Skip to content

Commit

Permalink
Avoid to copy twice the environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Allard committed Mar 23, 2010
1 parent 16d24d3 commit 0f43459
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions buildbot/slave/commands/base.py
Expand Up @@ -289,7 +289,6 @@ def __init__(self, builder, command,
self.workdir = workdir
if not os.path.exists(workdir):
os.makedirs(workdir)
self.environ = os.environ.copy()
if environ:
if environ.has_key('PYTHONPATH'):
ppath = environ['PYTHONPATH']
Expand All @@ -306,17 +305,19 @@ def __init__(self, builder, command,
# do substitution on variable values matching patern: ${name}
p = re.compile('\${([0-9a-zA-Z_]*)}')
def subst(match):
return self.environ.get(match.group(1), "")
return os.environ.get(match.group(1), "")
newenv = {}
for key in self.environ.keys():
for key in os.environ.keys():
# setting a key to None will delete it from the slave environment
if key not in environ or environ[key] is not None:
newenv[key] = self.environ[key]
newenv[key] = os.environ[key]
for key in environ.keys():
if environ[key] is not None:
newenv[key] = p.sub(subst, environ[key])

self.environ = newenv
else: # not environ
self.environ = os.environ.copy()
self.initialStdin = initialStdin
self.keepStdinOpen = keepStdinOpen
self.logEnviron = logEnviron
Expand Down

0 comments on commit 0f43459

Please sign in to comment.