]> granicus.if.org Git - libvpx/commitdiff
Small fixes to script based off of cry-infra
authorJoshua Litt <joshualitt@google.com>
Fri, 4 Apr 2014 23:59:04 +0000 (16:59 -0700)
committerJoshua Litt <joshualitt@google.com>
Mon, 7 Apr 2014 21:41:04 +0000 (14:41 -0700)
Change-Id: I5a65d6fdb27516aefda0473ac45b05186cf0913c

test/android/scrape_gtest_log.py

index c159c893830679a15d6e650467e5b7718f873cec..487845c270c3e6c66444486bb8586bcef39a3b54 100644 (file)
@@ -13,16 +13,45 @@ waterfall to gather json results mixed in with gtest logs.  This is
 dubious software engineering.
 """
 
+import getopt
 import json
+import os
 import re
 import sys
 
 
 def main():
+  if len(sys.argv) != 3:
+    print "Expects a file to write json to!"
+    exit(1)
+
+  try:
+    opts, _ = \
+        getopt.getopt(sys.argv[1:], \
+                      'o:', ['output-json='])
+  except getopt.GetOptError:
+    print 'scrape_gtest_log.py -o <output_json>'
+    sys.exit(2)
+
+  output_json = ''
+  for opt, arg in opts:
+    if opt in ('-o', '--output-json'):
+      output_json = os.path.join(arg)
+
   blob = sys.stdin.read()
   json_string = '[' + ','.join('{' + x + '}' for x in
                                re.findall(r'{([^}]*.?)}', blob)) + ']'
-  print json.dumps(json.loads(json_string), indent=4, sort_keys=True)
+  print blob
+
+  output = json.dumps(json.loads(json_string), indent=4, sort_keys=True)
+  print output
+
+  path = os.path.dirname(output_json)
+  if path and not os.path.exists(path):
+    os.makedirs(path)
+
+  outfile = open(output_json, 'w')
+  outfile.write(output)
 
 if __name__ == '__main__':
   sys.exit(main())