-
-
Save lonnen/1128049 to your computer and use it in GitHub Desktop.
newtcbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import logging, sys | |
logger = logging.getLogger("duplicates") | |
import socorro.lib.psycopghelper as psy | |
import socorro.lib.util as util | |
def update(config, targetDate): | |
databaseConnectionPool = psy.DatabaseConnectionPool(config.databaseHost, config.databaseName, config.databaseUserName, config.databasePassword, logger) | |
functions = [ | |
# function name, parmeters, dependencies | |
('update_product_versions',[],[]), | |
('update_signatures', [targetDate],[]), | |
('update_os_versions', [targetDate],[]), | |
('update_tcbs', [targetDate], ['update_product_versions', 'update_signatures']), | |
('update_adu', [targetDate],[]) | |
] | |
failed = [] | |
for function in functions: | |
connection, cursor = databaseConnectionPool.connectionCursorPair() | |
(funcname, parameters, deps) = function | |
try: | |
if set(failed) & set(deps): | |
print >>sys.stderr, '%s dependency failed. Skipping' % (funcname) | |
continue | |
print 'running %s' % funcname | |
cursor.callproc(funcname, parameters) | |
if not cursor.fetchone(): | |
raise Exception("oh man, oh geez, oh man, oh geez") | |
connection.commit() | |
except: | |
failed.append(funcname) | |
print >>sys.stderr, '%s failed' % (funcname) | |
print >>sys.stderr, sys.exc_info() | |
finally: | |
databaseConnectionPool.cleanup() | |
return len(failed) | |
('update_product_versions',[],[]), | |
('update_signatures', [targetDate],[]), | |
('update_os_versions', [targetDate],[]), | |
('update_tcbs', [targetDate], ['update_product_versions', 'update_signatures']), | |
('update_adu', [targetDate],[]) | |
] | |
failed = [] | |
connection, cursor = databaseConnectionPool.connectionCursorPair() | |
for function in functions: | |
(funcname, parameters, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment