summaryrefslogtreecommitdiff
path: root/scripts/lib
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
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')
-rw-r--r--scripts/lib/wic/utils/misc.py14
-rw-r--r--scripts/lib/wic/utils/runner.py50
2 files changed, 13 insertions, 51 deletions
diff --git a/scripts/lib/wic/utils/misc.py b/scripts/lib/wic/utils/misc.py
index c941112c63..307779aad5 100644
--- a/scripts/lib/wic/utils/misc.py
+++ b/scripts/lib/wic/utils/misc.py
@@ -59,7 +59,7 @@ NATIVE_RECIPES = {"bmaptool": "bmap-tools",
"syslinux": "syslinux"
}
-def _exec_cmd(cmd_and_args, as_shell=False, catch=3):
+def _exec_cmd(cmd_and_args, as_shell=False):
"""
Execute command, catching stderr, stdout
@@ -70,9 +70,9 @@ def _exec_cmd(cmd_and_args, as_shell=False, catch=3):
logger.debug(args)
if as_shell:
- ret, out = runner.runtool(cmd_and_args, catch)
+ ret, out = runner.runtool(cmd_and_args)
else:
- ret, out = runner.runtool(args, catch)
+ ret, out = runner.runtool(args)
out = out.strip()
if ret != 0:
raise WicError("_exec_cmd: %s returned '%s' instead of 0\noutput: %s" % \
@@ -84,14 +84,14 @@ def _exec_cmd(cmd_and_args, as_shell=False, catch=3):
return ret, out
-def exec_cmd(cmd_and_args, as_shell=False, catch=3):
+def exec_cmd(cmd_and_args, as_shell=False):
"""
Execute command, return output
"""
- return _exec_cmd(cmd_and_args, as_shell, catch)[1]
+ return _exec_cmd(cmd_and_args, as_shell)[1]
-def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""):
+def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""):
"""
Execute native command, catching stderr, stdout
@@ -118,7 +118,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""):
# If the command isn't in the native sysroot say we failed.
if spawn.find_executable(args[0], native_paths):
- ret, out = _exec_cmd(native_cmd_and_args, True, catch)
+ ret, out = _exec_cmd(native_cmd_and_args, True)
else:
ret = 127
out = "can't find native executable %s in %s" % (args[0], native_paths)
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