diff options
| author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-08-03 16:51:50 +0300 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-09 00:14:02 -0700 |
| commit | 8ce832890107a959ad9ff28481188d8b26d4a425 (patch) | |
| tree | b24753e84c2377959a8189d4de4229065b2b60d7 /scripts/lib | |
| parent | 8421e0e29f5e2073de8b8162b28a99e2582bd64e (diff) | |
| download | poky-8ce832890107a959ad9ff28481188d8b26d4a425.tar.gz | |
wic: code cleanup: pylint misc.py
Fixed pylint warnings.
Increased pylint score from 8.02 to 9.40.
(From OE-Core rev: 26d8c70fb8a7cc8f6473ad1779b20b00616740c0)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/wic/utils/oe/misc.py | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/scripts/lib/wic/utils/oe/misc.py b/scripts/lib/wic/utils/oe/misc.py index 0fa8a53b98..d399f2a480 100644 --- a/scripts/lib/wic/utils/oe/misc.py +++ b/scripts/lib/wic/utils/oe/misc.py | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | # AUTHORS | 24 | # AUTHORS |
| 25 | # Tom Zanussi <tom.zanussi (at] linux.intel.com> | 25 | # Tom Zanussi <tom.zanussi (at] linux.intel.com> |
| 26 | # | 26 | # |
| 27 | """Miscellaneous functions.""" | ||
| 27 | 28 | ||
| 28 | from collections import defaultdict | 29 | from collections import defaultdict |
| 29 | 30 | ||
| @@ -56,14 +57,14 @@ def __exec_cmd(cmd_and_args, as_shell=False, catch=3): | |||
| 56 | msger.debug(args) | 57 | msger.debug(args) |
| 57 | 58 | ||
| 58 | if as_shell: | 59 | if as_shell: |
| 59 | rc, out = runner.runtool(cmd_and_args, catch) | 60 | ret, out = runner.runtool(cmd_and_args, catch) |
| 60 | else: | 61 | else: |
| 61 | rc, out = runner.runtool(args, catch) | 62 | ret, out = runner.runtool(args, catch) |
| 62 | out = out.strip() | 63 | out = out.strip() |
| 63 | msger.debug("__exec_cmd: output for %s (rc = %d): %s" % \ | 64 | msger.debug("__exec_cmd: output for %s (rc = %d): %s" % \ |
| 64 | (cmd_and_args, rc, out)) | 65 | (cmd_and_args, ret, out)) |
| 65 | 66 | ||
| 66 | return (rc, out) | 67 | return (ret, out) |
| 67 | 68 | ||
| 68 | 69 | ||
| 69 | def exec_cmd(cmd_and_args, as_shell=False, catch=3): | 70 | def exec_cmd(cmd_and_args, as_shell=False, catch=3): |
| @@ -72,10 +73,11 @@ def exec_cmd(cmd_and_args, as_shell=False, catch=3): | |||
| 72 | 73 | ||
| 73 | Exits if rc non-zero | 74 | Exits if rc non-zero |
| 74 | """ | 75 | """ |
| 75 | rc, out = __exec_cmd(cmd_and_args, as_shell, catch) | 76 | ret, out = __exec_cmd(cmd_and_args, as_shell, catch) |
| 76 | 77 | ||
| 77 | if rc != 0: | 78 | if ret != 0: |
| 78 | msger.error("exec_cmd: %s returned '%s' instead of 0" % (cmd_and_args, rc)) | 79 | msger.error("exec_cmd: %s returned '%s' instead of 0" % \ |
| 80 | (cmd_and_args, ret)) | ||
| 79 | 81 | ||
| 80 | return out | 82 | return out |
| 81 | 83 | ||
| @@ -97,9 +99,9 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3): | |||
| 97 | args = cmd_and_args.split() | 99 | args = cmd_and_args.split() |
| 98 | msger.debug(args) | 100 | msger.debug(args) |
| 99 | 101 | ||
| 100 | rc, out = __exec_cmd(native_cmd_and_args, True, catch) | 102 | ret, out = __exec_cmd(native_cmd_and_args, True, catch) |
| 101 | 103 | ||
| 102 | if rc == 127: # shell command-not-found | 104 | if ret == 127: # shell command-not-found |
| 103 | prog = args[0] | 105 | prog = args[0] |
| 104 | msg = "A native program %s required to build the image "\ | 106 | msg = "A native program %s required to build the image "\ |
| 105 | "was not found (see details above).\n\n" % prog | 107 | "was not found (see details above).\n\n" % prog |
| @@ -114,11 +116,11 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3): | |||
| 114 | if out: | 116 | if out: |
| 115 | msger.debug('"%s" output: %s' % (args[0], out)) | 117 | msger.debug('"%s" output: %s' % (args[0], out)) |
| 116 | 118 | ||
| 117 | if rc != 0: | 119 | if ret != 0: |
| 118 | msger.error("exec_cmd: '%s' returned '%s' instead of 0" % \ | 120 | msger.error("exec_cmd: '%s' returned '%s' instead of 0" % \ |
| 119 | (cmd_and_args, rc)) | 121 | (cmd_and_args, ret)) |
| 120 | 122 | ||
| 121 | return (rc, out) | 123 | return ret, out |
| 122 | 124 | ||
| 123 | BOOTDD_EXTRA_SPACE = 16384 | 125 | BOOTDD_EXTRA_SPACE = 16384 |
| 124 | 126 | ||
| @@ -137,10 +139,10 @@ def get_bitbake_var(var, image=None): | |||
| 137 | 139 | ||
| 138 | log_level = msger.get_loglevel() | 140 | log_level = msger.get_loglevel() |
| 139 | msger.set_loglevel('normal') | 141 | msger.set_loglevel('normal') |
| 140 | rc, lines = __exec_cmd(cmd) | 142 | ret, lines = __exec_cmd(cmd) |
| 141 | msger.set_loglevel(log_level) | 143 | msger.set_loglevel(log_level) |
| 142 | 144 | ||
| 143 | if rc: | 145 | if ret: |
| 144 | print "Couldn't get '%s' output." % cmd | 146 | print "Couldn't get '%s' output." % cmd |
| 145 | print "Bitbake failed with error:\n%s\n" % lines | 147 | print "Bitbake failed with error:\n%s\n" % lines |
| 146 | return | 148 | return |
| @@ -176,14 +178,14 @@ def parse_sourceparams(sourceparams): | |||
| 176 | 178 | ||
| 177 | params = sourceparams.split(',') | 179 | params = sourceparams.split(',') |
| 178 | if params: | 180 | if params: |
| 179 | for p in params: | 181 | for par in params: |
| 180 | if not p: | 182 | if not par: |
| 181 | continue | 183 | continue |
| 182 | if not '=' in p: | 184 | if not '=' in par: |
| 183 | key = p | 185 | key = par |
| 184 | val = None | 186 | val = None |
| 185 | else: | 187 | else: |
| 186 | key, val = p.split('=') | 188 | key, val = par.split('=') |
| 187 | params_dict[key] = val | 189 | params_dict[key] = val |
| 188 | 190 | ||
| 189 | return params_dict | 191 | return params_dict |
