Commit 53563f9c authored by Mathieu Giraud's avatar Mathieu Giraud

scripts/db-stats.py: 2to3

See #2758.
parent 7f2f11db
......@@ -27,54 +27,54 @@ def ellipsis(what, max_size=30):
return what[:max_size-len(ell)] + ell
return what
print
print()
yesterday = datetime.datetime.now() - datetime.timedelta(hours=LAST_HOURS)
RUN_CONFIG_SEQ_PATIENT = (db.results_file.sequence_file_id == db.sequence_file.id) & (db.sample_set_membership.sequence_file_id == db.sequence_file.id) & (db.sample_set_membership.sample_set_id == db.patient.sample_set_id) & (db.config.id == db.results_file.config_id) & (db.scheduler_task.id == db.results_file.scheduler_task_id)
print
print "=== Recent not completed tasks, last %d hours" % LAST_HOURS
print()
print("=== Recent not completed tasks, last %d hours" % LAST_HOURS)
for res in db((db.scheduler_task.last_run_time >= yesterday) & (db.scheduler_task.status != 'COMPLETED')).select():
print " ", "sch-%04d" % res.id, "\t", res.status, " ", "\t", res.start_time, "\t", res.args,
print "\t", tmp_dir(res.args)
print(" ", "sch-%04d" % res.id, "\t", res.status, " ", "\t", res.start_time, "\t", res.args, end=' ')
print("\t", tmp_dir(res.args))
print
print "=== Recent analysis saved, last %d hours" % LAST_HOURS
print()
print("=== Recent analysis saved, last %d hours" % LAST_HOURS)
for res in db((db.analysis_file.analyze_date >= yesterday) & (db.patient.sample_set_id == db.analysis_file.sample_set_id)).select():
print " ", res.analysis_file.analyze_date,
print "\t", "pat-%04d (%s)" % (res.patient.id, res.patient.last_name[:3]),
print "\t", ellipsis(res.analysis_file.analysis_file, 50)
print(" ", res.analysis_file.analyze_date, end=' ')
print("\t", "pat-%04d (%s)" % (res.patient.id, res.patient.last_name[:3]), end=' ')
print("\t", ellipsis(res.analysis_file.analysis_file, 50))
print
print "=== Recent auth events, last %d hours" % LAST_HOURS
print()
print("=== Recent auth events, last %d hours" % LAST_HOURS)
for res in db((db.auth_event.time_stamp >= yesterday) & (db.auth_user.id == db.auth_event.user_id)).select():
print " ", res.auth_event.time_stamp, res.auth_event.client_ip,
print "\t", "%3d" % res.auth_user.id, "%-24s" % (res.auth_user.first_name + ' ' + res.auth_user.last_name),
print "\t", res.auth_event.description
print(" ", res.auth_event.time_stamp, res.auth_event.client_ip, end=' ')
print("\t", "%3d" % res.auth_user.id, "%-24s" % (res.auth_user.first_name + ' ' + res.auth_user.last_name), end=' ')
print("\t", res.auth_event.description)
print
print "=== Recent results files, last %d hours" % LAST_HOURS
print()
print("=== Recent results files, last %d hours" % LAST_HOURS)
for res in db((db.results_file.run_date >= yesterday) & RUN_CONFIG_SEQ_PATIENT).select():
print " ", "sch-%04d" % res.results_file.scheduler_task_id, "\t", res.scheduler_task.status, " ",
print "\t", res.results_file.run_date, "\t", res.config.name, # "\t", res.data_file,
print "\t", "seq-%04d" % res.sequence_file.id, "%-20s" % res.sequence_file.filename,
print "\t", "pat-%04d (%s)" % (res.patient.id, res.patient.last_name[:3]),
print "\t", tmp_dir(res.scheduler_task.args), ellipsis(res.results_file.data_file)
print(" ", "sch-%04d" % res.results_file.scheduler_task_id, "\t", res.scheduler_task.status, " ", end=' ')
print("\t", res.results_file.run_date, "\t", res.config.name, end=' ') # "\t", res.data_file,
print("\t", "seq-%04d" % res.sequence_file.id, "%-20s" % res.sequence_file.filename, end=' ')
print("\t", "pat-%04d (%s)" % (res.patient.id, res.patient.last_name[:3]), end=' ')
print("\t", tmp_dir(res.scheduler_task.args), ellipsis(res.results_file.data_file))
print
print "=== Tables"
print()
print("=== Tables")
for table in db.tables:
print "%10s %-20s" % (len(db(db[table]).select()), table)
print("%10s %-20s" % (len(db(db[table]).select()), table))
print
print()
log.debug("=== db-stats.py completed ===")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment