22 __schema =
"ATLAS_TAGS_METADATA"
25 'PR' :
'COMA_V_PERIOD_RUNS',
30 usedtables =
set( [o.split(
'.')[0]
for o
in output] )
34 if '.' in p
and '\'' not in p:
35 usedtables.add(p.split(
'.')[0].lstrip(
'('))
41 def query(cls, output, condition, bindvars, verbose=False):
42 query =
'select distinct %s from %s' % (
', '.
join(output),
45 query +=
' where ' +
' and '.
join(condition)
47 print (
"="*80,
"\n",query)
49 c.execute(
str(query),bindvars)
55 """get COMA connection
56 any connection to ATLR is fine, we use Trigger DB
60 from CoolRunQuery.utils.AtlRunQueryTriggerUtils
import interpretConnection
63 from cx_Oracle
import connect
64 connection = connect ( connectionParameters[
"user"],
65 connectionParameters[
"passwd"],
66 connectionParameters[
"server"], threaded=
True)
82 output = [
'PR.P_LEVEL',
'PR.P_PERIOD',
'PR.P_PROJECT' ]
83 condition = [
"PR.RUN_INDEX = :run" ]
84 bindvars = {
"run": run }
88 return [x[1]
for x
in cls.
__store[run]]
93 output = [
'PR.P_PERIOD',
'PR.P_PROJECT' ]
98 condition += [
"PR.P_LEVEL=:lvl" ]
99 bindvars[
"lvl"] = level
102 project =
'data%02i%%' % (year-2000)
103 condition += [
"PR.P_PROJECT like :proj" ]
104 bindvars[
"proj"] = project
106 return sorted( cls.
query(output, condition, bindvars) )
114 p = re.compile(
r"(?P<periodletter>[A-Za-z]+)(?P<periodnumber>\d+)?$")
117 for period, projectName
in result:
118 year =
int(projectName[4:6])
121 print (
"Period '%s'does not match pattern [A-Za-z]+\\d+" % period)
124 period_letter = m.group(
'periodletter')
125 period_number =
int(m.group(
'periodnumber'))
if m.group(
'periodnumber')
else 0
126 if len(period_letter)!=1:
129 pc = 10000*year + 100*(ord(period_letter.upper())-65) + period_number
131 cls.
all_periods += [ ((year, period, pc, projectName), projectName+
".period" + period) ]
136 traceback.print_exc()
143 output = [
'PR.RUN_INDEX',
'PR.P_LEVEL',
'PR.P_PERIOD',
'PR.P_PROJECT' ]
145 condition = [
"PR.P_PERIOD=:period" ]
146 bindvars = {
"period" : period }
148 project =
'data%02i%%' % (year-2000)
149 condition += [
"PR.P_PROJECT like :proj" ]
150 bindvars[
"proj"] = project
151 result = cls.
query(output, condition, bindvars)
155 for record
in result:
158 if run
not in tmpstore:
160 tmpstore[run] += [info]
164 return sorted( [r[0]
for r
in result] )
169 if __name__ ==
"__main__":
173 print (
"\n1 - periods for run")
174 print (
"2 - runs for period (and year)")
175 print (
"3 - periods (by year and/or level)")
176 print (
"4 - all periods (different format)")
177 print (
"\n0 - exit\n")
179 choice = input(
" enter your choice: ")
180 choice =
int(choice)
if choice.isdigit()
else 0
182 run =
int(input(
" run number: "))
183 print (ARQ_COMA.get_periods_for_run( run ))
185 period = input(
" period : ")
186 year = input(
" year <RET> = all : ")
187 year =
int(year)
if year.isdigit()
else 0
188 print (
', '.
join([
str(x)
for x
in ARQ_COMA.get_runs(period, year)]))
190 year = input(
" year <RET> = all : ")
191 year =
int(year)
if year.isdigit()
else 0
192 level = input(
" level [1|2|3] <RET> = all : ")
193 level =
int(level)
if level.isdigit()
else 0
194 print (ARQ_COMA.get_periods(year, level))
196 print (ARQ_COMA.get_all_periods())