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.
more_events
Javier Sánchez Parra 2020-04-17 10:18:01 +02:00
parent b576836e43
commit 0807ec76ed
2 changed files with 27 additions and 6 deletions

View File

@ -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

View File

@ -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'))