lib: remove dead Python < 3.5 compatibility branch in script()
subprocess.run() has been available since Python 3.5 (EOL 2017). The hasattr() guard and check_output() fallback are dead code. Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
This commit is contained in:
parent
83b49b313c
commit
9276d2a98b
1 changed files with 2 additions and 8 deletions
|
|
@ -28,14 +28,8 @@ CURRENT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + '/../
|
|||
|
||||
def script(*args, env=None):
|
||||
args = (os.path.join(CURRENT_DIR, 'script.sh'),) + args
|
||||
# subprocess.run was introduced in Python 3.5
|
||||
# fall back to subprocess.check_output if it's not available
|
||||
if hasattr(subprocess, 'run'):
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE, env=env)
|
||||
p = p.stdout
|
||||
else:
|
||||
p = subprocess.check_output(args)
|
||||
return p
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE, env=env)
|
||||
return p.stdout
|
||||
|
||||
def run_cmd(*args, env=None):
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
|
||||
|
|
|
|||
Loading…
Reference in a new issue