1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-12-05 01:23:44 +01:00
svtplay-dl/lib/svtplay_dl/utils/proc.py

13 lines
412 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()
2021-12-18 21:36:16 +01:00
logging.error("Something went wrong: %s", msg)
return p.returncode, stdout, stderr