mirror of https://git.48k.eu/ogclient
Avoid writting /software output to a file
parent
7ccc498014
commit
2e3d47b7b8
|
@ -117,7 +117,10 @@ class OgLinuxOperations:
|
|||
except:
|
||||
raise ValueError('Error: Incorrect command value')
|
||||
|
||||
return output.decode('utf-8')
|
||||
software = ''
|
||||
with open(path, 'r') as f:
|
||||
software = f.read()
|
||||
return software
|
||||
|
||||
def hardware(self, path, ogRest):
|
||||
try:
|
||||
|
|
|
@ -119,7 +119,7 @@ class ogThread():
|
|||
|
||||
def software(client, request, path, ogRest):
|
||||
try:
|
||||
ogRest.operations.software(request, path, ogRest)
|
||||
software = ogRest.operations.software(request, path, ogRest)
|
||||
except ValueError as err:
|
||||
response = restResponse(ogResponses.INTERNAL_ERR)
|
||||
client.send(response.get())
|
||||
|
@ -128,8 +128,7 @@ class ogThread():
|
|||
|
||||
json_body = jsonBody()
|
||||
json_body.add_element('partition', request.getPartition())
|
||||
with open(path, 'r') as f:
|
||||
json_body.add_element('software', f.read())
|
||||
json_body.add_element('software', software)
|
||||
|
||||
response = restResponse(ogResponses.OK, json_body)
|
||||
client.send(response.get())
|
||||
|
@ -188,6 +187,7 @@ class ogThread():
|
|||
def image_create(client, path, request, ogRest):
|
||||
try:
|
||||
ogRest.operations.image_create(path, request, ogRest)
|
||||
software = ogRest.operations.software(request, path, ogRest)
|
||||
except ValueError as err:
|
||||
response = restResponse(ogResponses.INTERNAL_ERR)
|
||||
client.send(response.get())
|
||||
|
@ -201,8 +201,7 @@ class ogThread():
|
|||
json_body.add_element('id', request.getId())
|
||||
json_body.add_element('name', request.getName())
|
||||
json_body.add_element('repository', request.getRepo())
|
||||
with open(path, 'r') as f:
|
||||
json_body.add_element('software', f.read())
|
||||
json_body.add_element('software', software)
|
||||
|
||||
response = restResponse(ogResponses.OK, json_body)
|
||||
client.send(response.get())
|
||||
|
|
|
@ -358,11 +358,7 @@ class OgVirtualOperations:
|
|||
software += [h.node_name(x) for x in h.node_children(key)]
|
||||
os.remove('win_reg')
|
||||
|
||||
with open(path, 'w+') as f:
|
||||
f.seek(0)
|
||||
for program in software:
|
||||
f.write(f'{program}\n')
|
||||
f.truncate()
|
||||
return '\n'.join(software)
|
||||
|
||||
def parse_pci(self, path='/usr/share/misc/pci.ids'):
|
||||
data = {}
|
||||
|
|
Loading…
Reference in New Issue