Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mesmith75 committed Dec 11, 2023
1 parent bc6f3bb commit e3dd366
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 1 addition & 4 deletions ganga/GangaCore/Utility/Shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,10 @@ def __init__(self, setup=None, setup_args=[]):
setup_args (list): list of strings which are executed directly with a ' ' character spacing
"""

self.env = os.environ
if setup is not None:
self.env = os.environ
execute('source {0} {1}'.format(setup, " ".join(setup_args)), shell=True, env=self.env, update_env=True)

else:
self.env = os.environ

self.dirname = None

def cmd(self, cmd, soutfile=None, allowed_exit=None,
Expand Down
8 changes: 3 additions & 5 deletions ganga/GangaCore/Utility/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def env_update_script(indent=''):
import os
import pickle as pickle
with os.fdopen(###FD_WRITE###,'wb') as envpipe:
pickle.dump(os.environ, envpipe, 2)
pickle.dump(dict(os.environ), envpipe, 2)
'''
from GangaCore.GPIDev.Lib.File.FileUtils import indentScript
script = indentScript(this_script, '###INDENT###')
Expand Down Expand Up @@ -155,7 +155,6 @@ def execute(command,

if update_env and env is None:
raise GangaException('Cannot update the environment if None given.')

if not shell:
# We want to run a python command inside a small Python wrapper
stream_command = 'python -'
Expand All @@ -168,18 +167,17 @@ def execute(command,
# note the exec gets around the problem of indent and base64 gets
# around the \n
command_update, env_file_pipes = env_update_script()
command_bytes = command_update.encode("utf-8")
command += ''';python -c "import base64;exec(base64.b64decode(%s))"''' % base64.b64encode(
command_update)
command_bytes)

# Some minor changes to cleanup the getting of the env
if env is None:
env = os.environ

# Construct the object which will contain the environment we want to run the command in
p = subprocess.Popen(stream_command, shell=True, env=env, cwd=cwd, preexec_fn=os.setsid,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True, close_fds=False)

# This is where we store the output
thread_output = {}

Expand Down

0 comments on commit e3dd366

Please sign in to comment.