summaryrefslogtreecommitdiffstats
path: root/src/linux
diff options
context:
space:
mode:
authorAlvaro Neira Ayuso <aneira@soleta.eu>2020-01-16 19:22:44 +0100
committerAlvaro Neira Ayuso <alvaroneay@gmail.com>2020-01-19 19:50:44 +0100
commitd5dca0f75614a3319dd528b0e390b8cec812db1b (patch)
tree7ce1c8965904a183cc5f2404d839b2ccf33b06d8 /src/linux
parent230bdca0ea290541f6d7f835ff7dc8571fc9f506 (diff)
Add stop command
This patch includes a new support for stopping all the process running on the ogClient.
Diffstat (limited to 'src/linux')
-rw-r--r--src/linux/ogOperations.py43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py
index 3fa636e..082f1fd 100644
--- a/src/linux/ogOperations.py
+++ b/src/linux/ogOperations.py
@@ -15,47 +15,51 @@ def reboot():
else:
subprocess.call(['/sbin/reboot'])
-def execCMD(httpparser):
+def execCMD(httpparser, ogRest):
cmd = httpparser.getCMD()
cmds = cmd.split(" ")
try:
- result = subprocess.check_output(cmds)
+ ogRest.proc = subprocess.Popen(cmds, stdout=subprocess.PIPE, shell=True)
+ (output, error) = ogRest.proc.communicate()
except:
raise ValueError('Error: Incorrect command value')
- return result.decode('utf-8')
+ return output.decode('utf-8')
-def procsession(httpparser):
+def procsession(httpparser, ogRest):
disk = httpparser.getDisk()
partition = httpparser.getPartition()
try:
- result = subprocess.check_output([OG_PATH + 'interfaceAdm/IniciarSesion', disk, partition], shell=True)
+ ogRest.proc = subprocess.Popen([OG_PATH + 'interfaceAdm/IniciarSesion', disk, partition], stdout=subprocess.PIPE, shell=True)
+ (output, error) = ogRest.proc.communicate()
except:
raise ValueError('Error: Incorrect command value')
- return result.decode('utf-8')
+ return output.decode('utf-8')
-def procsoftware(httpparser, path):
+def procsoftware(httpparser, path, ogRest):
disk = httpparser.getDisk()
partition = httpparser.getPartition()
try:
- result = subprocess.check_output([OG_PATH + 'interfaceAdm/InventarioSoftware', disk, partition, path], shell=True)
+ ogRest.proc = subprocess.Popen([OG_PATH + 'interfaceAdm/InventarioSoftware', disk, partition, path], stdout=subprocess.PIPE, shell=True)
+ (output, error) = ogRest.proc.communicate()
except:
raise ValueError('Error: Incorrect command value')
- return result.decode('utf-8')
+ return output.decode('utf-8')
-def prochardware(path):
+def prochardware(path, ogRest):
try:
- result = subprocess.check_output([OG_PATH + 'interfaceAdm/InventarioHardware', path], shell=True)
+ ogRest.proc = subprocess.Popen([OG_PATH + 'interfaceAdm/InventarioHardware', path], stdout=subprocess.PIPE, shell=True)
+ (output, error) = ogRest.proc.communicate()
except:
raise ValueError('Error: Incorrect command value')
- return result.decode('utf-8')
+ return output.decode('utf-8')
-def procsetup(httpparser):
+def procsetup(httpparser, ogRest):
disk = httpparser.getDisk()
cache = httpparser.getCache()
cachesize = httpparser.getCacheSize()
@@ -66,8 +70,12 @@ def procsetup(httpparser):
i = 0
json = {}
cfg = 'dis=' + disk + '*che=' + cache + '*tch=' + cachesize + '!par=' + part["partition"] + '*cpt='+part["code"] + '*sfi=' + part['filesystem'] + '*tam=' + part['size'] + '*ope=' + part['format'] + '%'
+ if ogRest.terminated:
+ break
+
try:
- subprocess.check_output([OG_PATH + 'interfaceAdm/Configurar', disk, cfg], shell=True)
+ ogRest.proc = subprocess.Popen([OG_PATH + 'interfaceAdm/Configurar', disk, cfg], stdout=subprocess.PIPE, shell=True)
+ (output, error) = ogRest.proc.communicate()
except:
continue
@@ -86,7 +94,7 @@ def procsetup(httpparser):
return listConfigs
-def procirestore(httpparser):
+def procirestore(httpparser, ogRest):
disk = httpparser.getDisk()
partition = httpparser.getPartition()
name = httpparser.getName()
@@ -96,8 +104,9 @@ def procirestore(httpparser):
cid = httpparser.getId()
try:
- result = subprocess.check_output([OG_PATH + 'interfaceAdm/RestaurarImagen', disk, partition, name, repo, ctype], shell=True)
+ ogRest.proc = subprocess.Popen([OG_PATH + 'interfaceAdm/RestaurarImagen', disk, partition, name, repo, ctype], stdout=subprocess.PIPE, shell=True)
+ (output, error) = ogRest.proc.communicate()
except:
raise ValueError('Error: Incorrect command value')
- return result.decode('utf-8')
+ return output.decode('utf-8')