in crashes.py [0:0]
def main():
# Maximum number of raw crashes to process. This matches
# the limit value of re:dash queries. Reduce for testing
# purposes.
CrashProcessMax = 7500
# When generating a report, signatures with client counts
# lower than this value will not be included in the report.
ReportLowerClientLimit = 2 # filter out single client crashes
queryId = ''
userKey = ''
targetSignature = ''
dbFilename = "crashreports" #.json
annoFilename = "annotations"
cacheValue = MaxAge
parameters = dict()
ipcActor = None
options, remainder = getopt.getopt(sys.argv[1:], 'c:u:n:d:c:k:q:p:a:s:zml:')
for o, a in options:
if o == '-u':
jsonUrl = a
print("data source url: %s" % jsonUrl)
elif o == '-n':
outputFilename = a
print("output filename: %s.html" % outputFilename)
elif o == '-c':
cacheValue = int(a)
elif o == '-d':
dbFilename = a
print("local cache file: %s.json" % dbFilename)
elif o == '-c':
CrashProcessMax = int(a)
elif o == '-q':
queryId = a
print("query id: %s" % queryId)
elif o == '-k':
userKey = a
print("user key: ({}) [CLI]".format(len(userKey)))
elif o == '-s':
targetSignature = a
print("target signature: %s" % targetSignature)
elif o == '-m':
print("calling maintenance function.")
doMaintenance(dbFilename)
exit()
elif o == '-p':
param = a.split('=')
parameters[param[0]] = param[1]
elif o == '-a':
ipcActor = a
print("IPC actor: %s" % ipcActor)
elif o == '-z':
reports, stats = loadReports(dbFilename)
dumpDatabase(reports)
exit()
elif o == '-l':
ReportLowerClientLimit = int(a)
print("ReportLowerClientLimit: %d" % ReportLowerClientLimit)
if len(userKey) == 0:
userKey = os.getenv("REDASH_API_KEY")
if userKey:
print("user key: ({}) [ENV]".format(len(userKey)))
else:
print("No user key; use -k or REDASH_API_KEY")
exit()
if ipcActor is not None:
if ipcActor == "none":
parameters["utility_actor_name_op"] = "IS NULL"
else:
parameters["utility_actor_name_op"] = 'LIKE "%{}%"'.format(ipcActor)
if len(userKey) == 0:
print("missing user api key.")
exit()
elif len(queryId) == 0:
print("missing query id.")
exit()
print("redash cache time: %d" % cacheValue)
parameters['crashcount'] = str(CrashProcessMax)
if len(targetSignature) > 0:
print("analyzing '%s'" % targetSignature)
generateSignatureReport(targetSignature)
exit()
# Pull fresh data from redash and process it
reports, stats, totalCrashesProcessed = processRedashDataset(dbFilename, jsonUrl, queryId, userKey, cacheValue, parameters, CrashProcessMax)
# Caching of reports
cacheReports(reports, stats, dbFilename)
generateTopCrashReport(reports, stats, totalCrashesProcessed, parameters, ipcActor, outputFilename, annoFilename, ReportLowerClientLimit)
exit()