diff options
author | cpettet <rush@wikimedia.org> | 2014-12-15 23:42:02 -0600 |
---|---|---|
committer | cpettet <rush@wikimedia.org> | 2014-12-15 23:42:02 -0600 |
commit | a339253851065809235d3b1dcd9e6eb315e58152 (patch) | |
tree | 03b1b358c469b4fa0a03d721d7e9e27bab82e184 /rt_populate_user_relations_table.py | |
parent | d33e8c56e65856a410fea855b6b5e9b34b5f3f6a (diff) |
getting through RT populate tables
Diffstat (limited to 'rt_populate_user_relations_table.py')
-rwxr-xr-x | rt_populate_user_relations_table.py | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/rt_populate_user_relations_table.py b/rt_populate_user_relations_table.py index 23f3063..278cf96 100755 --- a/rt_populate_user_relations_table.py +++ b/rt_populate_user_relations_table.py @@ -20,12 +20,15 @@ from wmfphablib import return_bug_list def populate(rtid): - pmig = phabdb.phdb(db=config.rtmigrate_db) + + pmig = phabdb.phdb(db=config.rtmigrate_db, + user=config.rtmigrate_user, + passwd=config.rtmigrate_passwd) issue = pmig.sql_x("SELECT id FROM rt_meta WHERE id = %s", rtid) if not issue: log('issue %s does not exist for user population' % (rtid,)) - return True + return 'missing' fpriority= pmig.sql_x("SELECT priority FROM rt_meta WHERE id = %s", rtid) if fpriority[0] == ipriority['fetch_failed']: @@ -45,18 +48,18 @@ def populate(rtid): relations['author'] = rtlib.user_lookup(header["Creator"]) ccusers = header['AdminCc'].split(',') + header['Cc'].split(',') relations['cc'] = ccusers + relations['cc'] = [cc.strip() for cc in relations['cc'] if cc] # RT uses a literal nobody for no assigned if header['Owner'] == 'Nobody': relations['owner'] = '' else: relations['owner'] = rtlib.user_lookup(header['Owner']) - for k, v in relations.iteritems(): if relations[k]: relations[k] = filter(bool, v) - def add_owner(owner): + def add_owner(owner): ouser = pmig.sql_x("SELECT user FROM user_relations WHERE user = %s", (owner,)) if ouser: jassigned = pmig.sql_x("SELECT assigned FROM user_relations WHERE user = %s", (owner,)) @@ -164,12 +167,21 @@ def run_populate(rtid, tries=1): def main(): bugs = return_bug_list() - from multiprocessing import Pool - pool = Pool(processes=10) - _ = pool.map(run_populate, bugs) - complete = len(filter(bool, _)) - failed = len(_) - complete - print '%s completed %s, failed %s' % (sys.argv[0], complete, failed) + result = [] + for b in bugs: + result.append(run_populate(b)) + + missing = len([i for i in result if i == 'missing']) + complete = len(filter(bool, [i for i in result if i not in ['missing']])) + failed = (len(result) - missing) - complete + print '-----------------------------\n \ + %s Total %s (missing %s)\n \ + completed %s, failed %s' % (sys.argv[0], + len(bugs), + missing, + complete, + failed) if __name__ == '__main__': main() + |