Skip to content

Commit

Permalink
SystemCallStep: support custom working dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
alenz33 committed Mar 20, 2015
1 parent 1373d49 commit a14e37c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion conduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ def main(argv=None):
BuildStep('s3', {}).build()
bs = SystemCallStep('scs', {
'command' : 'ls',
'captureoutput' : True
'captureoutput' : True,
'workingdir' : '/var/',
})
bs.build()
print(bs.commandoutput)
#bs = CopyBS('copysth', {})
#bs.loglevel = 'debug'
#bs.description = 'Some description'
Expand Down
18 changes: 13 additions & 5 deletions conduct/buildsteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# *****************************************************************************

import pprint
import os

import conduct
from conduct.util import systemCall
Expand Down Expand Up @@ -168,7 +168,10 @@ class SystemCallStep(BuildStep):
description='command to execute'),
'captureoutput' : Parameter(type=bool,
description='Capture command output',
default=True)
default=True),
'workingdir' : Parameter(type=str,
description='Working directory for command execution',
default='.'),
}

outparameters = {
Expand All @@ -178,10 +181,15 @@ class SystemCallStep(BuildStep):
}

def run(self, args):
self.commandoutput = systemCall(self.command,
captureOutput=self.captureoutput,
log=self.log)
cwd = os.getcwd()

try:
os.chdir(self.workingdir)
self.commandoutput = systemCall(self.command,
captureOutput=self.captureoutput,
log=self.log)
finally:
os.chdir(cwd)



Expand Down

0 comments on commit a14e37c

Please sign in to comment.