Fix OgLinuxOperations class params

Commit 621fb7a7 added class initialization with two parameters. These
two parameters were wrongly initialized, "self." was missing. The call
of these params in other functions of the class was also wrong.

This commit fix the initialization of the parameters of
OgLinuxOperations and fix the calls to these params.
more_events
Javier Sánchez Parra 2020-05-20 11:56:36 +02:00
parent 6502180fc8
commit 147c890617
1 changed files with 15 additions and 15 deletions

View File

@ -15,8 +15,8 @@ OG_SHELL = '/bin/bash'
class OgLinuxOperations: class OgLinuxOperations:
def __init__(self, config): def __init__(self, config):
_url = config['opengnsys']['url'] self._url = config['opengnsys']['url']
_url_log = config['opengnsys']['url_log'] self._url_log = config['opengnsys']['url_log']
def _restartBrowser(self, url): def _restartBrowser(self, url):
try: try:
@ -70,7 +70,7 @@ class OgLinuxOperations:
cmd = request.getrun() cmd = request.getrun()
cmds = cmd.split(";|\n\r") cmds = cmd.split(";|\n\r")
self._restartBrowser(OgLinuxOperations._url_log) self._restartBrowser(self._url_log)
try: try:
ogRest.proc = subprocess.Popen(cmds, ogRest.proc = subprocess.Popen(cmds,
@ -83,7 +83,7 @@ class OgLinuxOperations:
cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration' cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
result = subprocess.check_output([cmd_get_conf], shell=True) result = subprocess.check_output([cmd_get_conf], shell=True)
self._restartBrowser(OgLinuxOperations._url) self._restartBrowser(self._url)
return output.decode('utf-8') return output.decode('utf-8')
@ -107,7 +107,7 @@ class OgLinuxOperations:
disk = request.getDisk() disk = request.getDisk()
partition = request.getPartition() partition = request.getPartition()
self._restartBrowser(OgLinuxOperations._url_log) self._restartBrowser(self._url_log)
try: try:
cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \ cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
@ -121,7 +121,7 @@ class OgLinuxOperations:
except: except:
raise ValueError('Error: Incorrect command value') raise ValueError('Error: Incorrect command value')
self._restartBrowser(OgLinuxOperations._url) self._restartBrowser(self._url)
software = '' software = ''
with open(path, 'r') as f: with open(path, 'r') as f:
@ -129,7 +129,7 @@ class OgLinuxOperations:
return software return software
def hardware(self, path, ogRest): def hardware(self, path, ogRest):
self._restartBrowser(OgLinuxOperations._url_log) self._restartBrowser(self._url_log)
try: try:
cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioHardware {path}' cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioHardware {path}'
@ -141,7 +141,7 @@ class OgLinuxOperations:
except: except:
raise ValueError('Error: Incorrect command value') raise ValueError('Error: Incorrect command value')
self._restartBrowser(OgLinuxOperations._url) self._restartBrowser(self._url)
return output.decode('utf-8') return output.decode('utf-8')
@ -172,7 +172,7 @@ class OgLinuxOperations:
cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration' cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
result = subprocess.check_output([cmd_get_conf], shell=True) result = subprocess.check_output([cmd_get_conf], shell=True)
self._restartBrowser(OgLinuxOperations._url) self._restartBrowser(self._url)
return self.parseGetConf(result.decode('utf-8')) return self.parseGetConf(result.decode('utf-8'))
@ -187,7 +187,7 @@ class OgLinuxOperations:
cmd = f'{ogConfig.OG_PATH}interfaceAdm/RestaurarImagen {disk} {partition} ' \ cmd = f'{ogConfig.OG_PATH}interfaceAdm/RestaurarImagen {disk} {partition} ' \
f'{name} {repo} {ctype}' f'{name} {repo} {ctype}'
self._restartBrowser(OgLinuxOperations._url_log) self._restartBrowser(self._url_log)
try: try:
ogRest.proc = subprocess.Popen([cmd], ogRest.proc = subprocess.Popen([cmd],
@ -200,7 +200,7 @@ class OgLinuxOperations:
cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration' cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
result = subprocess.check_output([cmd_get_conf], shell=True) result = subprocess.check_output([cmd_get_conf], shell=True)
self._restartBrowser(OgLinuxOperations._url) self._restartBrowser(self._url)
return output.decode('utf-8') return output.decode('utf-8')
@ -214,7 +214,7 @@ class OgLinuxOperations:
cmd_create_image = f'{ogConfig.OG_PATH}interfaceAdm/CrearImagen {disk} ' \ cmd_create_image = f'{ogConfig.OG_PATH}interfaceAdm/CrearImagen {disk} ' \
f'{partition} {name} {repo}' f'{partition} {name} {repo}'
self._restartBrowser(OgLinuxOperations._url_log) self._restartBrowser(self._url_log)
try: try:
ogRest.proc = subprocess.Popen([cmd_software], ogRest.proc = subprocess.Popen([cmd_software],
@ -237,12 +237,12 @@ class OgLinuxOperations:
except: except:
raise ValueError('Error: Incorrect command value') raise ValueError('Error: Incorrect command value')
self._restartBrowser(OgLinuxOperations._url) self._restartBrowser(self._url)
return output.decode('utf-8') return output.decode('utf-8')
def refresh(self, ogRest): def refresh(self, ogRest):
self._restartBrowser(OgLinuxOperations._url_log) self._restartBrowser(self._url_log)
try: try:
cmd = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration' cmd = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
@ -254,6 +254,6 @@ class OgLinuxOperations:
except: except:
raise ValueError('Error: Incorrect command value') raise ValueError('Error: Incorrect command value')
self._restartBrowser(OgLinuxOperations._url) self._restartBrowser(self._url)
return self.parseGetConf(output.decode('utf-8')) return self.parseGetConf(output.decode('utf-8'))