From 1ced3dd0693fc6d88c0d5ec8432102454e10075e Mon Sep 17 00:00:00 2001 From: Alvaro Neira Ayuso Date: Mon, 13 Jan 2020 19:20:13 +0100 Subject: Improve hardware command response behavior This patch give us a better support in case of error or success execution. In error cases, the new behavior is to send an Internal Error http message (500). Otherwise, the server will receive a message with a json with this format: { "hardware" : "xyz" } "xyz" is the output saved in a specific path during the execution of InventarioHardware. --- src/linux/ogOperations.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/linux') diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py index 0034fd7..447f188 100644 --- a/src/linux/ogOperations.py +++ b/src/linux/ogOperations.py @@ -48,7 +48,11 @@ def procsoftware(httpparser, path): return result.decode('utf-8') def prochardware(path): - result = subprocess.check_output([OG_PATH + 'interfaceAdm/InventarioHardware', path], shell=True) + try: + result = subprocess.check_output([OG_PATH + 'interfaceAdm/InventarioHardware', path], shell=True) + except: + raise ValueError('Error: Incorrect command value') + return result.decode('utf-8') def procsetup(httpparser): -- cgit v1.2.3-18-g5258