1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-28 06:04:17 +01:00
svtplay-dl/lib/svtplay_dl/utils/proc.py

13 lines
419 B
Python
Raw Normal View History

import logging
2019-08-25 00:40:39 +02:00
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()
2019-08-25 00:27:31 +02:00
stderr = stderr.decode("utf-8", "replace")
if p.returncode != 0 and show:
msg = stderr.strip()
2019-08-25 00:33:51 +02:00
logging.error("Something went wrong: {}".format(msg))
return p.returncode, stdout, stderr