summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-04-15 23:47:10 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-04-24 11:06:55 +0100
commitf2a0a985236af116a84cc62a4f7e1d4707aea6e9 (patch)
tree781ff0e7990d38b314d9bea34a02abf085ff453d
parent1d0c3387e8881a7a372ee38c0944540ce2ac8bc5 (diff)
downloadpoky-f2a0a985236af116a84cc62a4f7e1d4707aea6e9.tar.gz
wic: code cleanup: wildcard imports
Here is what PEP8(Style Guide for Python Code) says about this: Wildcard imports (from <module> import *) should be avoided, as they make it unclear which names are present in the namespace, confusing both readers and many automated tools. (From OE-Core rev: 13416c1941f5dc8abcdb0073f2104a89eae2d6f1) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/image/engine.py18
-rw-r--r--scripts/lib/wic/imager/direct.py1
-rw-r--r--scripts/lib/wic/plugin.py2
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-efi.py8
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-partition.py2
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-pcbios.py9
-rw-r--r--scripts/lib/wic/plugins/source/fsimage.py2
-rw-r--r--scripts/lib/wic/plugins/source/rawcopy.py2
-rw-r--r--scripts/lib/wic/plugins/source/rootfs.py9
-rw-r--r--scripts/lib/wic/utils/fs_related.py5
-rw-r--r--scripts/lib/wic/utils/partitionedfs.py4
-rwxr-xr-xscripts/wic41
12 files changed, 43 insertions, 60 deletions
diff --git a/scripts/lib/image/engine.py b/scripts/lib/image/engine.py
index 68d1ce2659..05c26386e7 100644
--- a/scripts/lib/image/engine.py
+++ b/scripts/lib/image/engine.py
@@ -42,7 +42,7 @@ from wic.utils import cmdln, misc, errors
42from wic.conf import configmgr 42from wic.conf import configmgr
43from wic.plugin import pluginmgr 43from wic.plugin import pluginmgr
44from wic.__version__ import VERSION 44from wic.__version__ import VERSION
45from wic.utils.oe.misc import * 45from wic.utils.oe import misc
46 46
47 47
48def verify_build_env(): 48def verify_build_env():
@@ -65,19 +65,19 @@ def find_artifacts(image_name):
65 Gather the build artifacts for the current image (the image_name 65 Gather the build artifacts for the current image (the image_name
66 e.g. core-image-minimal) for the current MACHINE set in local.conf 66 e.g. core-image-minimal) for the current MACHINE set in local.conf
67 """ 67 """
68 bitbake_env_lines = get_bitbake_env_lines() 68 bitbake_env_lines = misc.get_bitbake_env_lines()
69 69
70 rootfs_dir = kernel_dir = bootimg_dir = native_sysroot = "" 70 rootfs_dir = kernel_dir = bootimg_dir = native_sysroot = ""
71 71
72 for line in bitbake_env_lines.split('\n'): 72 for line in bitbake_env_lines.split('\n'):
73 if (get_line_val(line, "IMAGE_ROOTFS")): 73 if (misc.get_line_val(line, "IMAGE_ROOTFS")):
74 rootfs_dir = get_line_val(line, "IMAGE_ROOTFS") 74 rootfs_dir = misc.get_line_val(line, "IMAGE_ROOTFS")
75 continue 75 continue
76 if (get_line_val(line, "DEPLOY_DIR_IMAGE")): 76 if (misc.get_line_val(line, "DEPLOY_DIR_IMAGE")):
77 kernel_dir = get_line_val(line, "DEPLOY_DIR_IMAGE") 77 kernel_dir = misc.get_line_val(line, "DEPLOY_DIR_IMAGE")
78 continue 78 continue
79 if (get_line_val(line, "STAGING_DIR_NATIVE")): 79 if (misc.get_line_val(line, "STAGING_DIR_NATIVE")):
80 native_sysroot = get_line_val(line, "STAGING_DIR_NATIVE") 80 native_sysroot = misc.get_line_val(line, "STAGING_DIR_NATIVE")
81 continue 81 continue
82 82
83 return (rootfs_dir, kernel_dir, bootimg_dir, native_sysroot) 83 return (rootfs_dir, kernel_dir, bootimg_dir, native_sysroot)
@@ -87,7 +87,7 @@ CANNED_IMAGE_DIR = "lib/image/canned-wks" # relative to scripts
87SCRIPTS_CANNED_IMAGE_DIR = "scripts/" + CANNED_IMAGE_DIR 87SCRIPTS_CANNED_IMAGE_DIR = "scripts/" + CANNED_IMAGE_DIR
88 88
89def build_canned_image_list(dl): 89def build_canned_image_list(dl):
90 layers_path = get_bitbake_var("BBLAYERS") 90 layers_path = misc.get_bitbake_var("BBLAYERS")
91 canned_wks_layer_dirs = [] 91 canned_wks_layer_dirs = []
92 92
93 if layers_path is not None: 93 if layers_path is not None:
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py
index 0e687bd70e..9a7d0f5117 100644
--- a/scripts/lib/wic/imager/direct.py
+++ b/scripts/lib/wic/imager/direct.py
@@ -32,7 +32,6 @@ from wic.utils import fs_related, runner, misc
32from wic.utils.partitionedfs import Image 32from wic.utils.partitionedfs import Image
33from wic.utils.errors import CreatorError, ImageError 33from wic.utils.errors import CreatorError, ImageError
34from wic.imager.baseimager import BaseImageCreator 34from wic.imager.baseimager import BaseImageCreator
35from wic.utils.oe.misc import *
36from wic.plugin import pluginmgr 35from wic.plugin import pluginmgr
37 36
38disk_methods = { 37disk_methods = {
diff --git a/scripts/lib/wic/plugin.py b/scripts/lib/wic/plugin.py
index 41a80175ca..9872d20985 100644
--- a/scripts/lib/wic/plugin.py
+++ b/scripts/lib/wic/plugin.py
@@ -20,7 +20,7 @@ import os, sys
20from wic import msger 20from wic import msger
21from wic import pluginbase 21from wic import pluginbase
22from wic.utils import errors 22from wic.utils import errors
23from wic.utils.oe.misc import * 23from wic.utils.oe.misc import get_bitbake_var
24 24
25__ALL__ = ['PluginMgr', 'pluginmgr'] 25__ALL__ = ['PluginMgr', 'pluginmgr']
26 26
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 883378ee84..2fc0357a5c 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -29,13 +29,9 @@ import shutil
29 29
30from wic.utils.errors import ImageError 30from wic.utils.errors import ImageError
31from wic import kickstart, msger 31from wic import kickstart, msger
32from wic.utils import misc, fs_related, errors, runner, cmdln
33from wic.conf import configmgr
34from wic.plugin import pluginmgr
35import wic.imager.direct as direct
36from wic.pluginbase import SourcePlugin 32from wic.pluginbase import SourcePlugin
37from wic.utils.oe.misc import * 33from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var, \
38from wic.imager.direct import DirectImageCreator 34 BOOTDD_EXTRA_SPACE
39 35
40class BootimgEFIPlugin(SourcePlugin): 36class BootimgEFIPlugin(SourcePlugin):
41 name = 'bootimg-efi' 37 name = 'bootimg-efi'
diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py
index c5eb7b8b80..909e59b6e2 100644
--- a/scripts/lib/wic/plugins/source/bootimg-partition.py
+++ b/scripts/lib/wic/plugins/source/bootimg-partition.py
@@ -28,7 +28,7 @@ import re
28 28
29from wic import msger 29from wic import msger
30from wic.pluginbase import SourcePlugin 30from wic.pluginbase import SourcePlugin
31from wic.utils.oe.misc import * 31from wic.utils.oe.misc import exec_cmd, get_bitbake_var
32from glob import glob 32from glob import glob
33 33
34class BootimgPartitionPlugin(SourcePlugin): 34class BootimgPartitionPlugin(SourcePlugin):
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
index 2280867308..9c638554c0 100644
--- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
@@ -28,13 +28,10 @@ import os
28 28
29from wic.utils.errors import ImageError 29from wic.utils.errors import ImageError
30from wic import kickstart, msger 30from wic import kickstart, msger
31from wic.utils import misc, fs_related, errors, runner, cmdln 31from wic.utils import runner
32from wic.conf import configmgr
33from wic.plugin import pluginmgr
34import wic.imager.direct as direct
35from wic.pluginbase import SourcePlugin 32from wic.pluginbase import SourcePlugin
36from wic.utils.oe.misc import * 33from wic.utils.oe.misc import exec_cmd, exec_native_cmd, \
37from wic.imager.direct import DirectImageCreator 34 get_bitbake_var, BOOTDD_EXTRA_SPACE
38 35
39class BootimgPcbiosPlugin(SourcePlugin): 36class BootimgPcbiosPlugin(SourcePlugin):
40 name = 'bootimg-pcbios' 37 name = 'bootimg-pcbios'
diff --git a/scripts/lib/wic/plugins/source/fsimage.py b/scripts/lib/wic/plugins/source/fsimage.py
index 4a090bac42..ef56cf278b 100644
--- a/scripts/lib/wic/plugins/source/fsimage.py
+++ b/scripts/lib/wic/plugins/source/fsimage.py
@@ -19,7 +19,7 @@ import os
19 19
20from wic import msger 20from wic import msger
21from wic.pluginbase import SourcePlugin 21from wic.pluginbase import SourcePlugin
22from wic.utils.oe.misc import * 22from wic.utils.oe.misc import get_bitbake_var
23 23
24class FSImagePlugin(SourcePlugin): 24class FSImagePlugin(SourcePlugin):
25 name = 'fsimage' 25 name = 'fsimage'
diff --git a/scripts/lib/wic/plugins/source/rawcopy.py b/scripts/lib/wic/plugins/source/rawcopy.py
index ca6b721b67..444c0268fb 100644
--- a/scripts/lib/wic/plugins/source/rawcopy.py
+++ b/scripts/lib/wic/plugins/source/rawcopy.py
@@ -19,7 +19,7 @@ import os
19 19
20from wic import msger 20from wic import msger
21from wic.pluginbase import SourcePlugin 21from wic.pluginbase import SourcePlugin
22from wic.utils.oe.misc import * 22from wic.utils.oe.misc import exec_cmd, get_bitbake_var
23 23
24class RawCopyPlugin(SourcePlugin): 24class RawCopyPlugin(SourcePlugin):
25 name = 'rawcopy' 25 name = 'rawcopy'
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index 6f5d9bb19f..7d444301fb 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -27,14 +27,9 @@
27 27
28import os 28import os
29 29
30from wic import kickstart, msger 30from wic import msger
31from wic.utils import misc, fs_related, errors, runner, cmdln
32from wic.conf import configmgr
33from wic.plugin import pluginmgr
34import wic.imager.direct as direct
35from wic.pluginbase import SourcePlugin 31from wic.pluginbase import SourcePlugin
36from wic.utils.oe.misc import * 32from wic.utils.oe.misc import find_bitbake_env_lines, find_artifact
37from wic.imager.direct import DirectImageCreator
38 33
39class RootfsPlugin(SourcePlugin): 34class RootfsPlugin(SourcePlugin):
40 name = 'rootfs' 35 name = 'rootfs'
diff --git a/scripts/lib/wic/utils/fs_related.py b/scripts/lib/wic/utils/fs_related.py
index fb9054d568..2e74461a40 100644
--- a/scripts/lib/wic/utils/fs_related.py
+++ b/scripts/lib/wic/utils/fs_related.py
@@ -20,10 +20,7 @@ from __future__ import with_statement
20import os 20import os
21import errno 21import errno
22 22
23from wic import msger 23from wic.utils.oe.misc import exec_cmd
24from wic.utils import runner
25from wic.utils.errors import *
26from wic.utils.oe.misc import *
27 24
28def makedirs(dirname): 25def makedirs(dirname):
29 """A version of os.makedirs() that doesn't throw an 26 """A version of os.makedirs() that doesn't throw an
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index 40d6e889b0..1c9e3eab58 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -19,10 +19,8 @@
19# Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21from wic import msger 21from wic import msger
22from wic.utils import runner
23from wic.utils.errors import ImageError 22from wic.utils.errors import ImageError
24from wic.utils.fs_related import * 23from wic.utils.oe.misc import exec_cmd, exec_native_cmd
25from wic.utils.oe.misc import *
26 24
27# Overhead of the MBR partitioning scheme (just one sector) 25# Overhead of the MBR partitioning scheme (just one sector)
28MBR_OVERHEAD = 1 26MBR_OVERHEAD = 1
diff --git a/scripts/wic b/scripts/wic
index 7d388c9768..1e07dfe922 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -52,8 +52,9 @@ if bitbake_exe:
52else: 52else:
53 bitbake_main = None 53 bitbake_main = None
54 54
55from image.help import * 55from wic.utils.oe.misc import find_bitbake_env_lines, set_bitbake_env_lines
56from image.engine import * 56from image import engine
57from image import help as hlp
57 58
58def rootfs_dir_to_args(krootfs_dir): 59def rootfs_dir_to_args(krootfs_dir):
59 """ 60 """
@@ -132,7 +133,7 @@ def wic_create_subcommand(args, usage_str):
132 133
133 if options.build_check and not options.properties_file: 134 if options.build_check and not options.properties_file:
134 print "Checking basic build environment..." 135 print "Checking basic build environment..."
135 if not verify_build_env(): 136 if not engine.verify_build_env():
136 print "Couldn't verify build environment, exiting\n" 137 print "Couldn't verify build environment, exiting\n"
137 sys.exit(1) 138 sys.exit(1)
138 else: 139 else:
@@ -158,7 +159,7 @@ def wic_create_subcommand(args, usage_str):
158 sys.exit(1) 159 sys.exit(1)
159 160
160 (rootfs_dir, kernel_dir, bootimg_dir, native_sysroot) \ 161 (rootfs_dir, kernel_dir, bootimg_dir, native_sysroot) \
161 = find_artifacts(options.image_name) 162 = engine.find_artifacts(options.image_name)
162 163
163 else: 164 else:
164 if options.build_rootfs: 165 if options.build_rootfs:
@@ -168,7 +169,7 @@ def wic_create_subcommand(args, usage_str):
168 wks_file = args[0] 169 wks_file = args[0]
169 170
170 if not wks_file.endswith(".wks"): 171 if not wks_file.endswith(".wks"):
171 wks_file = find_canned_image(scripts_path, wks_file) 172 wks_file = engine.find_canned_image(scripts_path, wks_file)
172 if not wks_file: 173 if not wks_file:
173 print "No image named %s found, exiting. (Use 'wic list images' to list available images, or specify a fully-qualified OE kickstart (.wks) filename)\n" % wks_file 174 print "No image named %s found, exiting. (Use 'wic list images' to list available images, or specify a fully-qualified OE kickstart (.wks) filename)\n" % wks_file
174 sys.exit(1) 175 sys.exit(1)
@@ -223,9 +224,9 @@ def wic_create_subcommand(args, usage_str):
223 rootfs_dir = rootfs_dir_to_args(krootfs_dir) 224 rootfs_dir = rootfs_dir_to_args(krootfs_dir)
224 225
225 print "Creating image(s)...\n" 226 print "Creating image(s)...\n"
226 wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir, 227 engine.wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
227 native_sysroot, scripts_path, image_output_dir, 228 native_sysroot, scripts_path, image_output_dir,
228 options.debug, options.properties_file) 229 options.debug, options.properties_file)
229 230
230 231
231def wic_list_subcommand(args, usage_str): 232def wic_list_subcommand(args, usage_str):
@@ -247,7 +248,7 @@ def wic_list_subcommand(args, usage_str):
247 sys.exit(1) 248 sys.exit(1)
248 set_bitbake_env_lines(bitbake_env_lines) 249 set_bitbake_env_lines(bitbake_env_lines)
249 250
250 if not wic_list(args, scripts_path, options.properties_file): 251 if not engine.wic_list(args, scripts_path, options.properties_file):
251 logging.error("Bad list arguments, exiting\n") 252 logging.error("Bad list arguments, exiting\n")
252 parser.print_help() 253 parser.print_help()
253 sys.exit(1) 254 sys.exit(1)
@@ -268,20 +269,20 @@ wic_help_topic_usage = """
268 269
269subcommands = { 270subcommands = {
270 "create": [wic_create_subcommand, 271 "create": [wic_create_subcommand,
271 wic_create_usage, 272 hlp.wic_create_usage,
272 wic_create_help], 273 hlp.wic_create_help],
273 "list": [wic_list_subcommand, 274 "list": [wic_list_subcommand,
274 wic_list_usage, 275 hlp.wic_list_usage,
275 wic_list_help], 276 hlp.wic_list_help],
276 "plugins": [wic_help_topic_subcommand, 277 "plugins": [wic_help_topic_subcommand,
277 wic_help_topic_usage, 278 wic_help_topic_usage,
278 wic_plugins_help], 279 hlp.wic_plugins_help],
279 "overview": [wic_help_topic_subcommand, 280 "overview": [wic_help_topic_subcommand,
280 wic_help_topic_usage, 281 wic_help_topic_usage,
281 wic_overview_help], 282 hlp.wic_overview_help],
282 "kickstart": [wic_help_topic_subcommand, 283 "kickstart": [wic_help_topic_subcommand,
283 wic_help_topic_usage, 284 wic_help_topic_usage,
284 wic_kickstart_help], 285 hlp.wic_kickstart_help],
285} 286}
286 287
287 288
@@ -291,7 +292,7 @@ def start_logging(loglevel):
291 292
292def main(argv): 293def main(argv):
293 parser = optparse.OptionParser(version="wic version %s" % __version__, 294 parser = optparse.OptionParser(version="wic version %s" % __version__,
294 usage=wic_usage) 295 usage=hlp.wic_usage)
295 296
296 parser.disable_interspersed_args() 297 parser.disable_interspersed_args()
297 298
@@ -303,7 +304,7 @@ def main(argv):
303 parser.print_help() 304 parser.print_help()
304 sys.exit(1) 305 sys.exit(1)
305 306
306 invoke_subcommand(args, parser, wic_help_usage, subcommands) 307 hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands)
307 308
308 309
309if __name__ == "__main__": 310if __name__ == "__main__":