Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

accept filenames as arguments, including gzip files

  • Loading branch information...
commit 93b6d70c41176d2d2e4c63d921fbcb7f0c6216cb 1 parent 4245092
Gregory Szorc indygreg authored

Showing 1 changed file with 27 additions and 3 deletions. Show diff stats Hide diff stats

  1. +27 3 parse_crashdata.py
30 parse_crashdata.py
@@ -47,8 +47,11 @@
47 47
48 48 from breakpad.crashdata import CrashDataParser
49 49 from optparse import OptionParser
  50 +from os.path import exists
50 51 from sys import stdin
51 52
  53 +import gzip
  54 +
52 55 op = OptionParser()
53 56 op.add_option('--signature', '-s', dest='signature', default=None,
54 57 help='Filter crashes by those containing this string in signature')
@@ -58,6 +61,8 @@
58 61
59 62 (options, args) = op.parse_args()
60 63
  64 +read_files = len(args) > 0
  65 +
61 66 print_uuids = True
62 67
63 68 if options.print_versions:
@@ -65,8 +70,7 @@
65 70
66 71 version_counts = {}
67 72
68   -parser = CrashDataParser()
69   -for row in parser.parse_handle(stdin):
  73 +def handle_row(row):
70 74 # filter stage
71 75 relevant = True
72 76
@@ -75,7 +79,7 @@
75 79 relevant = False
76 80
77 81 if not relevant:
78   - continue
  82 + return
79 83
80 84 # data collection
81 85 version = row.version
@@ -88,6 +92,26 @@
88 92 if print_uuids:
89 93 print row.uuid
90 94
  95 +parser = CrashDataParser()
  96 +if not read_files:
  97 + for row in parser.parse_handle(stdin):
  98 + handle_row(row)
  99 +else:
  100 + for filename in args:
  101 + if not exists(filename):
  102 + print 'Specified file does not exist: %s' % filename
  103 + continue
  104 +
  105 + # automagically perform gzip uncompression
  106 + if filename[-3:] == '.gz':
  107 + gz = gzip.open(filename, 'rb')
  108 + for row in parser.parse_handle(gz):
  109 + handle_row(row)
  110 +
  111 + else:
  112 + for row in parser.parse_file(filename):
  113 + handle_row(row)
  114 +
91 115 if options.print_versions:
92 116 keys = version_counts.keys()
93 117 keys.sort()

0 comments on commit 93b6d70

Please sign in to comment.
Something went wrong with that request. Please try again.