Skip to content

Commit

Permalink
fixes #315 - remove the old example
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian authored May 28, 2020
1 parent ef702d9 commit d417c5a
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions apstools/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,63 +47,11 @@ def specfile_example(headers, filename=DEMO_SPEC_FILE):
logger.info("Look at SPEC data file: "+specwriter.spec_filename)


def plan_catalog(db):
"""
make a table of all scans known in the databroker
Example::
from apstools.examples import plan_catalog
plan_catalog(db)
"""
import warnings
warnings.warn("DEPRECATED: use apstools.utils.listruns()")
import pyRestTable
t = pyRestTable.Table()
t.labels = "date/time short_uid id plan args".split()
for h in db.v1():
doc = h.start
row = []
dt = datetime.datetime.fromtimestamp(doc["time"])
row.append(str(dt).split(".")[0])
row.append(doc['uid'][:8])
command = _rebuild_scan_command(doc)
scan_id = command.split()[0]
command = command[len(scan_id):].strip()
plan = command.split("(")[0]
args = command[len(plan)+1:].rstrip(")")
row.append(scan_id)
row.append(plan)
row.append(args)
t.addRow(row)
t.rows = t.rows[::-1] # reverse the list
return t


def main():
"""
summary list of all scans in the databroker
``apstools_plan_catalog`` command-line application
This can be unwieldy if there are many scans in the databroker.
Consider it as a demo program rather than for general, long-term use.
"""
# load config from ~/.config/databroker/mongodb_config.yml
db = databroker.Broker.named("mongodb_config")
table = plan_catalog(db)
print(table)
print("Found {} plans (start documents)".format(len(table.rows)))


if __name__ == "__main__":
main()

# load config from ~/.config/databroker/mongodb_config.yml
# db = Broker.named("mongodb_config")

# plan_catalog(db)
# specfile_example(db[-1])
# specfile_example(db[-5:][::-1])
# specfile_example(db["1d2a3890"])
Expand Down

0 comments on commit d417c5a

Please sign in to comment.