Created
August 4, 2011 23:01
-
-
Save rhelmer/1126517 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 | |
import psycopg2 | |
import socorro.lib.psycopghelper as psy | |
import socorro.lib.util as util | |
logger = logging.getLogger("duplicates") | |
def update(config, targetDate): | |
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 = [] | |
databaseDSN = "host=%(databaseHost)s dbname=%(databaseName)s user=%(databaseUserName)s password=%(databasePassword)s" % config | |
connection = psycopg2.connect(databaseDSN) | |
cursor = connection.cursor() | |
for function in functions: | |
(funcname, parameters, deps) = function | |
try: | |
if set(failed).intersection(set(deps)): | |
print >>sys.stderr, '%s dependency failed. Skipping' % (funcname) | |
# FIXME what to raise here? | |
raise | |
print 'running %s' % funcname | |
cursor.callproc(funcname, parameters) | |
if cursor.fetchone() is not True: | |
failed.append(funcname) | |
print >>sys.stderr, '%s failed' % (funcname) | |
connection.commit() | |
# FIXME what to catch here? | |
except: | |
failed.append(funcname) | |
print >>sys.stderr, '%s failed' % (funcname) | |
print >>sys.stderr, sys.exc_info() | |
connection.rollback() | |
return len(failed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/1128049 <- something like that