summaryrefslogtreecommitdiff
path: root/cloudinit/subp.py
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2020-12-25 17:52:03 +0200
committerzsdc <taras@vyos.io>2020-12-25 17:52:03 +0200
commit526c2760b85ff625a10f4a1c9ba83759d8de1441 (patch)
treec7a87d78a7944dd6a9d02544d1605f3a7d77e313 /cloudinit/subp.py
parent66dc53b1b3f8786f3bbb25e914c1dc8161af0494 (diff)
parent47f4229ebcef9f83df8b549bb869a2dbf6dff17c (diff)
downloadvyos-cloud-init-526c2760b85ff625a10f4a1c9ba83759d8de1441.tar.gz
vyos-cloud-init-526c2760b85ff625a10f4a1c9ba83759d8de1441.zip
T2117: Cloud-init updated to 20.4
Merged with 20.4 tag from the upstream Cloud-init repository
Diffstat (limited to 'cloudinit/subp.py')
-rw-r--r--cloudinit/subp.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/cloudinit/subp.py b/cloudinit/subp.py
index 3e4efa42..024e1a98 100644
--- a/cloudinit/subp.py
+++ b/cloudinit/subp.py
@@ -144,7 +144,7 @@ class ProcessExecutionError(IOError):
def subp(args, data=None, rcs=None, env=None, capture=True,
combine_capture=False, shell=False,
logstring=False, decode="replace", target=None, update_env=None,
- status_cb=None):
+ status_cb=None, cwd=None):
"""Run a subprocess.
:param args: command to run in a list. [cmd, arg1, arg2...]
@@ -181,6 +181,8 @@ def subp(args, data=None, rcs=None, env=None, capture=True,
:param status_cb:
call this fuction with a single string argument before starting
and after finishing.
+ :param cwd:
+ change the working directory to cwd before executing the command.
:return
if not capturing, return is (None, None)
@@ -254,7 +256,7 @@ def subp(args, data=None, rcs=None, env=None, capture=True,
try:
sp = subprocess.Popen(bytes_args, stdout=stdout,
stderr=stderr, stdin=stdin,
- env=env, shell=shell)
+ env=env, shell=shell, cwd=cwd)
(out, err) = sp.communicate(data)
except OSError as e:
if status_cb: