change check_output to run
This commit is contained in:
parent
d6c1261cec
commit
cf927c3ce0
@ -1,7 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from platform import uname
|
from platform import uname
|
||||||
from subprocess import check_output
|
from subprocess import run, PIPE, STDOUT
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
@ -61,7 +61,7 @@ class PlayoutService:
|
|||||||
self.proc = None
|
self.proc = None
|
||||||
|
|
||||||
def run_cmd(self):
|
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):
|
def start(self):
|
||||||
self.cmd.append('start')
|
self.cmd.append('start')
|
||||||
@ -80,10 +80,10 @@ class PlayoutService:
|
|||||||
self.run_cmd()
|
self.run_cmd()
|
||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
self.cmd.append('status')
|
self.cmd.append('is-active')
|
||||||
self.run_cmd()
|
self.run_cmd()
|
||||||
|
|
||||||
return self.proc
|
return self.proc.replace('\n', '')
|
||||||
|
|
||||||
def log(self):
|
def log(self):
|
||||||
self.cmd = ['sudo', '/bin/systemctl', 'journalctl',
|
self.cmd = ['sudo', '/bin/systemctl', 'journalctl',
|
||||||
|
@ -99,7 +99,7 @@ class SystemCtl(APIView):
|
|||||||
log = service.log()
|
log = service.log()
|
||||||
return Response({"data": log})
|
return Response({"data": log})
|
||||||
else:
|
else:
|
||||||
Response({"success": False})
|
return Response({"success": False})
|
||||||
|
|
||||||
return Response({"success": False})
|
return Response({"success": False})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user