 |
ATLAS Offline Software
|
|
| StorageManager = namedtuple('StorageManager', ['name', 'prefix', 'cp', 'ls', 'longls']) |
|
| CastorMgr = StorageManager(name='castor', prefix='root://castoratlas/', cp='xrdcp', ls='nsls %s', longls='nsls -l %s') |
|
| RFIOMgr = StorageManager(name='rfio', prefix='rfio:', cp='rfcp', ls='rfdir %s', longls='rfdir %s') |
|
| EOSMgr = StorageManager(name='eos', prefix='root://eosatlas.cern.ch/', cp='xrdcp', ls='/bin/sh -l -c "LD_LIBRARY_PATH=/usr/lib64/ eos ls %s"', longls='/bin/sh -l -c "LD_LIBRARY_PATH=/usr/lib64/ eos ls -l %s"') |
|
| UnixMgr = StorageManager(name='unix', prefix='', cp='cp', ls='ls %s', longls='ls -l %s') |
|
◆ _rationalise()
def python.DiskUtils._rationalise |
( |
|
path | ) |
|
|
private |
Rationalise a path, removing prefix and esuring single leading slash
Definition at line 34 of file DiskUtils.py.
36 Rationalise a path, removing prefix and esuring single leading slash
38 for p
in (
'root://castoratlas/',
'root://eosatlas.cern.ch/',
'rfio:',
'castor:'):
39 if path.startswith(p):
41 if path.startswith(
'//'):
43 if not path.startswith(
'/'):
49 @
deprecated(
"EOS is mounted on /eos with fuse, so you probably don't need this abstraction")
◆ cp()
def python.DiskUtils.cp |
( |
|
src, |
|
|
|
dest = '.' |
|
) |
| |
Definition at line 127 of file DiskUtils.py.
127 def cp(src, dest='.'):
134 if srcmgr.cp ==
'xrdcp' or destmgr.cp ==
'xrdcp': cp =
'xrdcp'
136 return os.system(
'%s %s%s %s%s' %(cp, srcmgr.prefix, src, destmgr.prefix, dest))
◆ deprecated()
def python.DiskUtils.deprecated |
( |
|
message | ) |
|
Definition at line 13 of file DiskUtils.py.
16 def wrapper(*args, **kwargs):
17 print(
'WARNING: [InDetBeamSpotExample.DiskUtils]',
18 '{}() is deprecated and will be removed'.
format( fn.__name__),
20 print(
'WARNING: ', message,
22 return fn(*args, **kwargs)
◆ filelist()
def python.DiskUtils.filelist |
( |
|
files, |
|
|
|
prefix = None |
|
) |
| |
lists CASTOR/EOS name server directory/file entries.
If path is a directory, filelist lists the entries in the directory;
they are sorted alphabetically.
`files` specifies the CASTOR/EOS pathname.
`prefix` specifies the prefix one wants to prepend to the path found.
(e.g. prefix='root://castoratlas/' or 'root://eosatlas.cern.ch//')
if prefix=True it will determin the prefix based on the pathname
ex:
filelist('/castor/cern.ch/atlas/*')
filelist('/castor/cern.ch/atl*/foo?[bar]/*.pool.root.?')
filelist('/eos/atlas/*', prefix='root://eosatlas.cern.ch/')
filelist('/castor/cern.ch/atlas/*', prefix=True)
Definition at line 63 of file DiskUtils.py.
65 lists CASTOR/EOS name server directory/file entries.
66 If path is a directory, filelist lists the entries in the directory;
67 they are sorted alphabetically.
69 `files` specifies the CASTOR/EOS pathname.
70 `prefix` specifies the prefix one wants to prepend to the path found.
71 (e.g. prefix='root://castoratlas/' or 'root://eosatlas.cern.ch//')
72 if prefix=True it will determin the prefix based on the pathname
75 filelist('/castor/cern.ch/atlas/*')
76 filelist('/castor/cern.ch/atl*/foo?[bar]/*.pool.root.?')
77 filelist('/eos/atlas/*', prefix='root://eosatlas.cern.ch/')
78 filelist('/castor/cern.ch/atlas/*', prefix=True)
81 path, fname = os.path.split(files)
84 if ( path.count(
'*') > 0
or path.count(
'?') > 0
or
85 path.count(
'[') > 0
or path.count(
']') > 0 ) :
87 return sum([
ls(os.path.join(p,fname))
93 flist = subprocess.check_output(mgr.ls % path, shell=
True).
split()
94 except subprocess.CalledProcessError
as err:
98 if not (os.path.basename(files)
in [
'',
'*']):
99 pattern = fnmatch.translate(os.path.basename(files))
100 flist =
filter(
lambda x: re.search(pattern, x), flist)
103 if isinstance(prefix, str):
104 return [os.path.join(prefix+path, p)
for p
in flist]
106 return [os.path.join(mgr.prefix+path, p)
for p
in flist]
108 return [os.path.join(path, p)
for p
in flist]
110 @
deprecated(
"EOS is mounted on /eos with fuse, so you probably don't need this abstraction")
◆ get_lumi_blocks()
def python.DiskUtils.get_lumi_blocks |
( |
|
root_file | ) |
|
Definition at line 142 of file DiskUtils.py.
145 from PyUtils.MetaReader
import read_metadata
148 return( md[root_file][
'lumiBlockNumbers'] )
149 except Exception
as e:
150 print(
"Failed to read MetaData will fall back to looping ",
repr(e))
153 from PyUtils.RootUtils
import import_root
155 f = root.TFile.Open(root_file,
'READ')
157 metadata= f.Get(
'CollectionMetadata')
if f
else None
161 key_name =
str(ctypes.c_char_p(metadata.Key).value)
162 assert key_name ==
'POOLCollectionID'
164 coll_tree = f.Get(
'POOLCollectionTree')
if f
else None
166 evtmax = coll_tree.GetEntries()
167 if evtmax
in (-1,
None):
170 for row
in range(evtmax):
171 if coll_tree.GetEntry(row) < 0:
173 lbn = coll_tree.LumiBlockN
176 return list( lumiblocks )
◆ ls()
def python.DiskUtils.ls |
( |
|
path, |
|
|
|
longls = False |
|
) |
| |
Simple list of files
`longls` specifies long listing format
Definition at line 111 of file DiskUtils.py.
111 def ls(path, longls=False):
115 `longls` specifies long listing format
122 return subprocess.check_output(mgr.longls % path, shell=
True)
124 return subprocess.check_output(mgr.ls % path, shell=
True)
126 @
deprecated(
"EOS is mounted on /eos with fuse, so you probably don't need this abstraction")
◆ make_lumi_block_map_file()
def python.DiskUtils.make_lumi_block_map_file |
( |
|
file_set, |
|
|
|
path |
|
) |
| |
Definition at line 180 of file DiskUtils.py.
181 with open(path,
'w')
as mapfile:
182 for f, lbs
in file_set.with_lumi_blocks():
184 mapfile.write(
'{} {}\n'.
format(
186 ','.
join(
str(x)
for x
in lbs)))
◆ storageManager()
def python.DiskUtils.storageManager |
( |
|
name | ) |
|
Return SotrageManager to deal with listing, copying and reading files from various storage systems
Definition at line 50 of file DiskUtils.py.
52 Return SotrageManager to deal with listing, copying and reading files from various storage systems
55 if name.startswith(
'/castor/'):
57 elif name.startswith(
'/eos/'):
62 @
deprecated(
"DiskUtils.FileSet replaces this functionality")
◆ CastorMgr
python.DiskUtils.CastorMgr = StorageManager(name='castor', prefix='root://castoratlas/', cp='xrdcp', ls='nsls %s', longls='nsls -l %s') |
◆ EOSMgr
python.DiskUtils.EOSMgr = StorageManager(name='eos', prefix='root://eosatlas.cern.ch/', cp='xrdcp', ls='/bin/sh -l -c "LD_LIBRARY_PATH=/usr/lib64/ eos ls %s"', longls='/bin/sh -l -c "LD_LIBRARY_PATH=/usr/lib64/ eos ls -l %s"') |
◆ RFIOMgr
python.DiskUtils.RFIOMgr = StorageManager(name='rfio', prefix='rfio:', cp='rfcp', ls='rfdir %s', longls='rfdir %s') |
◆ StorageManager
python.DiskUtils.StorageManager = namedtuple('StorageManager', ['name', 'prefix', 'cp', 'ls', 'longls']) |
◆ UnixMgr
def import_root(batch=True)
functions --------------------------------------------------------------—
std::string repr(PyObject *o)
returns the string representation of a python object equivalent of calling repr(o) in python
def get_lumi_blocks(root_file)
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
def filelist(files, prefix=None)
void print(char *figname, TCanvas *c1)
std::string join(const std::vector< std::string > &v, const char c=',')
def ls(path, longls=False)
def make_lumi_block_map_file(file_set, path)