1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 12:15:40 +01:00
svtplay-dl/lib/svtplay_dl/utils/proc.py
Johan Andersson 3aef9a796e black fixes
2019-09-06 22:31:52 +02:00

15 lines
433 B
Python

import logging
import subprocess
def run_program(cmd, show=True):
p = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE
)
stdout, stderr = p.communicate()
stderr = stderr.decode("utf-8", "replace")
if p.returncode != 0 and show:
msg = stderr.strip()
logging.error("Something went wrong: {}".format(msg))
return p.returncode, stdout, stderr