mirror of https://git.48k.eu/ogclient
Improve software command response behavior
During our tests, we found some limitation during the execution of the software command. We don't manage errors during the execution of this command. Moreover, the server needs some information in case that everything is OK. This patch modified the code for controlling the errors during the execution, returning an "Internal Error" http message (500). Moreover, in case that everything is OK, ogClient sends a message with this json body: { "disk" : "0", "partition" : "1", "software" : "xyz" } "xyz" will be the output saved during the execution of InventarioSoftware in a specific path.more_events
parent
0f32b9ca88
commit
683afa6465
|
@ -40,7 +40,11 @@ def procsoftware(httpparser, path):
|
|||
disk = httpparser.getDisk()
|
||||
partition = httpparser.getPartition()
|
||||
|
||||
result = subprocess.check_output([OG_PATH + 'interfaceAdm/InventarioSoftware', disk, partition, path], shell=True)
|
||||
try:
|
||||
result = subprocess.check_output([OG_PATH + 'interfaceAdm/InventarioSoftware', disk, partition, path], shell=True)
|
||||
except:
|
||||
raise ValueError('Error: Incorrect command value')
|
||||
|
||||
return result.decode('utf-8')
|
||||
|
||||
def prochardware(path):
|
||||
|
|
|
@ -68,9 +68,23 @@ class ogThread():
|
|||
client.send(restResponse.getResponse(ogResponses.OK))
|
||||
|
||||
# Process software
|
||||
def procsoftware(msgqueue, httpparser, path):
|
||||
msgqueue.queue.clear()
|
||||
msgqueue.put(ogOperations.procsoftware(httpparser, path))
|
||||
def procsoftware(client, httpparser, path):
|
||||
try:
|
||||
ogOperations.procsoftware(httpparser, path)
|
||||
except ValueError as err:
|
||||
client.send(restResponse.getResponse(ogResponses.INTERNAL_ERR))
|
||||
return
|
||||
|
||||
jsonResp = jsonResponse()
|
||||
jsonResp.addElement('disk', httpparser.getDisk())
|
||||
jsonResp.addElement('partition', httpparser.getPartition())
|
||||
|
||||
f = open(path, "r")
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
jsonResp.addElement('software', lines[0])
|
||||
|
||||
client.send(restResponse.getResponse(ogResponses.OK, jsonResp))
|
||||
|
||||
# Process hardware
|
||||
def prochardware(msgqueue, path):
|
||||
|
@ -172,9 +186,8 @@ class ogRest():
|
|||
threading.Thread(target=ogThread.procsession, args=(client, httpparser,)).start()
|
||||
|
||||
def process_software(self, client, httpparser):
|
||||
path = '/tmp/CSft-' + client.ip + '-' + partition
|
||||
threading.Thread(target=ogThread.procsoftware, args=(self.msgqueue, httpparser, path,)).start()
|
||||
client.send(restResponse.getResponse(ogResponses.OK))
|
||||
path = '/tmp/CSft-' + client.ip + '-' + httpparser.getPartition()
|
||||
threading.Thread(target=ogThread.procsoftware, args=(client, httpparser, path,)).start()
|
||||
|
||||
def process_hardware(self, client):
|
||||
path = '/tmp/Chrd-' + client.ip
|
||||
|
|
Loading…
Reference in New Issue