Functions | |
def | Func_CopyWBMInfo |
Func_CopyWBMInfo(str_name) | |
def | Func_FillInfoDBS |
Func_FillInfoDBS(str_dbsInstance) | |
def | Func_FillInfoHlt |
Func_FillInfoHlt() | |
def | Func_FillInfoMagnetHistory |
Func_FillInfoMagnetHistory() | |
def | Func_FillInfoRunRegistry |
Func_FillInfoRunRegistry() | |
def | Func_FillInfoRunSummary |
Func_FillInfoRunSummary() | |
def | Func_GetHtmlTags |
FUNCTIONS. | |
def | Func_GetHtmlTagValue |
Func_GetHtmlTagValue(str_tag, str_text) | |
def | Func_GetHtmlTagValueAttr |
Func_GetHtmlTagValueAttr(str_tag, str_text) | |
def | Func_GetHtmlTagValues |
Func_GetHtmlTagValues(str_text) | |
def | Func_GetWBMInfo |
Func_GetWBMInfo(str_name, str_path) | |
def | Func_MakeShellWord |
Func_MakeShellWord(str_python) | |
Variables | |
bool_hlt = False | |
tuple | bool_runRegistry = Func_FillInfoRunRegistry() |
dictionary | Dict_dbsDatasets = {} |
dictionary | DICT_keysRunSummary = {} |
dictionary | DICT_keysRunSummaryTrigger = {} |
dictionary | Dict_maxLenDbsDatasets = {} |
dictionary | Dict_runRegistry = {} |
dictionary | DICT_tagsRunRegistry = {} |
dictionary | Dict_wbmRunSummary = {} |
dictionary | DictDict_dbsDatasets = {} |
dictionary | DictDict_dbsEvents = {} |
float | Float_magneticField = 999.0 |
tuple | int_length = len(str_print) |
int | INT_offset = 8 |
list | LSTR_dbsInstances |
list | Lstr_hltPaths = [] |
string | STR_headDatasets = 'datasets' |
string | STR_headFiles = 'available data files' |
string | STR_htlConfig = 'HLT Config ID' |
string | STR_p5 = 'cmsusr0.cern.ch' |
tuple | Str_passwd = getpass.getpass('> getRunInfo.py > '+Str_userID+'@'+STR_p5+'\'s password: ') |
string | str_print = '> getRunInfo.py > ' |
list | Str_run = sys.argv[1] |
string | STR_runEnd = 'STOP_TIME' |
string | STR_runStart = 'START_TIME' |
string | STR_SiStrip = 'SIST' |
tuple | Str_userID = getpass.getuser() |
MAIN PROGRAM. | |
string | STR_wwwDBSData = 'dbs_discovery/getData' |
string | STR_wwwWBM = 'https://cmswbm/cmsdb/servlet' |
tuple | TD_shiftUTC = datetime.timedelta(hours = 2) |
def getRunInfo::Func_CopyWBMInfo | ( | str_name | ) |
Func_CopyWBMInfo(str_name)
Logs in on cmsusr0 and copies file from there
Func_CopyWBMInfo(str_name) Logs in on cmsusr0 and copies file from there
Definition at line 199 of file getRunInfo.py.
00200 : 00201 """ Func_CopyWBMInfo(str_name) 00202 Logs in on cmsusr0 and copies file from there 00203 """ 00204 pid, fd = os.forkpty() 00205 if pid == 0: 00206 os.execv('/usr/bin/scp', ['/usr/bin/scp', Str_userID+'@'+STR_p5+':~/'+str_name, '.']) 00207 else: 00208 time.sleep(1) 00209 os.read(fd, 1000) 00210 time.sleep(1) 00211 os.write(fd, Str_passwd) 00212 time.sleep(1) 00213 c = 0 00214 s = os.read(fd, 1) 00215 while s: 00216 c += 1 00217 s = os.read(fd, 1) 00218 if c >= 163: 00219 break
def getRunInfo::Func_FillInfoDBS | ( | str_dbsInstance | ) |
Func_FillInfoDBS(str_dbsInstance)
Retrieves run info from DBS and fills it into containers
Func_FillInfoDBS(str_dbsInstance) Retrieves run info from DBS and fills it into containers
Definition at line 344 of file getRunInfo.py.
00345 : 00346 """ Func_FillInfoDBS(str_dbsInstance) 00347 Retrieves run info from DBS and fills it into containers 00348 """ 00349 str_dbsRuns = urllib.urlencode({'ajax':'0', '_idx':'0', 'pagerStep':'0', 'userMode':'user', 'release':'Any', 'tier':'Any', 'dbsInst':str_dbsInstance, 'primType':'Any', 'primD':'Any', 'minRun':Str_run, 'maxRun':Str_run}) 00350 file_dbsRuns = urllib.urlopen("https://cmsweb.cern.ch/dbs_discovery/getRunsFromRange", str_dbsRuns) 00351 lstr_dbsRuns = [] 00352 lstr_dbsDatasets = [] 00353 dict_dbsDatasets = {} 00354 dict_dbsEvents = {} 00355 for str_dbsRuns in file_dbsRuns.readlines(): 00356 lstr_dbsRuns.append(str_dbsRuns) 00357 if str_dbsRuns.find(STR_wwwDBSData) >= 0: 00358 if str_dbsRuns.split('&proc=')[1].find('&') >= 0: 00359 lstr_dbsDatasets.append(str_dbsRuns.split('&proc=')[1].split('&')[0]) 00360 else: 00361 lstr_dbsDatasets.append(str_dbsRuns.split('&proc=')[1]) 00362 int_maxLenDbsDatasets = 0 00363 for str_dbsDataset in lstr_dbsDatasets: 00364 str_dbsLFN = urllib.urlencode({'dbsInst':str_dbsInstance, 'blockName':'*', 'dataset':str_dbsDataset, 'userMode':'user', 'run':Str_run}) 00365 file_dbsLFN = urllib.urlopen("https://cmsweb.cern.ch/dbs_discovery/getLFNlist", str_dbsLFN) 00366 lstr_dbsLFN = [] 00367 int_events = 0 00368 for str_dbsLFN in file_dbsLFN.readlines(): 00369 lstr_dbsLFN.append(str_dbsLFN) 00370 if str_dbsLFN.find('contians') >= 0 and str_dbsLFN.find('file(s)'): # FIXME: be careful, this typo might be corrected sometimes on the web page... 00371 dict_dbsDatasets[str_dbsDataset] = str_dbsLFN.split()[1] 00372 if str_dbsLFN.startswith('/store/data/'): 00373 int_events += int(Func_GetHtmlTagValue('td' ,lstr_dbsLFN[len(lstr_dbsLFN)-4])) 00374 dict_dbsEvents[str_dbsDataset] = str(int_events) 00375 if len(str_dbsDataset) > int_maxLenDbsDatasets: 00376 int_maxLenDbsDatasets = len(str_dbsDataset) 00377 DictDict_dbsDatasets[str_dbsInstance] = dict_dbsDatasets 00378 DictDict_dbsEvents[str_dbsInstance] = dict_dbsEvents 00379 Dict_dbsDatasets[str_dbsInstance] = lstr_dbsDatasets 00380 Dict_maxLenDbsDatasets[str_dbsInstance] = int_maxLenDbsDatasets
def getRunInfo::Func_FillInfoHlt | ( | ) |
Retrieves run info from Hlt and fills it into containers
Func_FillInfoHlt(): Retrieves run info from Hlt and fills it into containers
Definition at line 320 of file getRunInfo.py.
00321 : 00322 """ Func_FillInfoHlt(): 00323 Retrieves run info from Hlt and fills it into containers 00324 """ 00325 str_nameHlt = 'HLTConfiguration?KEY=' + Dict_wbmRunSummary[STR_htlConfig] 00326 Func_GetWBMInfo(str_nameHlt, STR_wwwWBM) 00327 Func_CopyWBMInfo(Func_MakeShellWord(str_nameHlt)) 00328 file_wbmHlt = file(str_nameHlt, 'r') 00329 bool_foundPaths = False 00330 bool_foundPath = False 00331 for str_wbmHlt in file_wbmHlt.readlines(): 00332 if str_wbmHlt.find('<H3>Paths</H3>') >= 0: 00333 bool_foundPaths = True 00334 if bool_foundPaths and str_wbmHlt.find('<HR><H3>') >= 0: 00335 bool_foundPaths = False 00336 if bool_foundPaths and str_wbmHlt.startswith('<TR><TD ALIGN=RIGHT>'): 00337 Lstr_hltPaths.append(str_wbmHlt.split('</TD>')[1].split('<TD>')[-1]) 00338 file_wbmHlt.close() 00339 os.remove(str_nameHlt) 00340 return (len(Lstr_hltPaths)>0)
def getRunInfo::Func_FillInfoMagnetHistory | ( | str_timeStart, | |
str_timeEnd | |||
) |
Retrieves run info from MagnetHistory and fills it into containers
Func_FillInfoMagnetHistory(): Retrieves run info from MagnetHistory and fills it into containers
Definition at line 301 of file getRunInfo.py.
00302 : 00303 """ Func_FillInfoMagnetHistory(): 00304 Retrieves run info from MagnetHistory and fills it into containers 00305 """ 00306 str_nameMagnetHistory = 'MagnetHistory?TIME_BEGIN=' + str_timeStart + '&TIME_END=' + str_timeEnd 00307 Func_GetWBMInfo(str_nameMagnetHistory, STR_wwwWBM) 00308 Func_CopyWBMInfo(Func_MakeShellWord(str_nameMagnetHistory)) 00309 file_wbmMagnetHistory = file(str_nameMagnetHistory, 'r') 00310 float_avMagMeasure = Float_magneticField 00311 for str_wbmMagnetHistory in file_wbmMagnetHistory.readlines(): 00312 if str_wbmMagnetHistory.find('BFIELD, Tesla') >= 0: 00313 float_avMagMeasure = float(str_wbmMagnetHistory.split('</A>')[0].split('>')[-1]) 00314 file_wbmMagnetHistory.close() 00315 os.remove(str_nameMagnetHistory) 00316 return float_avMagMeasure
def getRunInfo::Func_FillInfoRunRegistry | ( | ) |
Retrieves run info from RunRegistry and fills it into containers
Func_FillInfoRunRegistry(): Retrieves run info from RunRegistry and fills it into containers
Definition at line 223 of file getRunInfo.py.
00224 : 00225 """ Func_FillInfoRunRegistry(): 00226 Retrieves run info from RunRegistry and fills it into containers 00227 """ 00228 str_runRegistry = urllib.urlencode({'format':'xml', 'intpl':'xml', 'qtype':'RUN_NUMBER', 'sortname':'RUN_NUMBER'}) 00229 file_runRegistry = urllib.urlopen("https://pccmsdqm04.cern.ch/runregistry/runregisterdata", str_runRegistry) 00230 str_runRegistryLong = '' 00231 for str_runRegistry in file_runRegistry.readlines(): 00232 str_runRegistryLong += str_runRegistry.splitlines()[0] 00233 bool_foundRun = False 00234 str_runRunRegistry = '' 00235 for int_runIndex in range(1,int(str_runRegistryLong.split('<RUNS')[1].split('>')[0].split('total=\"')[1].split('\"')[0])): 00236 str_runRunRegistry = Func_GetHtmlTagValue('RUN', str_runRegistryLong, int_runIndex) 00237 if Func_GetHtmlTagValue('NUMBER', str_runRunRegistry) == Str_run: 00238 bool_foundRun = True 00239 break 00240 if not bool_foundRun: 00241 print '> getRunInfo.py > run %s not found in run registry' %(Str_run) 00242 return False 00243 dict_tagsRunRegistry = Func_GetHtmlTags(str_runRunRegistry) 00244 for str_tagRunRegistry in dict_tagsRunRegistry.keys(): 00245 if dict_tagsRunRegistry[str_tagRunRegistry] == False: 00246 Dict_runRegistry[str_tagRunRegistry] = Func_GetHtmlTagValue(str_tagRunRegistry, str_runRunRegistry) 00247 if Dict_runRegistry['SUBSYSTEMS'].find(STR_SiStrip) < 0: 00248 print '> getRunInfo.py > SiStrip was not in this run' 00249 return False 00250 return True
def getRunInfo::Func_FillInfoRunSummary | ( | ) |
Retrieves run info from RunSummary and fills it into containers
Func_FillInfoRunSummary(): Retrieves run info from RunSummary and fills it into containers
Definition at line 254 of file getRunInfo.py.
00255 : 00256 """ Func_FillInfoRunSummary(): 00257 Retrieves run info from RunSummary and fills it into containers 00258 """ 00259 str_nameRunSummary = 'RunSummary?RUN=' + Str_run 00260 Func_GetWBMInfo(str_nameRunSummary, STR_wwwWBM) 00261 Func_CopyWBMInfo(Func_MakeShellWord(str_nameRunSummary)) 00262 file_wbmRunSummary = file(str_nameRunSummary, 'r') 00263 bool_table = False 00264 int_tableHeader = 0 00265 int_tableItem = 0 00266 int_startItem = 0 00267 int_endItem = 0 00268 for str_wbmRunSummary in file_wbmRunSummary.readlines(): 00269 if str_wbmRunSummary.find('<TABLE CLASS="params"><THEAD><TR>') >= 0: 00270 bool_table = True 00271 if str_wbmRunSummary.find('</TBODY></TABLE>') >= 0: 00272 bool_table = False 00273 if bool_table: 00274 if str_wbmRunSummary.startswith('<TH>'): 00275 int_tableHeader += 1 00276 if str_wbmRunSummary.find(STR_runStart) >= 0: 00277 int_startItem = int_tableHeader 00278 if str_wbmRunSummary.find(STR_runEnd) >= 0: 00279 int_endItem = int_tableHeader 00280 if str_wbmRunSummary.startswith('<TD'): 00281 int_tableItem += 1 00282 if int_tableItem == int_startItem: 00283 Dict_wbmRunSummary[STR_runStart] = str_wbmRunSummary.split(' </TD>')[0].split('<TD>')[-1] 00284 if int_tableItem == int_endItem: 00285 Dict_wbmRunSummary[STR_runEnd] = str_wbmRunSummary.split(' </TD>')[0].split('<TD>')[-1] 00286 continue 00287 for str_keyRunSummary in DICT_keysRunSummary.keys(): 00288 if str_wbmRunSummary.find(str_keyRunSummary) >= 0: 00289 Dict_wbmRunSummary[str_keyRunSummary] = str_wbmRunSummary.split('</TD></TR>')[0].split('>')[-1] 00290 break 00291 for str_summaryKeysTrigger in DICT_keysRunSummaryTrigger.keys(): 00292 if str_wbmRunSummary.find(str_summaryKeysTrigger) >= 0: 00293 Dict_wbmRunSummary[str_summaryKeysTrigger] = str_wbmRunSummary.split('</A></TD></TR>')[0].split('>')[-1] 00294 if str_summaryKeysTrigger == 'HLT Key': 00295 Dict_wbmRunSummary[STR_htlConfig] = str_wbmRunSummary.split('HLTConfiguration?KEY=')[1].split('>')[0] 00296 file_wbmRunSummary.close() 00297 os.remove(str_nameRunSummary)
def getRunInfo::Func_GetHtmlTags | ( | str_text | ) |
FUNCTIONS.
Func_GetHtmlTags(str_text)
Gets HTML tags from a string
Func_GetHtmlTags(str_text): Gets HTML tags from a string
Definition at line 109 of file getRunInfo.py.
00110 : 00111 """ Func_GetHtmlTags(str_text): 00112 Gets HTML tags from a string 00113 """ 00114 dict_tags = {} 00115 # first look for tags w/ values 00116 lstr_split = str_text.split('</') 00117 for str_split in lstr_split[1:]: 00118 str_key = str_split.split('>')[0] 00119 dict_tags[str_key] = str_key in dict_tags 00120 # second look for tags w/o values 00121 lstr_split = str_text.split('/>') 00122 for str_split in lstr_split[:-1]: 00123 str_key = str_split.split('<')[-1].split()[0] 00124 dict_tags[str_key] = str_key in dict_tags 00125 return dict_tags
def getRunInfo::Func_GetHtmlTagValue | ( | str_tag, | |
str_text, | |||
int_index = 1 |
|||
) |
Func_GetHtmlTagValue(str_tag, str_text)
Gets the value of the n-th oocurence a given HTML tag from a string
Func_GetHtmlTagValue(str_tag, str_text): Gets the value of the n-th oocurence a given HTML tag from a string
Definition at line 129 of file getRunInfo.py.
00130 : 00131 """ Func_GetHtmlTagValue(str_tag, str_text): 00132 Gets the value of the n-th oocurence a given HTML tag from a string 00133 """ 00134 if int_index > str_text.count('<'+str_tag): 00135 return '' 00136 str_1 = str_text.split('<'+str_tag)[int_index] 00137 if str_1[0] != '>': 00138 if str_1.split('>')[0][-1] == '/': 00139 return '' 00140 return str_1.split('>',1)[1].split('</'+str_tag+'>')[0]
def getRunInfo::Func_GetHtmlTagValueAttr | ( | str_value, | |
str_text | |||
) |
Func_GetHtmlTagValueAttr(str_tag, str_text)
Gets the (last) attribute of a given HTML tag value from a string
Func_GetHtmlTagValueAttr(str_value, str_text): Gets the (last) attributes of a given HTML tag value from a string
Definition at line 157 of file getRunInfo.py.
def getRunInfo::Func_GetHtmlTagValues | ( | str_text | ) |
Func_GetHtmlTagValues(str_text)
Gets HTML tag values from a string
Func_GetHtmlTagValues(str_text): Gets HTML tag values from a string
Definition at line 144 of file getRunInfo.py.
def getRunInfo::Func_GetWBMInfo | ( | str_name, | |
str_path | |||
) |
Func_GetWBMInfo(str_name, str_path)
Logs in on cmsusr0, retrieves WBM information and stores it locally
Func_GetWBMInfo(str_name, str_path) Logs in on cmsusr0, retrieves WBM information and stores it locally
Definition at line 175 of file getRunInfo.py.
00176 : 00177 """ Func_GetWBMInfo(str_name, str_path) 00178 Logs in on cmsusr0, retrieves WBM information and stores it locally 00179 """ 00180 pid, fd = os.forkpty() 00181 if pid == 0: 00182 os.execv('/usr/bin/ssh', ['/usr/bin/ssh', '-l', Str_userID, STR_p5] + ['rm', '-f', '\"'+str_name + '\" && ' + 'wget', '\"'+str_path+'/'+str_name+'\"']) 00183 else: 00184 time.sleep(1) 00185 os.read(fd, 1000) 00186 time.sleep(1) 00187 os.write(fd, Str_passwd) 00188 time.sleep(1) 00189 c = 0 00190 s = os.read(fd, 1) 00191 while s: 00192 c += 1 00193 s = os.read(fd, 1) 00194 if c >= 2: 00195 break
def getRunInfo::Func_MakeShellWord | ( | str_python | ) |
Func_MakeShellWord(str_python)
Adds shell escape charakters to Python strings
Func_MakeShellWord(str_python) Adds shell escape charakters to Python strings
Definition at line 166 of file getRunInfo.py.
tuple getRunInfo::bool_hlt = False |
Definition at line 437 of file getRunInfo.py.
tuple getRunInfo::bool_runRegistry = Func_FillInfoRunRegistry() |
Definition at line 394 of file getRunInfo.py.
dictionary getRunInfo::Dict_dbsDatasets = {} |
Definition at line 101 of file getRunInfo.py.
dictionary getRunInfo::DICT_keysRunSummary = {} |
Definition at line 60 of file getRunInfo.py.
dictionary getRunInfo::DICT_keysRunSummaryTrigger = {} |
Definition at line 75 of file getRunInfo.py.
dictionary getRunInfo::Dict_maxLenDbsDatasets = {} |
Definition at line 102 of file getRunInfo.py.
dictionary getRunInfo::Dict_runRegistry = {} |
Definition at line 95 of file getRunInfo.py.
dictionary getRunInfo::DICT_tagsRunRegistry = {} |
Definition at line 36 of file getRunInfo.py.
dictionary getRunInfo::Dict_wbmRunSummary = {} |
Definition at line 97 of file getRunInfo.py.
dictionary getRunInfo::DictDict_dbsDatasets = {} |
Definition at line 99 of file getRunInfo.py.
dictionary getRunInfo::DictDict_dbsEvents = {} |
Definition at line 100 of file getRunInfo.py.
tuple getRunInfo::Float_magneticField = 999.0 |
Definition at line 96 of file getRunInfo.py.
tuple getRunInfo::int_length = len(str_print) |
Definition at line 475 of file getRunInfo.py.
int getRunInfo::INT_offset = 8 |
Definition at line 26 of file getRunInfo.py.
00001 ['cms_dbs_caf_analysis_01', 00002 'cms_dbs_prod_global' ]
Definition at line 32 of file getRunInfo.py.
list getRunInfo::Lstr_hltPaths = [] |
Definition at line 98 of file getRunInfo.py.
string getRunInfo::STR_headDatasets = 'datasets' |
Definition at line 34 of file getRunInfo.py.
string getRunInfo::STR_headFiles = 'available data files' |
Definition at line 35 of file getRunInfo.py.
string getRunInfo::STR_htlConfig = 'HLT Config ID' |
Definition at line 57 of file getRunInfo.py.
string getRunInfo::STR_p5 = 'cmsusr0.cern.ch' |
Definition at line 28 of file getRunInfo.py.
tuple getRunInfo::Str_passwd = getpass.getpass('> getRunInfo.py > '+Str_userID+'@'+STR_p5+'\'s password: ') |
Definition at line 390 of file getRunInfo.py.
string getRunInfo::str_print = '> getRunInfo.py > ' |
Definition at line 471 of file getRunInfo.py.
list getRunInfo::Str_run = sys.argv[1] |
Definition at line 94 of file getRunInfo.py.
string getRunInfo::STR_runEnd = 'STOP_TIME' |
Definition at line 59 of file getRunInfo.py.
string getRunInfo::STR_runStart = 'START_TIME' |
Definition at line 58 of file getRunInfo.py.
string getRunInfo::STR_SiStrip = 'SIST' |
Definition at line 30 of file getRunInfo.py.
tuple getRunInfo::Str_userID = getpass.getuser() |
MAIN PROGRAM.
Definition at line 389 of file getRunInfo.py.
string getRunInfo::STR_wwwDBSData = 'dbs_discovery/getData' |
Definition at line 31 of file getRunInfo.py.
string getRunInfo::STR_wwwWBM = 'https://cmswbm/cmsdb/servlet' |
Definition at line 29 of file getRunInfo.py.
tuple getRunInfo::TD_shiftUTC = datetime.timedelta(hours = 2) |
Definition at line 25 of file getRunInfo.py.