From 95e5e0588df0057fbefd3a05e6203c7f8e92ab09 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Tue, 13 Feb 2018 10:17:20 -0500 Subject: Bug 1343248 - Migrate secbugstats scripts to bmo production --- contrib/secbugstats/bin/fillbugtable.py | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 contrib/secbugstats/bin/fillbugtable.py (limited to 'contrib/secbugstats/bin/fillbugtable.py') diff --git a/contrib/secbugstats/bin/fillbugtable.py b/contrib/secbugstats/bin/fillbugtable.py new file mode 100755 index 000000000..7f991a12d --- /dev/null +++ b/contrib/secbugstats/bin/fillbugtable.py @@ -0,0 +1,41 @@ +#!/usr/bin/python +# Fill the secbugs_Bugs table +# Should not be run regularly as it runs bugdata.py (API script) on every +# bug_id we have stored in the DB. +import sys, MySQLdb, os +from settings import * + +if "--debug" in sys.argv: + DEBUG = True +else: + DEBUG = False + +# set up database connection +db = MySQLdb.connect(host=DB_HOST, user=DB_USER, passwd=DB_PASS, db=DB_NAME) +db.autocommit(True) +cur = db.cursor() + +severities = ["sg_critical","sg_high","sg_moderate","sg_low"] + +for sev in severities: + sql = "SELECT d.bug_list FROM secbugs_Details d WHERE d.sid IN (SELECT s.sid FROM secbugs_Stats s WHERE category='%s' and date > '2008-07-01');" % (sev) + # complete list of bugs for this severity level + complete = [] + # print "#", sql + cur.execute(sql) + row = cur.fetchone() + while row is not None: + # row e.g. ('408736,430127',) + # print "# ", row + bugs = row[0].split(",") + for bug in bugs: + if len(bug): complete.append(bug) + row = cur.fetchone() + + unique = list(set(complete)) + print "Going to fetch data for %d %s bugs..." % (len(unique), sev[3:]) + + for bug in unique: + cmd = "%s/bugdata.py %s" % (SCRIPTS_DIR, bug) + print cmd + if not DEBUG: os.popen(cmd) -- cgit v1.2.3-24-g4f1b