[Groonga-commit] groonga/groonga [master] follow the recent groonga output format changes.

Back to archive index

null+****@clear***** null+****@clear*****
2010年 6月 14日 (月) 15:26:27 JST


Kouhei Sutou	2010-06-14 06:26:27 +0000 (Mon, 14 Jun 2010)

  New Revision: 8f92f1160dd62603fe5e40d090108668a04bc7aa

  Log:
    follow the recent groonga output format changes.

  Modified files:
    data/munin/groonga_n_records
    data/munin/groonga_status

  Modified: data/munin/groonga_n_records (+12 -9)
===================================================================
--- data/munin/groonga_n_records    2010-06-14 02:31:48 +0000 (8e8a97c)
+++ data/munin/groonga_n_records    2010-06-14 06:26:27 +0000 (967e14d)
@@ -14,24 +14,27 @@ label = ENV["label"]
 
 command = ARGV.shift
 
-def parse(result)
-  header, body = JSON.parse(result)
-  if header[0].zero?
-    [true, body]
+def parse(success, result)
+  if success
+    begin
+      [success, JSON.parse(result)]
+    rescue JSON::ParserError
+      [false, $!.message]
+    end
   else
-    [false, header[3]]
+    [success, result]
   end
-rescue JSON::ParserError
-  [false, $!.message]
 end
 
 def run(command, *args)
   if @path
     path = Shellwords.shellescape(@path)
-    parse(`#{@groonga} #{path} #{command} #{args.join(' ')}`)
+    result = `#{@groonga} #{path} #{command} #{args.join(' ')} 2>&1`
   else
-    parse(`#{@groonga} -p #{@port} -c #{@host} #{command} #{args.join(' ')}`)
+    groonga = "#{@groonga} -p #{@port} -c #{@host}"
+    result = `#{groonga} #{command} #{args.join(' ')} 2>&1`
   end
+  parse($?.success?, result)
 end
 
 def parse_list(header, list)

  Modified: data/munin/groonga_status (+11 -8)
===================================================================
--- data/munin/groonga_status    2010-06-14 02:31:48 +0000 (8dc1c7a)
+++ data/munin/groonga_status    2010-06-14 06:26:27 +0000 (1f984cd)
@@ -12,19 +12,22 @@ label = ENV["label"]
 
 command = ARGV.shift
 
-def parse(result)
-  header, body = JSON.parse(result)
-  if header[0].zero?
-    [true, body]
+def parse(success, result)
+  if success
+    begin
+      [success, JSON.parse(result)]
+    rescue JSON::ParserError
+      [false, $!.message]
+    end
   else
-    [false, header[3]]
+    [success, result]
   end
-rescue JSON::ParserError
-  [false, $!.message]
 end
 
 def run(command, *args)
-  parse(`#{@groonga} -p #{@port} -c #{@host} #{command} #{args.join(' ')}`)
+  groonga = "#{@groonga} -p #{@port} -c #{@host}"
+  result = `#{groonga} #{command} #{args.join(' ')} 2>&1`
+  parse($?.success?, result)
 end
 
 def parse_list(header, list)




Groonga-commit メーリングリストの案内
Back to archive index