~james-w/udd/management-commands

« back to all changes in this revision

Viewing changes to udd/scripts/count_outstanding_jobs.py

  • Committer: James Westby
  • Date: 2011-12-13 21:09:23 UTC
  • mfrom: (557.1.1 drop_email_failures)
  • Revision ID: james.westby@canonical.com-20111213210923-tfrirlx3xbwmi70u
Merged drop_email_failures into management-commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from udd import icommon
2
 
from udd.paths import paths
 
1
from udd import (
 
2
    icommon,
 
3
    iconfig,
 
4
    )
3
5
 
4
6
 
5
7
def main():
6
 
    conn = icommon.get_sqlite_connection(paths.sqlite_file)
7
 
    c = conn.cursor()
8
 
    try:
 
8
    conf = iconfig.ImporterStack()
 
9
    conn = icommon.get_sqlite_connection(conf.get('pi.sqlite_file'))
 
10
    with icommon.Cursor(conn) as c:
9
11
        rows = c.execute('select count(*), type from %s where active=1 '
10
12
                'group by type' % icommon.StatusDatabase.JOBS_TABLE).fetchall()
11
13
        for row in rows:
12
14
            print row
13
 
    except:
14
 
        conn.rollback()
15
 
        raise
16
 
    finally:
17
 
        c.close()