Skip to content

Commit 93b1f39

Browse files
authored
Make it possible to specify the current dir when using the Executor (#41)
* Make it possible to specify the current dir when using the Executor Signed-off-by: cmuraru <[email protected]> * Fix build Signed-off-by: cmuraru <[email protected]>
1 parent b8fc163 commit 93b1f39

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

build_scripts/build_package.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -e
33

44
echo "Building package"
5+
rm -rf dist/
56
export BOTO_CONFIG=/dev/null
67
python setup.py sdist bdist_wheel
78
ls -l dist/

requirements.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
simpledi>=0.2
2-
awscli==1.16.97
2+
awscli==1.16.206
33
ansible==2.7.10
4-
s3transfer==0.1.13
5-
boto3==1.9.87
4+
boto3==1.9.196
65
boto==2.49.0
7-
botocore==1.12.87
6+
botocore==1.12.196
87
PyYAML==3.13
98
azure-common==1.1.20
109
azure==4.0.0

src/ops/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@
1616
class Executor(object):
1717
""" All cli commands usually return a dict(command=...) that will be executed by this handler"""
1818

19-
def __call__(self, result, pass_trough=True):
19+
def __call__(self, result, pass_trough=True, cwd=None):
2020
try:
21-
return self._execute(result, pass_trough)
21+
return self._execute(result, pass_trough, cwd)
2222
except Exception as ex:
2323
display(ex.message, stderr=True, color='red')
2424
display('------- TRACEBACK ----------', stderr=True, color='dark gray')
2525
import traceback
2626
traceback.print_exc()
2727
display('------ END TRACEBACK -------', stderr=True, color='dark gray')
2828

29-
def _execute(self, result, pass_trough=True):
29+
def _execute(self, result, pass_trough=True, cwd=None):
3030
if not result or not isinstance(result, dict):
3131
return
3232

3333
if 'command' in result:
3434
shell_command = result['command']
3535
display("%s" % self.shadow_credentials(shell_command), stderr=True, color='yellow')
3636
if pass_trough:
37-
exit_code = call(shell_command, shell=True)
37+
exit_code = call(shell_command, shell=True, cwd=cwd)
3838
else:
39-
p = Popen(shell_command, shell=True, stdout=PIPE, stderr=PIPE)
39+
p = Popen(shell_command, shell=True, stdout=PIPE, stderr=PIPE, cwd=cwd)
4040
output, errors = p.communicate()
4141
display(output)
4242
if errors:

0 commit comments

Comments
 (0)