diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/live/ogOperations.py | 26 | ||||
-rw-r--r-- | src/ogRest.py | 10 |
2 files changed, 16 insertions, 20 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index f11b221..56f0a75 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -31,6 +31,7 @@ from src.utils.disk import * from src.utils.cache import generate_cache_txt, umount_cache, init_cache from src.utils.tiptorrent import * from src.utils.sw_inventory import get_package_set +from src.utils.hw_inventory import get_hardware_inventory, legacy_list_hardware_inventory OG_SHELL = '/bin/bash' @@ -274,24 +275,21 @@ class OgLiveOperations: # "{package_name} {package_version}" return '\n'.join(map(str,pkgset)) - def hardware(self, path, ogRest): + def hardware(self, ogRest): self._restartBrowser(self._url_log) + logging.info('Running hardware inventory command') try: - cmd = f'{ogClient.OG_PATH}interfaceAdm/InventarioHardware {path}' - ogRest.proc = subprocess.Popen([cmd], - stdout=subprocess.PIPE, - shell=True, - executable=OG_SHELL) - (output, error) = ogRest.proc.communicate() - except: - logging.error('Exception when running hardware inventory subprocess') - raise ValueError('Error: Incorrect command value') - - self._restartBrowser(self._url) + inventory = get_hardware_inventory() + except ValueError as e: + logging.error('Error occurred while running get_hardware_inventory') + raise e + finally: + self._restartBrowser(self._url) - logging.info('Hardware inventory command OK') - return output.decode('utf-8') + result = legacy_list_hardware_inventory(inventory) + logging.info('Successful hardware inventory command execution') + return result def setup(self, request, ogRest): table_type = request.getType() diff --git a/src/ogRest.py b/src/ogRest.py index fe6c0da..ac312f2 100644 --- a/src/ogRest.py +++ b/src/ogRest.py @@ -135,16 +135,15 @@ class ogThread(): client.send(response.get()) ogRest.state = ThreadState.IDLE - def hardware(client, path, ogRest): + def hardware(client, ogRest): try: - ogRest.operations.hardware(path, ogRest) + result = ogRest.operations.hardware(ogRest) except Exception as e: ogRest.send_internal_server_error(client, exc=e) return json_body = jsonBody() - with open(path, 'r') as f: - json_body.add_element('hardware', f.read()) + json_body.add_element('hardware', result) response = restResponse(ogResponses.OK, json_body) client.send(response.get()) @@ -399,8 +398,7 @@ class ogRest(): threading.Thread(target=ogThread.software, args=(client, request, path, self,)).start() def process_hardware(self, client): - path = '/tmp/Chrd-' + client.ip - threading.Thread(target=ogThread.hardware, args=(client, path, self,)).start() + threading.Thread(target=ogThread.hardware, args=(client, self,)).start() def process_schedule(self, client): response = restResponse(ogResponses.OK) |