summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2020-04-17 10:18:01 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2020-04-22 10:39:02 +0200
commit0807ec76ed82d56048b3d5e89729e9ca0d67133f (patch)
tree85550349c0a2ba050d96dd51944d61becefbd261
parentb576836e4331fe8c2e3b92d343af0e2d5670d6c0 (diff)
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.
-rw-r--r--cfg/ogclient.cfg1
-rw-r--r--src/linux/ogOperations.py32
2 files changed, 27 insertions, 6 deletions
diff --git a/cfg/ogclient.cfg b/cfg/ogclient.cfg
index a006eca..634382d 100644
--- a/cfg/ogclient.cfg
+++ b/cfg/ogclient.cfg
@@ -1,6 +1,7 @@
[opengnsys]
ip=127.0.0.1
url=https://127.0.0.1/opengnsys/varios/menubrowser.php
+url_log=http://localhost/cgi-bin/httpd-log.sh
port=8889
# Log Level, if ommited, will be set to INFO
log=DEBUG
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'))