summaryrefslogtreecommitdiffstats
path: root/src/linux
diff options
context:
space:
mode:
authorAlvaro Neira Ayuso <aneira@soleta.eu>2019-12-28 18:02:00 +0100
committerAlvaro Neira Ayuso <alvaroneay@gmail.com>2020-01-19 19:50:44 +0100
commite6eba4b91f0cfc54b33a4832b1a9de3816bbfd6e (patch)
tree578d57a1f19ae226bb1f2a163f7efa13bff7f340 /src/linux
parentaf903503a2424994f58a3adc42597451df569c65 (diff)
(BUG) Handling command error
This patch adds support for handling the error when the command is wrong formed. Now, if we send a shell/run command and the shell command is incomplete, the program crashes.
Diffstat (limited to 'src/linux')
-rw-r--r--src/linux/ogOperations.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py
index 1502f40..147944f 100644
--- a/src/linux/ogOperations.py
+++ b/src/linux/ogOperations.py
@@ -17,5 +17,9 @@ def reboot():
def execCMD(cmd):
cmds = cmd.split(" ")
- result = subprocess.run(cmds, stdout=subprocess.PIPE)
- return result.stdout.decode('utf-8')
+ try:
+ result = subprocess.check_output(cmds)
+ except:
+ raise ValueError('Error: Incorrect command value')
+
+ return result.decode('utf-8')