From cf927c3ce04f2ac779e48c079849f00260a7d084 Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Mon, 27 Apr 2020 11:56:49 +0200 Subject: [PATCH] change check_output to run --- ffplayout/api/utils.py | 8 ++++---- ffplayout/api/views.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ffplayout/api/utils.py b/ffplayout/api/utils.py index bc23b5c2..36819a32 100644 --- a/ffplayout/api/utils.py +++ b/ffplayout/api/utils.py @@ -1,7 +1,7 @@ import json import os from platform import uname -from subprocess import check_output +from subprocess import run, PIPE, STDOUT from time import sleep import psutil @@ -61,7 +61,7 @@ class PlayoutService: self.proc = None def run_cmd(self): - self.proc = check_output(self.cmd + self.service) + self.proc = run(self.cmd + self.service, stdout=PIPE, stderr=STDOUT, encoding="utf-8").stdout def start(self): self.cmd.append('start') @@ -80,10 +80,10 @@ class PlayoutService: self.run_cmd() def status(self): - self.cmd.append('status') + self.cmd.append('is-active') self.run_cmd() - return self.proc + return self.proc.replace('\n', '') def log(self): self.cmd = ['sudo', '/bin/systemctl', 'journalctl', diff --git a/ffplayout/api/views.py b/ffplayout/api/views.py index bf432c71..6172b49e 100644 --- a/ffplayout/api/views.py +++ b/ffplayout/api/views.py @@ -99,7 +99,7 @@ class SystemCtl(APIView): log = service.log() return Response({"data": log}) else: - Response({"success": False}) + return Response({"success": False}) return Response({"success": False})