diff options
| author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2017-06-16 16:19:27 +0300 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-23 11:44:12 +0100 |
| commit | a0536e61dcea2e7207a8933c6fad71c2c1cdf21a (patch) | |
| tree | 5347917f6d52d9cd31bdc74c4c84aa465612088c /scripts/lib/wic/utils/runner.py | |
| parent | 44023e6c41a57d93d7b3a7c6d297e1ca77cd69ff (diff) | |
| download | poky-a0536e61dcea2e7207a8933c6fad71c2c1cdf21a.tar.gz | |
wic/runner.py: move runtool API to misc.py
Moved remaining API to misc.py.
Removed runner.py.
Now misc.py is ready to be moved to the scripts/lib/wic and
utils directory can be removed.
(From OE-Core rev: 327e340a29d330f24117e24d0649fa156017208f)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/utils/runner.py')
| -rw-r--r-- | scripts/lib/wic/utils/runner.py | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/scripts/lib/wic/utils/runner.py b/scripts/lib/wic/utils/runner.py deleted file mode 100644 index 4aa00fbe20..0000000000 --- a/scripts/lib/wic/utils/runner.py +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 1 | #!/usr/bin/env python -tt | ||
| 2 | # | ||
| 3 | # Copyright (c) 2011 Intel, Inc. | ||
| 4 | # | ||
| 5 | # This program is free software; you can redistribute it and/or modify it | ||
| 6 | # under the terms of the GNU General Public License as published by the Free | ||
| 7 | # Software Foundation; version 2 of the License | ||
| 8 | # | ||
| 9 | # This program is distributed in the hope that it will be useful, but | ||
| 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
| 11 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 12 | # for more details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License along | ||
| 15 | # with this program; if not, write to the Free Software Foundation, Inc., 59 | ||
| 16 | # Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
| 17 | import subprocess | ||
| 18 | |||
| 19 | from wic import WicError | ||
| 20 | |||
| 21 | def runtool(cmdln_or_args): | ||
| 22 | """ wrapper for most of the subprocess calls | ||
| 23 | input: | ||
| 24 | cmdln_or_args: can be both args and cmdln str (shell=True) | ||
| 25 | return: | ||
| 26 | rc, output | ||
| 27 | """ | ||
| 28 | if isinstance(cmdln_or_args, list): | ||
| 29 | cmd = cmdln_or_args[0] | ||
| 30 | shell = False | ||
| 31 | else: | ||
| 32 | import shlex | ||
| 33 | cmd = shlex.split(cmdln_or_args)[0] | ||
| 34 | shell = True | ||
| 35 | |||
| 36 | sout = subprocess.PIPE | ||
| 37 | serr = subprocess.STDOUT | ||
| 38 | |||
| 39 | try: | ||
| 40 | process = subprocess.Popen(cmdln_or_args, stdout=sout, | ||
| 41 | stderr=serr, shell=shell) | ||
| 42 | sout, serr = process.communicate() | ||
| 43 | # combine stdout and stderr, filter None out and decode | ||
| 44 | out = ''.join([out.decode('utf-8') for out in [sout, serr] if out]) | ||
| 45 | except OSError as err: | ||
| 46 | if err.errno == 2: | ||
| 47 | # [Errno 2] No such file or directory | ||
| 48 | raise WicError('Cannot run command: %s, lost dependency?' % cmd) | ||
| 49 | else: | ||
| 50 | raise # relay | ||
| 51 | |||
| 52 | return process.returncode, out | ||
