Skip to content

Instantly share code, notes, and snippets.

@lonnen
Forked from rhelmer/newtcbs.py
Created August 4, 2011 23:05
Show Gist options
  • Save lonnen/1126528 to your computer and use it in GitHub Desktop.
Save lonnen/1126528 to your computer and use it in GitHub Desktop.
newtcbs
#!/usr/bin/python
import logging
from datetime import datetime
from datetime import timedelta
logger = logging.getLogger("duplicates")
import socorro.lib.psycopghelper as psy
import socorro.lib.util as util
def update(config):
databaseConnectionPool = psy.DatabaseConnectionPool(config.databaseHost, config.databaseName, config.databaseUserName, config.databasePassword, logger)
sql = {
'update_product_versions' : """SELECT update_product_versions()""",
'update_signatures' : """SELECT update_signatures()""",
'update_os_versions' : """SELECT update_os_versions()""",
'update_tcbs' : """SELECT update_tcbs()""",
'update_adu' : """SELECT update_adu()""",
}
deps = { 'update_tcbs': ['update_product_versions', 'update_signatures'] }
for f in sql.keys():
try:
print f
connection, cursor= databaseConnectionPool.connectionCursorPair()
cursor.execute(sql[f]])
connection.commit()
except:
if f in deps:
print "%s failed, not running %s" % (f, deps[f])
print functions
for d in deps[f]:
functions.remove(d)
print functions
finally:
databaseConnectionPool.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment