14 from __future__
import print_function
23 __schema =
"ATLAS_TAGS_METADATA"
26 'PR' :
'COMA_V_PERIOD_RUNS',
31 usedtables =
set( [o.split(
'.')[0]
for o
in output] )
35 if '.' in p
and '\'' not in p:
36 usedtables.add(p.split(
'.')[0].lstrip(
'('))
42 def query(cls, output, condition, bindvars, verbose=False):
43 query =
'select distinct %s from %s' % (
', '.
join(output),
46 query +=
' where ' +
' and '.
join(condition)
48 print (
"="*80,
"\n",query)
50 c.execute(
str(query),bindvars)
56 """get COMA connection
57 any connection to ATLR is fine, we use Trigger DB
61 from CoolRunQuery.utils.AtlRunQueryTriggerUtils
import interpretConnection
64 from cx_Oracle
import connect
65 connection = connect ( connectionParameters[
"user"],
66 connectionParameters[
"passwd"],
67 connectionParameters[
"server"], threaded=
True)
83 output = [
'PR.P_LEVEL',
'PR.P_PERIOD',
'PR.P_PROJECT' ]
84 condition = [
"PR.RUN_INDEX = :run" ]
85 bindvars = {
"run": run }
89 return [x[1]
for x
in cls.
__store[run]]
94 output = [
'PR.P_PERIOD',
'PR.P_PROJECT' ]
99 condition += [
"PR.P_LEVEL=:lvl" ]
100 bindvars[
"lvl"] = level
103 project =
'data%02i%%' % (year-2000)
104 condition += [
"PR.P_PROJECT like :proj" ]
105 bindvars[
"proj"] = project
107 return sorted( cls.
query(output, condition, bindvars) )
115 p = re.compile(
r"(?P<periodletter>[A-Za-z]+)(?P<periodnumber>\d+)?$")
118 for period, projectName
in result:
119 year =
int(projectName[4:6])
122 print (
"Period '%s'does not match pattern [A-Za-z]+\\d+" % period)
125 period_letter = m.group(
'periodletter')
126 period_number =
int(m.group(
'periodnumber'))
if m.group(
'periodnumber')
else 0
127 if len(period_letter)!=1:
130 pc = 10000*year + 100*(ord(period_letter.upper())-65) + period_number
132 cls.
all_periods += [ ((year, period, pc, projectName), projectName+
".period" + period) ]
137 traceback.print_exc()
144 output = [
'PR.RUN_INDEX',
'PR.P_LEVEL',
'PR.P_PERIOD',
'PR.P_PROJECT' ]
146 condition = [
"PR.P_PERIOD=:period" ]
147 bindvars = {
"period" : period }
149 project =
'data%02i%%' % (year-2000)
150 condition += [
"PR.P_PROJECT like :proj" ]
151 bindvars[
"proj"] = project
152 result = cls.
query(output, condition, bindvars)
156 for record
in result:
159 if run
not in tmpstore:
161 tmpstore[run] += [info]
165 return sorted( [r[0]
for r
in result] )
170 if __name__ ==
"__main__":
174 print (
"\n1 - periods for run")
175 print (
"2 - runs for period (and year)")
176 print (
"3 - periods (by year and/or level)")
177 print (
"4 - all periods (different format)")
178 print (
"\n0 - exit\n")
180 choice =
input(
" enter your choice: ")
181 choice =
int(choice)
if choice.isdigit()
else 0
184 print (ARQ_COMA.get_periods_for_run( run ))
187 year =
input(
" year <RET> = all : ")
188 year =
int(year)
if year.isdigit()
else 0
189 print (
', '.
join([
str(x)
for x
in ARQ_COMA.get_runs(period, year)]))
191 year =
input(
" year <RET> = all : ")
192 year =
int(year)
if year.isdigit()
else 0
193 level =
input(
" level [1|2|3] <RET> = all : ")
194 level =
int(level)
if level.isdigit()
else 0
195 print (ARQ_COMA.get_periods(year, level))
197 print (ARQ_COMA.get_all_periods())