From 0807ec76ed82d56048b3d5e89729e9ca0d67133f Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Fri, 17 Apr 2020 10:18:01 +0200 Subject: Add realtime log menu We observed that with the new ogClient the ogLive did not show the realtime log menu*. This commit changes the ogClient to launch the browser and show the realtime log menu when some commands are executed. * The realtime log menu is a menu that shows current status and info about the command that the ogLive is executing. --- src/linux/ogOperations.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/linux') diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py index d0bbeeb..ab58cd7 100644 --- a/src/linux/ogOperations.py +++ b/src/linux/ogOperations.py @@ -18,11 +18,12 @@ class OgLinuxOperations: _config_path = f'{ogConfig.OG_PATH}ogclient/cfg/ogclient.cfg' _ogconfig.parser_file(_config_path) _url = _ogconfig.get_value_section('opengnsys', 'url') + _url_log = _ogconfig.get_value_section('opengnsys', 'url_log') - def _restartBrowser(self): + def _restartBrowser(self, url): try: proc = subprocess.call(["pkill", "-9", "browser"]) - proc = subprocess.Popen(["browser", "-qws", OgLinuxOperations._url]) + proc = subprocess.Popen(["browser", "-qws", url]) except: raise ValueError('Error: cannot restart browser') @@ -70,6 +71,9 @@ class OgLinuxOperations: def execCMD(self, request, ogRest): cmd = request.getrun() cmds = cmd.split(";|\n\r") + + self._restartBrowser(OgLinuxOperations._url_log) + try: ogRest.proc = subprocess.Popen(cmds, stdout=subprocess.PIPE, @@ -81,7 +85,7 @@ class OgLinuxOperations: cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration' result = subprocess.check_output([cmd_get_conf], shell=True) - self._restartBrowser() + self._restartBrowser(OgLinuxOperations._url) return output.decode('utf-8') @@ -105,6 +109,8 @@ class OgLinuxOperations: disk = request.getDisk() partition = request.getPartition() + self._restartBrowser(OgLinuxOperations._url_log) + try: cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \ f'{partition} {path}' @@ -117,12 +123,16 @@ class OgLinuxOperations: except: raise ValueError('Error: Incorrect command value') + self._restartBrowser(OgLinuxOperations._url) + software = '' with open(path, 'r') as f: software = f.read() return software def hardware(self, path, ogRest): + self._restartBrowser(OgLinuxOperations._url_log) + try: cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioHardware {path}' ogRest.proc = subprocess.Popen([cmd], @@ -133,6 +143,8 @@ class OgLinuxOperations: except: raise ValueError('Error: Incorrect command value') + self._restartBrowser(OgLinuxOperations._url) + return output.decode('utf-8') def setup(self, request, ogRest): @@ -162,7 +174,7 @@ class OgLinuxOperations: cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration' result = subprocess.check_output([cmd_get_conf], shell=True) - self._restartBrowser() + self._restartBrowser(OgLinuxOperations._url) return self.parseGetConf(result.decode('utf-8')) @@ -177,6 +189,8 @@ class OgLinuxOperations: cmd = f'{ogConfig.OG_PATH}interfaceAdm/RestaurarImagen {disk} {partition} ' \ f'{name} {repo} {ctype}' + self._restartBrowser(OgLinuxOperations._url_log) + try: ogRest.proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, @@ -188,7 +202,7 @@ class OgLinuxOperations: cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration' result = subprocess.check_output([cmd_get_conf], shell=True) - self._restartBrowser() + self._restartBrowser(OgLinuxOperations._url) return output.decode('utf-8') @@ -202,6 +216,8 @@ class OgLinuxOperations: cmd_create_image = f'{ogConfig.OG_PATH}interfaceAdm/CrearImagen {disk} ' \ f'{partition} {name} {repo}' + self._restartBrowser(OgLinuxOperations._url_log) + try: ogRest.proc = subprocess.Popen([cmd_software], stdout=subprocess.PIPE, @@ -223,9 +239,13 @@ class OgLinuxOperations: except: raise ValueError('Error: Incorrect command value') + self._restartBrowser(OgLinuxOperations._url) + return output.decode('utf-8') def refresh(self, ogRest): + self._restartBrowser(OgLinuxOperations._url_log) + try: cmd = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration' ogRest.proc = subprocess.Popen([cmd], @@ -236,6 +256,6 @@ class OgLinuxOperations: except: raise ValueError('Error: Incorrect command value') - self._restartBrowser() + self._restartBrowser(OgLinuxOperations._url) return self.parseGetConf(output.decode('utf-8')) -- cgit v1.2.3-18-g5258