mirror of https://git.48k.eu/ogclient
live: disable browser operations if the binary is missing
Add shutils.which checks before every browser operations to skip the subprocess call if the binary is missing.master
parent
8754c21694
commit
9c2ae873f2
4
ogclient
4
ogclient
|
@ -13,6 +13,7 @@ import logging
|
|||
import argparse
|
||||
import platform
|
||||
import subprocess
|
||||
import shutil
|
||||
try:
|
||||
from signal import SIG_DFL, SIGPIPE
|
||||
except ImportError:
|
||||
|
@ -79,7 +80,8 @@ def main():
|
|||
LOGLEVEL = CONFIG['opengnsys']['log']
|
||||
|
||||
if MODE == 'live':
|
||||
proc = subprocess.Popen(["browser", "-qws", URL])
|
||||
if shutil.which('browser'):
|
||||
proc = subprocess.Popen(["browser", "-qws", URL])
|
||||
if MODE != 'windows':
|
||||
signal.signal(SIGPIPE, SIG_DFL)
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ class OgLiveOperations:
|
|||
self._smb_pass = config['samba']['pass']
|
||||
|
||||
def _restartBrowser(self, url):
|
||||
if not shutil.which('browser'):
|
||||
return
|
||||
|
||||
try:
|
||||
proc = subprocess.call(["pkill", "-9", "browser"])
|
||||
proc = subprocess.Popen(["browser", "-qws", url])
|
||||
|
@ -353,7 +356,7 @@ class OgLiveOperations:
|
|||
umount_cache()
|
||||
if subprocess.run(cmd_ethtool).returncode != 0:
|
||||
logging.error('Error running ethtool subprocess')
|
||||
if subprocess.run(cmd_browser).returncode != 0:
|
||||
if shutil.which('browser') and subprocess.run(cmd_browser).returncode != 0:
|
||||
logging.error('Error terminating ogBrowser process')
|
||||
if subprocess.run(cmd_busybox) != 0:
|
||||
logging.error('Error running "busybox poweroff" subprocess')
|
||||
|
|
Loading…
Reference in New Issue