@@ -141,7 +141,7 @@ def dictionary_table(dictionary, fmt="simple"):
141141
142142 default: ``simple``
143143
144- .. [#] *pyRestTable* : https://pyresttable.readthedocs.io/en/latest/examples/index.html#examples
144+ .. [#] *pyRestTable* : https://pyresttable.readthedocs.io/en/latest/examples/index.html#examples
145145
146146 RETURNS
147147
@@ -182,9 +182,39 @@ def itemizer(fmt, items):
182182 return [fmt % k for k in items ]
183183
184184
185- def list_recent_scans (num = 20 , printing = True , db = None ):
185+ def list_recent_scans (num = 20 , keys = [], printing = True , db = None ):
186186 """
187187 make a table of the most recent scans
188+
189+ PARAMETERS
190+
191+ num : int (default: ``20``)
192+ Make the table include the ``num`` most recent scans.
193+ keys : [str] (default: ``[]``)
194+ Include these additional keys from the start document.
195+ printing : bool (default: ``True``)
196+ If True, print the table to stdout
197+ db : object (default: ``db`` from the IPython shell)
198+ Instance of ``databroker.Broker()``
199+
200+ RETURNS
201+
202+ object:
203+ Instance of `pyRestTable.Table()``
204+
205+ EXAMPLE::
206+
207+ In [7]: APS_utils.list_recent_scans(num=5, keys=["proposal_id","pid"])
208+ ========= ========================== ======= ========= =========== =====
209+ short_uid date/time scan_id plan_name proposal_id pid
210+ ========= ========================== ======= ========= =========== =====
211+ 235cc8e 2019-07-26 19:59:57.377210 156 scan testing 31185
212+ 82406dd 2019-07-26 19:57:30.607125 155 scan testing 31185
213+ f6249d8 2019-07-25 16:45:36.114533 151 count testing 15321
214+ 9457fa4 2019-07-25 16:19:07.410803 150 count testing 4845
215+ f17f026 2019-07-25 16:19:04.929030 149 count testing 4845
216+ ========= ========================== ======= ========= =========== =====
217+
188218 """
189219 try :
190220 from IPython import get_ipython
@@ -193,16 +223,17 @@ def list_recent_scans(num=20, printing=True, db=None):
193223 global_db = None
194224 db = db or global_db
195225
226+ keys .insert (0 , "plan_name" )
227+ keys .insert (0 , "scan_id" )
228+
196229 table = pyRestTable .Table ()
197- table .labels = "scan_id date/time plan_name short_uid " .split ()
230+ table .labels = "short_uid date/time" .split () + keys
198231
199232 for h in db [- abs (num ):]:
200233 row = [
201- h .start ['scan_id' ],
234+ h .start ["uid" ][: 7 ],
202235 datetime .datetime .fromtimestamp (h .start ['time' ]),
203- h .start .get ("plan_name" , "" ),
204- h .start ["uid" ][:7 ]
205- ]
236+ ] + [h .start .get (k , "" ) for k in keys ]
206237 table .addRow (row )
207238
208239 if printing :
@@ -314,6 +345,11 @@ def show_ophyd_symbols(show_pv=True, printing=True, verbose=False, symbols=None)
314345 If None, use global symbol table.
315346 If not None, use provided dictionary.
316347
348+ RETURNS
349+
350+ object:
351+ Instance of `pyRestTable.Table()``
352+
317353 EXAMPLE::
318354
319355 In [1]: show_ophyd_symbols()
0 commit comments