summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2021-03-23 15:51:36 +0900
committerKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2021-03-30 08:47:08 +0900
commitbbd2f1c781c8791f1626e003f86ebaa89260c8f6 (patch)
tree5123246093b51a0b947b87821f329132dfb03fdf /scripts
parent9756d9b548351e43f33b621f8e7e1433d6dcb77f (diff)
base: add run2() to enable to get command return value
Current run() can't handle command return value. This patch adds new run2() which can handle return value. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/base.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/base.py b/scripts/base.py
index 5e5161e..324298e 100755
--- a/scripts/base.py
+++ b/scripts/base.py
@@ -73,13 +73,18 @@ class base:
#
# run command and get result as plane text
#--------------------
- def run(self, command):
+ def run2(self, command):
# Ughhhh
# I don't like python external command !!
# (ノ `Д´)ノ go away !!
- return self.chomp(subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).\
- communicate()[0].decode("utf-8"));
+ child = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
+ stdout, stderr = child.communicate()
+
+ return self.chomp(stdout.decode("utf-8")), child.returncode;
+
+ def run(self, command):
+ return self.run2(command)[0]
#--------------------
# run1()