Skip to content

Commit

Permalink
fixes #206
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Jul 29, 2019
1 parent 052cd0f commit 5a49846
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion apstools/utils.py
Expand Up @@ -12,10 +12,11 @@
~ExcelDatabaseFileBase
~ExcelDatabaseFileGeneric
~ExcelReadError
~ipython_profile_name
~itemizer
~json_export
~json_import
~ipython_profile_name
~list_recent_scans
~pairwise
~print_snapshot_list
~print_RE_md
Expand Down Expand Up @@ -181,6 +182,33 @@ def itemizer(fmt, items):
return [fmt % k for k in items]


def list_recent_scans(num=20, db=None):
"""
make a table of the most recent scans
"""
try:
from IPython import get_ipython
global_db = get_ipython().user_ns["db"]
except AttributeError as _exc:
global_db = None
db = db or global_db

table = pyRestTable.Table()
table.labels = "scan_id date/time plan_name short_uid".split()

for h in db[-abs(num):]:
row = [
h.start['scan_id'],
datetime.datetime.fromtimestamp(h.start['time']),
h.start.get("plan_name", ""),
h.start["uid"][:7]
]
table.addRow(row)

print(table)
return table


def print_RE_md(dictionary=None, fmt="simple", printing=True):
"""
custom print the RunEngine metadata in a table
Expand Down

0 comments on commit 5a49846

Please sign in to comment.