Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions ccdb/hdds2ccdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,35 @@
# author: richard.t.jones at uconn.edu
# version: may 17, 2018
#
# Usage: hddm2ccdb.py [-r <run>] [-v <var>] command
# Usage: hddm2ccdb.py [-r <run>] [-v <var>] [-d <datetime>] command
# where command is one of
# * ls <table>
# * get <table>
# * set <table> <comment>
# with
# <run> is a run number starting at 1 [1]
# <var> is a variation string [default]
# <date> is a date string like "2024-04-12 09:30:00"
# <table> is a GEOMETRY table name, eg BeamLine_HDDS.xml
# <comment> is a log comment to go with the ccdb update, in quotes
#

import os
import sys
import ccdb
import datetime

def usage():
str1 = """
Usage: hddm2ccdb.py [-r <run>] [-v <var>] command
Usage: hddm2ccdb.py [-r <run>] [-v <var>] [-d datetime] command
where command is one of
* ls <table>
* get <table>
* set <table> <comment>
with
<run> is a run number or range, like 10222 or 10222-10224 [1]
<var> is a variation string [default]
<datetime> is a date string, eg "2024-04-12 09:30:00"
<table> is a GEOMETRY table name, eg BeamLine_HDDS.xml
<comment> is a log comment to go with the ccdb update, in quotes
"""
Expand Down Expand Up @@ -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
Expand All @@ -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":
Expand All @@ -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]
Expand All @@ -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()
Expand Down