1616 ~itemizer
1717 ~json_export
1818 ~json_import
19+ ~listruns
1920 ~list_recent_scans
2021 ~pairwise
2122 ~print_snapshot_list
@@ -187,55 +188,62 @@ def itemizer(fmt, items):
187188 return [fmt % k for k in items ]
188189
189190
190- def list_recent_scans (num = 20 , keys = [], printing = True , show_command = False , db = None ):
191+ def list_recent_scans (raises = False , ** kwargs ):
192+ """(deprecated): use ``listruns`` instead"""
193+ msg = "'list_recent_scans()' is deprecated"
194+ msg += ", use 'listruns()' instead"
195+ if raises :
196+ raise RuntimeWarning (msg )
197+ logger .warning (msg )
198+ return listruns (** kwargs )
199+
200+
201+ def listruns (
202+ num = 20 , keys = [], printing = True ,
203+ show_command = True , db = None ):
191204 """
192- make a table of the most recent scans
205+ make a table of the most recent runs ( scans)
193206
194207 PARAMETERS
195208
196209 num : int
197- Make the table include the ``num`` most recent scans .
210+ Make the table include the ``num`` most recent runs .
198211 (default: ``20``)
199212 keys : [str]
200213 Include these additional keys from the start document.
201214 (default: ``[]``)
202-
203- Two special keys are supported:
204-
205- * ``command`` : shows the scan command.
206- (note: This command is reconstructed from keys in the start
207- document so it will not be exactly as the user typed.
208- Also, it will be truncated so that it is no more than 40 characters.)
209- * ``exit_status`` : from the stop document
210-
211215 printing : bool
212216 If True, print the table to stdout
213217 (default: ``True``)
214218 show_command : bool
215219 If True, show the (reconstructed) full command,
216220 but truncate it to no more than 40 characters)
217- (default: ``False``)
221+ (note: This command is reconstructed from keys in the start
222+ document so it will not be exactly as the user typed.)
223+ (default: ``True``)
218224 db : object
219225 Instance of ``databroker.Broker()``
220226 (default: ``db`` from the IPython shell)
221227
222228 RETURNS
223229
224230 object:
225- Instance of `pyRestTable.Table()``
231+ Instance of `` pyRestTable.Table()``
226232
227233 EXAMPLE::
228234
229- In [7]: APS_utils.list_recent_scans(num=5, keys=["proposal_id","pid"])
230- ========= ========================== ======= ========= =========== =====
231- short_uid date/time scan_id plan_name proposal_id pid
232- ========= ========================== ======= ========= =========== =====
233- 235cc8e 2019-07-26 19:59:57.377210 156 scan testing 31185
234- 82406dd 2019-07-26 19:57:30.607125 155 scan testing 31185
235- f6249d8 2019-07-25 16:45:36.114533 151 count testing 15321
236- 9457fa4 2019-07-25 16:19:07.410803 150 count testing 4845
237- f17f026 2019-07-25 16:19:04.929030 149 count testing 4845
238- ========= ========================== ======= ========= =========== =====
235+ In [2]: from apstools import utils as APS_utils
236+
237+ In [3]: APS_utils.listruns(num=5, keys=["proposal_id","pid"])
238+ ========= ========================== ======= ======= ======================================== =========== ===
239+ short_uid date/time exit scan_id command proposal_id pid
240+ ========= ========================== ======= ======= ======================================== =========== ===
241+ 5f2bc62 2019-03-10 22:27:57.803193 success 3 fly()
242+ ef7777d 2019-03-10 22:27:12.449852 success 2 fly()
243+ 8048ea1 2019-03-10 22:25:01.663526 success 1 scan(detectors=['calcs_calc2_val'], ...
244+ 83ad06d 2019-03-10 22:19:14.352157 success 4 fly()
245+ b713d46 2019-03-10 22:13:26.481118 success 3 fly()
246+ ========= ========================== ======= ======= ======================================== =========== ===
239247
240248 *new in apstools release 1.1.10*
241249 """
@@ -247,12 +255,13 @@ def list_recent_scans(num=20, keys=[], printing=True, show_command=False, db=Non
247255 labels = "scan_id plan_name" .split () + keys
248256
249257 table = pyRestTable .Table ()
250- table .labels = "short_uid date/time" .split () + labels
258+ table .labels = "short_uid date/time exit " .split () + labels
251259
252260 for h in db [- abs (num ):]:
253261 row = [
254262 h .start ["uid" ][:7 ],
255263 datetime .datetime .fromtimestamp (h .start ['time' ]),
264+ h .stop .get ("exit_status" , "" )
256265 ]
257266 for k in labels :
258267 if k == "command" :
@@ -263,8 +272,6 @@ def list_recent_scans(num=20, keys=[], printing=True, show_command=False, db=Non
263272 suffix = " ..."
264273 command = command [:maxlen - len (suffix )] + suffix
265274 row .append (command )
266- elif k == "exit_status" :
267- row .append (h .stop .get (k , "" ))
268275 else :
269276 row .append (h .start .get (k , "" ))
270277 table .addRow (row )
0 commit comments