summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/linux/ogOperations.py5
-rw-r--r--src/ogRest.py9
-rw-r--r--src/virtual/ogOperations.py6
3 files changed, 9 insertions, 11 deletions
diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py
index fcbcc69..d0bbeeb 100644
--- a/src/linux/ogOperations.py
+++ b/src/linux/ogOperations.py
@@ -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:
diff --git a/src/ogRest.py b/src/ogRest.py
index 24c8a70..4fb2bba 100644
--- a/src/ogRest.py
+++ b/src/ogRest.py
@@ -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())
diff --git a/src/virtual/ogOperations.py b/src/virtual/ogOperations.py
index a9cf06b..bc18dd4 100644
--- a/src/virtual/ogOperations.py
+++ b/src/virtual/ogOperations.py
@@ -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 = {}