diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-05-09 14:55:04 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-05-09 16:05:08 +0100 |
| commit | b54339d63339c99f24845f69f49cd1fe996e6e7c (patch) | |
| tree | 73b3da57a66ab4a0f6fa06a479efc5449126342f /meta/lib/oe | |
| parent | d529c11fa512e7f06044378a7ec7137765ea8eb4 (diff) | |
| download | poky-b54339d63339c99f24845f69f49cd1fe996e6e7c.tar.gz | |
classes/lib: Fix getcmdstatus breakage
I mistakenly thought subprocess had getcmdstatus in python 2. It doesn't so lets
add a wrapper and have this work in both worlds.
(From OE-Core rev: 2253e9f12734c6e6aa489942b5e4628eca1fa29d)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
| -rw-r--r-- | meta/lib/oe/patch.py | 4 | ||||
| -rw-r--r-- | meta/lib/oe/utils.py | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index 8de73a7037..244f6c5cf2 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py | |||
| @@ -17,7 +17,7 @@ class CmdError(bb.BBHandledException): | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | def runcmd(args, dir = None): | 19 | def runcmd(args, dir = None): |
| 20 | import subprocess, pipes | 20 | import pipes |
| 21 | 21 | ||
| 22 | if dir: | 22 | if dir: |
| 23 | olddir = os.path.abspath(os.curdir) | 23 | olddir = os.path.abspath(os.curdir) |
| @@ -30,7 +30,7 @@ def runcmd(args, dir = None): | |||
| 30 | args = [ pipes.quote(str(arg)) for arg in args ] | 30 | args = [ pipes.quote(str(arg)) for arg in args ] |
| 31 | cmd = " ".join(args) | 31 | cmd = " ".join(args) |
| 32 | # print("cmd: %s" % cmd) | 32 | # print("cmd: %s" % cmd) |
| 33 | (exitstatus, output) = subprocess.getstatusoutput(cmd) | 33 | (exitstatus, output) = oe.utils.getstatusoutput(cmd) |
| 34 | if exitstatus != 0: | 34 | if exitstatus != 0: |
| 35 | raise CmdError(exitstatus >> 8, output) | 35 | raise CmdError(exitstatus >> 8, output) |
| 36 | return output | 36 | return output |
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index ed9409613a..ec8260d9bd 100644 --- a/meta/lib/oe/utils.py +++ b/meta/lib/oe/utils.py | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | try: | ||
| 2 | # Python 2 | ||
| 3 | import commands as cmdstatus | ||
| 4 | except ImportError: | ||
| 5 | # Python 3 | ||
| 6 | import subprocess as cmdstatus | ||
| 7 | |||
| 1 | def read_file(filename): | 8 | def read_file(filename): |
| 2 | try: | 9 | try: |
| 3 | f = file( filename, "r" ) | 10 | f = file( filename, "r" ) |
| @@ -123,3 +130,6 @@ def packages_filter_out_system(d): | |||
| 123 | if pkg not in blacklist and localepkg not in pkg: | 130 | if pkg not in blacklist and localepkg not in pkg: |
| 124 | pkgs.append(pkg) | 131 | pkgs.append(pkg) |
| 125 | return pkgs | 132 | return pkgs |
| 133 | |||
| 134 | def getstatusoutput(cmd): | ||
| 135 | return cmdstatus.getstatusoutput(cmd) | ||
