Skip to content

Commit

Permalink
MasterShellCommand: support env and usePTY, fixes calls.
Browse files Browse the repository at this point in the history
In our case, we wanted to run ssh from the master, so needed the environ.
Pass those values to the spawnProcess.

Note: this commit changes the default empty environment to the parent
process's. If you still want an empty environ, specify env={} as an
argument.
  • Loading branch information
xrg authored and Dustin J. Mitchell committed Oct 3, 2010
1 parent cf09b3b commit d4bdf3f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion master/buildbot/steps/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ class MasterShellCommand(BuildStep):

def __init__(self, command,
description=None, descriptionDone=None,
env=None, path=None, usePTY=0,
**kwargs):
BuildStep.__init__(self, **kwargs)
self.addFactoryArguments(description=description,
descriptionDone=descriptionDone,
env=env, path=path, usePTY=usePTY,
command=command)

self.command=command
Expand All @@ -32,6 +34,9 @@ def __init__(self, command,
self.descriptionDone = descriptionDone
if isinstance(self.descriptionDone, str):
self.descriptionDone = [self.descriptionDone]
self.env=env
self.path=path
self.usePTY=usePTY

class LocalPP(ProcessProtocol):
def __init__(self, step):
Expand Down Expand Up @@ -80,8 +85,14 @@ def start(self):
stdio_log.addHeader(" argv: %s\n" % (argv,))
self.step_status.setText(list(self.description))

if self.env is None:
env = os.environ
else:
assert isinstance(self.env, dict)
env = self.env
# TODO add a timeout?
reactor.spawnProcess(self.LocalPP(self), argv[0], argv)
reactor.spawnProcess(self.LocalPP(self), argv[0], argv,
path=self.path, usePTY=self.usePTY, env=env )
# (the LocalPP object will call processEnded for us)

def processEnded(self, status_object):
Expand Down

0 comments on commit d4bdf3f

Please sign in to comment.