ATLAS Offline Software
jo_proxy.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 # Helper functions for setting up a job options proxy
4 import os,shutil
5 
7  return [name for name in os.listdir(a_dir)
8  if os.path.isdir(os.path.join(a_dir, name))]
9 
10 def mk_jo_proxy(targetbasepath, pkgname, proxypath, addtosearch=True):
11  "Make a JO proxy dir such that the MCxxJobOptions/dddd dirs contents are found via include(MCxxJobOptions/yyyy)"
12  if proxypath:
13  if os.path.exists(proxypath):
14  shutil.rmtree(proxypath)
15  os.mkdir(proxypath)
16  os.environ['LOCAL_INSTALL_DIR'] = (os.environ['JOBOPTSEARCHPATH']).split(":")[0]
17  os.environ['LOCAL_DATA_DIR'] = (os.environ['DATAPATH']).split(":")[0]
18 
19  dirlist = get_immediate_subdirectories(targetbasepath)
20  subdirlist=dirlist
21  for dd in (dirlist):
22  if (('.svn' not in dd) and ('cmt' not in dd) and ('_joproxy' not in dd)):
23  deepdir = os.path.join(targetbasepath, dd)
24  subdirlist1 = get_immediate_subdirectories(deepdir)
25  subdirlist = subdirlist+["%s" % dd+"/%s" % item for item in subdirlist1]
26  for d in (subdirlist):
27  # TODO: we could _maybe_ add the appropriate share/DSIDxxxx/ dir to the path based on the jobConfig arg... too much magic?
28  if (('.svn' not in d) and ('cmt' not in d) and ('_joproxy' not in d) and ('share/' not in d)):
29  dpath = os.path.join(proxypath, d)
30  if proxypath:
31  os.mkdir(dpath)
32 
33  if ('nonStandard' in dpath):
34  dpath_ex = os.path.join(dpath,pkgname)
35  if proxypath:
36  os.mkdir(dpath_ex)
37 
38  os.symlink(os.path.join(targetbasepath, d), os.path.join(dpath_ex, "nonStandard"))
39  else :
40  os.symlink(os.path.join(targetbasepath, d), os.path.join(dpath, pkgname))
41  if addtosearch:
42  os.environ["JOBOPTSEARCHPATH"] = dpath+":"+os.environ["JOBOPTSEARCHPATH"]
43  os.environ["DATAPATH"] =os.path.join(targetbasepath, d)+":"+os.environ["DATAPATH"]
44 
45  os.environ["JOBOPTSEARCHPATH"] = os.environ['LOCAL_INSTALL_DIR']+":"+os.environ["JOBOPTSEARCHPATH"]
46  os.environ["DATAPATH"] = os.environ['LOCAL_DATA_DIR']+":"+os.environ["DATAPATH"]
python.jo_proxy.get_immediate_subdirectories
def get_immediate_subdirectories(a_dir)
Definition: jo_proxy.py:6
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.jo_proxy.mk_jo_proxy
def mk_jo_proxy(targetbasepath, pkgname, proxypath, addtosearch=True)
Definition: jo_proxy.py:10