diff --git a/ccdb/hdds2ccdb.py b/ccdb/hdds2ccdb.py index ba6fa19e..3bd4f978 100755 --- a/ccdb/hdds2ccdb.py +++ b/ccdb/hdds2ccdb.py @@ -6,7 +6,7 @@ # author: richard.t.jones at uconn.edu # version: may 17, 2018 # -# Usage: hddm2ccdb.py [-r ] [-v ] command +# Usage: hddm2ccdb.py [-r ] [-v ] [-d ] command # where command is one of # * ls # * get
@@ -14,6 +14,7 @@ # with # is a run number starting at 1 [1] # is a variation string [default] +# is a date string like "2024-04-12 09:30:00" #
is a GEOMETRY table name, eg BeamLine_HDDS.xml # is a log comment to go with the ccdb update, in quotes # @@ -21,10 +22,11 @@ import os import sys import ccdb +import datetime def usage(): str1 = """ - Usage: hddm2ccdb.py [-r ] [-v ] command + Usage: hddm2ccdb.py [-r ] [-v ] [-d datetime] command where command is one of * ls
* get
@@ -32,6 +34,7 @@ def usage(): with is a run number or range, like 10222 or 10222-10224 [1] is a variation string [default] + is a date string, eg "2024-04-12 09:30:00"
is a GEOMETRY table name, eg BeamLine_HDDS.xml is a log comment to go with the ccdb update, in quotes """ @@ -64,7 +67,7 @@ def do_get_table(tpath): table = provider.get_type_table(tpath) try: runs = run.split('-') - ass = provider.get_assignment(tpath, runs[0], var) + ass = provider.get_assignment(tpath, runs[0], var, date) except: print( "no entry found") return @@ -90,6 +93,8 @@ def do_set_table(tpath, comment): get_table = "" set_table = "" comment = "" +date = "" + i = 1 while i < len(sys.argv[1:]): if sys.argv[i][:2] == "-r": @@ -104,6 +109,12 @@ def do_set_table(tpath, comment): else: i += 1 var = sys.argv[i] + elif sys.argv[i][:2] == "-d": + if len(sys.argv[i]) > 2: + date = sys.argv[i][2:] + else: + i += 1 + date = sys.argv[i] elif sys.argv[i] == "ls": i += 1 ls_table = sys.argv[i] @@ -119,6 +130,10 @@ def do_set_table(tpath, comment): if not ls_table and not get_table and not set_table: usage() + +if date != "" : + calibdate = datetime.datetime.fromisoformat(date) + # Connect to CCDB DB sqlite_connect_str = os.environ["JANA_CALIB_URL"] provider = ccdb.AlchemyProvider()