This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch network-namespace
in repository https://gitbox.apache.org/repos/asf/cloudstack-extensions.git
The following commit(s) were added to refs/heads/network-namespace by this push:
new dbde2bb Network Namespace: fix python3.6 issue with
capture_output=True
dbde2bb is described below
commit dbde2bb7af63811b5395df74b2cefc126f203557
Author: Wei Zhou <[email protected]>
AuthorDate: Thu Apr 16 16:12:30 2026 +0200
Network Namespace: fix python3.6 issue with capture_output=True
The argument 'capture_output' is introduced in python 3.7.
In python 3.6 (on oracle linux 8), it returns an error like below
```
>>> cmd = ['ip', 'netns', 'ls']
>>> import subprocess
>>> subprocess.run(cmd, capture_output=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.6/subprocess.py", line 423, in run
with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'capture_output'
```
therefore replace with stdout/stderr
```
>>> r=subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
>>> r.returncode
0
```
---
Network-Namespace/network-namespace-wrapper.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Network-Namespace/network-namespace-wrapper.sh
b/Network-Namespace/network-namespace-wrapper.sh
index 223e334..f0b0a6a 100755
--- a/Network-Namespace/network-namespace-wrapper.sh
+++ b/Network-Namespace/network-namespace-wrapper.sh
@@ -2461,7 +2461,7 @@ FW_INGRESS_PREFIX = 'CS_EXTNET_FWI_'
def _run(table, *args):
cmd = ['ip', 'netns', 'exec', namespace, 'iptables', '-t', table] +
list(args)
- r = subprocess.run(cmd, capture_output=True)
+ r = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if r.returncode != 0:
print(f"iptables ({table}): {r.stderr.decode().strip()}",
file=sys.stderr)
return r
@@ -3614,7 +3614,7 @@ except Exception as e:
def _run(table, *args):
cmd = ['ip', 'netns', 'exec', namespace, 'iptables', '-t', table] +
list(args)
- r = subprocess.run(cmd, capture_output=True)
+ r = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if r.returncode != 0:
print(f"iptables ({table}): {r.stderr.decode().strip()}",
file=sys.stderr)
return r