ATLAS Offline Software
readGridFiles.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2 
3 # file to parse log files from grid for rate compilation
4 # grid outputs logs as tarballs (.tgz)
5 # instructions in compileRPVLLRates.p
6 # receives two arguments: output file + input directory containing log files to be parsed
7 
8 from os import listdir
9 from os.path import isfile, join, isdir
10 import re
11 import sys
12 import tarfile
13 import os
14 
15 text_file = open(sys.argv[1], "w")
16 mypath = sys.argv[2]
17 # get list of grid log tgz tarballs w/in directory
18 tgzs = [t for t in listdir(mypath) if isfile(join(mypath, t))]
19 # cd into directory containing tarballs
20 os.chdir(mypath)
21 
22 # loop through tarballs and untar
23 print('About to loop through tarballs!')
24 for t in tgzs:
25  tar = tarfile.open(t, "r:gz")
26  tar.extractall()
27  tar.close()
28 
29 # get list of untarred tarballs
30 tarballs = [x for x in listdir(os.getcwd()) if isdir(x)]
31 # loop through untarred tarballs + cd into them
32 for x in tarballs:
33  # loop through files in tarballs
34  files = [f for f in listdir(x)]
35  for f in files:
36  # open log.RAWtoALL + extract filter info
37  if "log.RAWtoALL" in f:
38  openFile = open(x+'/'+f)
39  for line in openFile:
40  # find RPVLL filter information
41  if re.match('.*RPVLL.*Events',line) or re.match('.*BSESOutputSvcStreamDRAW_RPVLL.*events',line):
42  # write input data file + RPVLL info to output file
43  text_file.write(data_file + ':' + line)
44 # close output text file
45 text_file.close()
python.dummyaccess.listdir
def listdir(dirname)
Definition: dummyaccess.py:6
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
Trk::open
@ open
Definition: BinningType.h:40
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28