Skip to content

Commit 94fa8d3

Browse files
authored
Fixing LHCb init code (#826)
* Fixing LHCb init code
1 parent d5e82da commit 94fa8d3

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

python/GangaLHCb/__init__.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,22 @@ def _store_dirac_environment():
6868
fdir = os.path.join(os.path.expanduser("~/.cache/Ganga/GangaLHCb"), platform)
6969
fname = os.path.join(fdir, diracversion)
7070
if not os.path.exists(fname) or not os.path.getsize(fname):
71-
cmd = 'lb-run LHCBDIRAC {version} python -c "import os; print(dict(os.environ))"'.format(version=diracversion)
72-
env = execute(cmd)
73-
try:
74-
env = eval(env)
75-
except SyntaxError:
76-
logger.error("LHCbDirac version {version} does not exist".format(version=diracversion))
77-
raise OptionValueError("LHCbDirac version {version} does not exist".format(version=diracversion))
78-
try:
79-
write_env_cache(env, fname)
80-
logger.info("Storing new LHCbDirac environment (%s:%s)" % (str(diracversion), str(platform)))
81-
except (OSError, IOError, TypeError):
82-
logger.error("Unable to store LHCbDirac environment")
83-
raise
71+
cmd = 'lb-run LHCBDIRAC {version} python -c "import os; print(dict(os.environ))"'.format(version=diracversion)
72+
env = execute(cmd)
73+
if isinstance(env, str):
74+
try:
75+
env_temp = eval(env)
76+
env = env_temp
77+
78+
except SyntaxError:
79+
logger.error("LHCbDirac version {version} does not exist".format(version=diracversion))
80+
raise OptionValueError("LHCbDirac version {version} does not exist".format(version=diracversion))
81+
try:
82+
write_env_cache(env, fname)
83+
logger.info("Storing new LHCbDirac environment (%s:%s)" % (str(diracversion), str(platform)))
84+
except (OSError, IOError, TypeError):
85+
logger.error("Unable to store LHCbDirac environment")
86+
raise
8487
logger.info("Using LHCbDirac version %s", diracversion)
8588
os.environ['GANGADIRACENVIRONMENT'] = fname
8689

0 commit comments

Comments
 (0)