Skip to content
Snippets Groups Projects
Commit 49a36f3c authored by nimrod's avatar nimrod
Browse files

Use subprocess32 only on Python2.7.

Since Python3.4 is EOL and Python3.5 has `run` in the `subprocess`
module, there's no need for it outside of Python2.7.
parent e463ab1d
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ setup(
"PyYAML",
"jmespath",
"toml",
"subprocess32>=3.5.0",
"subprocess32>=3.5.0;python_version<'3.5'",
],
extras_require={"dev": ["pipenv"]},
entry_points={"console_scripts": ["template=template:main"]},
......
......@@ -157,11 +157,16 @@ def run(*argv, **kwargs):
>>> run(['ls', 'foo'])['returncode'] > 0
True
"""
import subprocess32 # nosec
import sys
defaults = {"stdout": subprocess32.PIPE, "stderr": subprocess32.PIPE}
if sys.version_info[0] < 3: # nosec
import subprocess32 as subprocess
else:
import subprocess
defaults = {"stdout": subprocess.PIPE, "stderr": subprocess.PIPE}
defaults.update(kwargs)
proc = subprocess32.run(*argv, **defaults).__dict__
proc = subprocess.run(*argv, **defaults).__dict__ # nosec
if "text" not in kwargs or kwargs["text"]:
proc["stdout"] = proc["stdout"].decode()
proc["stderr"] = proc["stderr"].decode()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment