-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlhc_log_db_query.py
39 lines (28 loc) · 1.09 KB
/
lhc_log_db_query.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import time
def UnixTimeStamp2UTCTimberTimeString(t):
return time.strftime('%Y-%m-%d %H:%M:%S.000', time.gmtime(t))
def dbquery(varlist, t_start, t_stop, filename):
if type(t_start) is not str:
t_start_str_UTC = UnixTimeStamp2UTCTimberTimeString(t_start)
else:
t_start_str_UTC = t_start
if type(t_stop) is not str:
t_stop_str_UTC = UnixTimeStamp2UTCTimberTimeString(t_stop)
else:
t_stop_str_UTC = t_stop
if type(varlist) is not list:
raise TypeError
varlist_str = ''
for var in varlist:
varlist_str += var+','
varlist_str = varlist_str[:-1]
currpath = os.path.dirname(os.path.abspath(__file__))
execut = 'java -jar %s/accsoft-cals-extr-client-nodep.jar '%(currpath)
config = ' -C %s/ldb_UTC.conf '%(currpath)
time_interval = ' -t1 "'+ t_start_str_UTC +'" -t2 "'+t_stop_str_UTC+'"'
variables = '-vs "%s"'%(varlist_str)
outpfile = ' -N .//'+filename
command = execut+config+variables+time_interval+outpfile
print(command)
os.system(command)