From ad1bce56c43cf4758b4974f95736cfef3840c246 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Sun, 26 Mar 2017 20:39:22 +0300 Subject: 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] (From OE-Core rev: 1e45a4f72b16c7ab64f46907d2d2ee9cd749dc23) Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- scripts/lib/wic/utils/runner.py | 50 +++++------------------------------------ 1 file changed, 6 insertions(+), 44 deletions(-) (limited to 'scripts/lib/wic/utils/runner.py') 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 -- cgit v1.2.3-54-g00ecf