summaryrefslogtreecommitdiff
path: root/scripts/lib/wic/utils/runner.py
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-03-26 20:39:22 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-31 12:12:15 +0100
commit1e45a4f72b16c7ab64f46907d2d2ee9cd749dc23 (patch)
tree5c9a8394738cb0d0f0d5e85c4c81da817d3b4e6d /scripts/lib/wic/utils/runner.py
parent9749336c37249af99c92478c3e4dc8821cb9a816 (diff)
downloadopenembedded-core-1e45a4f72b16c7ab64f46907d2d2ee9cd749dc23.tar.gz
openembedded-core-1e45a4f72b16c7ab64f46907d2d2ee9cd749dc23.tar.bz2
openembedded-core-1e45a4f72b16c7ab64f46907d2d2ee9cd749dc23.zip
wic: remove unused code from runner module
Removed unused APIs 'outs' and 'quiet'. Removed 'catch' parameter from runner.runtool API as wic uses only one value of it. Removed the code that handles unused values of 'catch' parameter. [YOCTO #10618] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Diffstat (limited to 'scripts/lib/wic/utils/runner.py')
-rw-r--r--scripts/lib/wic/utils/runner.py50
1 files changed, 6 insertions, 44 deletions
diff --git a/scripts/lib/wic/utils/runner.py b/scripts/lib/wic/utils/runner.py
index 348557aee8..4aa00fbe20 100644
--- a/scripts/lib/wic/utils/runner.py
+++ b/scripts/lib/wic/utils/runner.py
@@ -14,32 +14,17 @@
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-import logging
-import os
import subprocess
from wic import WicError
-logger = logging.getLogger('wic')
-
-def runtool(cmdln_or_args, catch=1):
+def runtool(cmdln_or_args):
""" wrapper for most of the subprocess calls
input:
cmdln_or_args: can be both args and cmdln str (shell=True)
- catch: 0, quitely run
- 1, only STDOUT
- 2, only STDERR
- 3, both STDOUT and STDERR
return:
- (rc, output)
- if catch==0: the output will always None
+ rc, output
"""
-
- if catch not in (0, 1, 2, 3):
- # invalid catch selection, will cause exception, that's good
- return None
-
if isinstance(cmdln_or_args, list):
cmd = cmdln_or_args[0]
shell = False
@@ -48,26 +33,13 @@ def runtool(cmdln_or_args, catch=1):
cmd = shlex.split(cmdln_or_args)[0]
shell = True
- if catch != 3:
- dev_null = os.open("/dev/null", os.O_WRONLY)
-
- if catch == 0:
- sout = dev_null
- serr = dev_null
- elif catch == 1:
- sout = subprocess.PIPE
- serr = dev_null
- elif catch == 2:
- sout = dev_null
- serr = subprocess.PIPE
- elif catch == 3:
- sout = subprocess.PIPE
- serr = subprocess.STDOUT
+ sout = subprocess.PIPE
+ serr = subprocess.STDOUT
try:
process = subprocess.Popen(cmdln_or_args, stdout=sout,
stderr=serr, shell=shell)
- (sout, serr) = process.communicate()
+ sout, serr = process.communicate()
# combine stdout and stderr, filter None out and decode
out = ''.join([out.decode('utf-8') for out in [sout, serr] if out])
except OSError as err:
@@ -76,15 +48,5 @@ def runtool(cmdln_or_args, catch=1):
raise WicError('Cannot run command: %s, lost dependency?' % cmd)
else:
raise # relay
- finally:
- if catch != 3:
- os.close(dev_null)
-
- return (process.returncode, out)
-
-def outs(cmdln_or_args, catch=1):
- # get the outputs of tools
- return runtool(cmdln_or_args, catch)[1].strip()
-def quiet(cmdln_or_args):
- return runtool(cmdln_or_args, catch=0)[0]
+ return process.returncode, out