27 input_pool_connect_string =
"sqlite_file:/nfshome0/kukartse/hcal/dcs/HcalDcsValues_v1.00_offline.db"
28 output_pool_connect_string =
"sqlite_file:/nfshome0/kukartse/hcal/dcs/HcalDcsValues_v1.00_offline.db"
29 pool_auth_path =
"/nfshome0/popcondev/conddb"
30 pool_logconnect =
"sqlite_file:/nfshome0/kukartse/hcal/dcs/log.db"
31 omds_accessor_string =
"occi://CMS_HCL_APPUSER_R@anyhost/cms_omds_lb?PASSWORD=HCAL_Reader_44"
34 o2o_tag_list_file =
"o2o_tag_list.txt"
35 python_popcon_template_file =
"dbwrite_o2o_template.py"
36 python_popcon_file =
"dbwrite_o2o.py"
41 dropbox_dir =
"./dropbox"
42 dropbox_destination_db =
'oracle://cms_orcon_prod/CMS_COND_31X_HCAL'
43 dropbox_comment =
'generated by CaloOnlineTools/HcalOnlineDb/test/o2o.py script'
53 py_templ_file = open(base_dir+
"/"+python_popcon_template_file)
54 py_file = open(str(filename),
"w")
55 for line
in py_templ_file:
56 line=line.replace(
'CONNECT_STRING', output_pool_connect_string)
57 line=line.replace(
'POOL_AUTH_PATH', pool_auth_path)
58 line=line.replace(
'CONDITION_TYPE', condition_type)
59 line=line.replace(
'OMDS_CONDITION_TAG', tag)
60 line=line.replace(
'OMDS_IOV', str(iov))
61 line=line.replace(
'OMDS_ACCESSOR_STRING', omds_accessor_string)
62 line=line.replace(
'OMDS_QUERY', query)
63 line=line.replace(
'POOL_LOGCONNECT', pool_logconnect)
64 line=line.replace(
'POOL_RECORD', pool_record)
65 line=line.replace(
'POOL_OUTPUT_TAG', tag)
66 line=line.replace(
'POOL_IOV', str(pool_iov))
77 guessed_type = tagname[0:tagname.find(
"_")]
79 if guessed_type ==
"gak":
80 guessed_type =
"HcalChannelQuality"
81 guessed_query_file_name = base_dir+
"/HcalChannelQuality.sql"
82 guessed_pool_record =
"HcalChannelQualityRcd"
84 elif guessed_type ==
"HcalDcsValues":
85 guessed_type =
"DcsValues"
86 guessed_query_file_name = base_dir+
"/HcalDcsValues.sql"
87 guessed_pool_record =
"HcalDcsRcd"
89 elif guessed_type ==
"HcalChannelQuality":
90 guessed_type =
"ChannelQuality"
91 guessed_query_file_name = base_dir+
"/HcalChannelQuality.sql"
92 guessed_pool_record =
"HcalChannelQualityRcd"
94 elif guessed_type ==
"HcalLutMetadata":
95 guessed_type =
"LutMetadata"
96 guessed_query_file_name = base_dir+
"/HcalLutMetadata.sql"
97 guessed_pool_record =
"HcalLutMetadataRcd"
99 elif guessed_type ==
"HcalRespCorrs":
100 guessed_type =
"RespCorrs"
101 guessed_query_file_name = base_dir+
"/HcalRespCorrs.sql"
102 guessed_pool_record =
"HcalRespCorrsRcd"
104 elif guessed_type ==
"HcalValidationCorrs":
105 guessed_type =
"ValidationCorrs"
106 guessed_query_file_name = base_dir+
"/HcalValidationCorrs.sql"
107 guessed_pool_record =
"HcalValidationCorrsRcd"
109 elif guessed_type ==
"HcalPedestals":
110 guessed_type =
"Pedestals"
111 guessed_query_file_name = base_dir+
"/HcalPedestals.sql"
112 guessed_pool_record =
"HcalPedestalsRcd"
114 elif guessed_type ==
"HcalPedestalWidths":
115 guessed_type =
"PedestalWidths"
116 guessed_query_file_name = base_dir+
"/HcalPedestalWidths.sql"
117 guessed_pool_record =
"HcalPedestalWidthsRcd"
119 elif guessed_type ==
"HcalGains":
120 guessed_type =
"Gains"
121 guessed_query_file_name = base_dir+
"/HcalGains.sql"
122 guessed_pool_record =
"HcalGainsRcd"
124 elif guessed_type ==
"HcalGainWidths":
125 guessed_type =
"GainWidths"
126 guessed_query_file_name = base_dir+
"/HcalGainWidths.sql"
127 guessed_pool_record =
"HcalGainWidthsRcd"
129 elif guessed_type ==
"HcalQIEData":
130 guessed_type =
"QIEData"
131 guessed_query_file_name = base_dir+
"/HcalQieData.sql"
132 guessed_pool_record =
"HcalQIEDataRcd"
134 elif guessed_type ==
"HcalElectronicsMap":
135 guessed_type =
"ElectronicsMap"
136 guessed_query_file_name = base_dir+
"/HcalEmap.sql"
137 guessed_pool_record =
"HcalElectronicsMapRcd"
139 elif guessed_type ==
"HcalZSThresholds":
140 guessed_type =
"ZSThresholds"
141 guessed_query_file_name = base_dir+
"/HcalZSThresholds.sql"
142 guessed_pool_record =
"HcalZSThresholdsRcd"
144 elif guessed_type ==
"HcalL1TriggerObjects":
145 guessed_type =
"L1TriggerObjects"
146 guessed_query_file_name = base_dir+
"/HcalL1TriggerObjects.sql"
147 guessed_pool_record =
"HcalL1TriggerObjectsRcd"
150 print "Cannot guess condition type"
152 return {
'condition_type':guessed_type,
153 'query_file_name':guessed_query_file_name,
154 'pool_record':guessed_pool_record}
159 tag_list_file = open(tag_list_file_name)
161 print "Cannot open the file with the list of tags, exiting..."
164 for line
in tag_list_file:
166 tag_list_file.close()
171 def get_iovs(tag, input_pool_connect_string, mode):
175 if mode ==
"online" or mode ==
"online_dropbox":
177 iovs = subprocess.Popen([
"./xmlToolsRun",
"--list-iovs-for-o2o",
"--tag-name", tag,
"--pool-connect-string", input_pool_connect_string,
"--pool-auth-path", pool_auth_path], stdout=subprocess.PIPE).
communicate()[0]
178 iov_list = iovs.splitlines()
181 print "ERROR: Cannot get the IOV update list for tag", tag+
". This tag will not be updated. Now continue to the next tag..."
186 if mode ==
"offline_development":
189 iov_list_file = open(base_dir+
"/o2o/"+tag+
"_iov_to_update.devel")
191 print "ERROR: Cannot open file with the IOV list for tag", tag+
". This tag will not be updated. Now continue to the next tag..."
195 for line
in iov_list_file:
196 iov_list .
append(line.strip())
197 iov_list_file.close()
204 for line
in iov_list:
205 line_stripped = line.strip()
206 if line.strip()[0:13] ==
"O2O_IOV_LIST:":
207 iovs.append(line.lstrip(
"O2O_IOV_LIST:"))
208 if line_stripped[0:line_stripped.find(
":")] ==
"CONNECTION ERROR":
209 result =
"fail_connect"
210 if line_stripped[0:line_stripped.find(
":")] ==
"NEW_POOL_TAG_TRUE":
221 if mode ==
"online" or mode ==
"online_dropbox":
222 subprocess.call([
"cmsRun", str(python_popcon_file)])
224 print "In online mode would run Popcon now:",
"cmsRun", str(python_popcon_file)
227 print "Cannot execute cmsRun. Further processing of this tag is stopped, going to the next tag..."
230 print "Cannot execute cmsRun. Further processing of this tag is stopped, going to the next tag..."
236 if use_dropbox ==
"true" or use_dropbox ==
"True" or use_dropbox ==
"TRUE":
238 retcall_meta = subprocess.call([
'mv', str(output_dir)+
'/'+str(dropbox_file_name_prefix)+
'.txt', str(dropbox_dir)+
'/'])
239 retcall_sql = subprocess.call([
'mv', str(output_dir)+
'/'+str(dropbox_file_name_prefix)+
'.sql', str(dropbox_dir)+
'/'])
241 print "ERROR: Cannot copy files to the dropbox area"
243 return {
'status':status}
249 for tag_name
in tags:
251 tag = tag_name.strip()
257 condition_type = guessed_condition[
'condition_type']
258 query_file_name = guessed_condition[
'query_file_name']
259 pool_record = guessed_condition[
'pool_record']
262 print "Processing tag:", tag
263 print "Condition type:",condition_type
268 query_file = open(query_file_name,
"r")
269 query = query_file.read()
275 if use_dropbox ==
"true" or use_dropbox ==
"True" or use_dropbox ==
"TRUE":
277 dropbox_file_name_prefix = str(output_dir)+
"/"+str(tag)
278 output_pool_connect_string =
'sqlite_file:'+str(dropbox_file_name_prefix)+
'.db'
279 dropbox_txt_file_name = str(dropbox_file_name_prefix)+
".txt"
280 dropbox_txt_file = open(dropbox_txt_file_name,
"w")
281 dropbox_txt_file.write(
'destDB '+dropbox_destination_db+
'\n')
282 dropbox_txt_file.write(
'inputtag\n')
283 dropbox_txt_file.write(
'tag '+str(tag)+
'\n')
284 dropbox_txt_file.write(
'since\n')
285 dropbox_txt_file.write(
'till\n')
286 dropbox_txt_file.write(
'usertext '+str(dropbox_comment)+
'\n')
287 dropbox_txt_file.close()
293 gotten_iovs =
get_iovs(tag, input_pool_connect_string, mode)
296 if (gotten_iovs[
'result'] !=
"success"):
297 if (gotten_iovs[
'result'] ==
"fail_connect"):
298 print "Problems connecting to", input_pool_connect_string
299 print "Unable to process tag", tag_name,
"continuing to the next tag..."
302 o2o_iovs = gotten_iovs[
'iovs']
303 isnewtag = gotten_iovs[
'newtag']
305 for line
in o2o_iovs:
312 print "Creating a new offline tag: ", tag_name
313 if condition_type ==
"DcsValues" and iov != 1:
314 print "DCS values: The first IOV in the online tag is ", iov
315 print "DCS values: Adding default DCS set values to the offline"
316 print "DCS values: tag for IOVs 1 - ", iov-1
317 print "DCS values: because first IOV in the offline tag must always be 1."
319 query_file_name = query_file_name+
".default"
320 query_file = open(query_file_name,
"r")
321 query = query_file.read()
328 if run_result[
'status'] !=
"success":
335 if run_result[
'status'] !=
"success":
static void * communicate(void *obj)
def guess_condition_from_tag
def make_popcon_config_file