summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-05-04 16:06:14 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-14 23:05:13 +0100
commit0c57dd96c85612e2c616966ae21fcbbb11bdc066 (patch)
tree4895dd1b43faf418375d4fdf2d91745ac34d302f
parent4dadbbdd46195fc60cd91f589102bca31cea3c2e (diff)
downloadpoky-0c57dd96c85612e2c616966ae21fcbbb11bdc066.tar.gz
wic: replace print statements with print function
Print statements have been replaced with print function in Python 3. Replaced them in wic code to be able to run it under both Python 2 and Python 3. [YOCTO #9412] (From OE-Core rev: ee6979a19c77931c3cf6368e695e370d46192fef) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/wic/engine.py20
-rw-r--r--scripts/lib/wic/help.py2
-rw-r--r--scripts/lib/wic/utils/oe/misc.py8
-rwxr-xr-xscripts/wic43
4 files changed, 37 insertions, 36 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index 76b93e82f2..5d35c46b32 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -44,7 +44,7 @@ def verify_build_env():
44 Returns True if it is, false otherwise 44 Returns True if it is, false otherwise
45 """ 45 """
46 if not os.environ.get("BUILDDIR"): 46 if not os.environ.get("BUILDDIR"):
47 print "BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)" 47 print("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)")
48 sys.exit(1) 48 sys.exit(1)
49 49
50 return True 50 return True
@@ -107,7 +107,7 @@ def list_canned_images(scripts_path):
107 desc = line[idx + len("short-description:"):].strip() 107 desc = line[idx + len("short-description:"):].strip()
108 break 108 break
109 basename = os.path.splitext(fname)[0] 109 basename = os.path.splitext(fname)[0]
110 print " %s\t\t%s" % (basename.ljust(30), desc) 110 print(" %s\t\t%s" % (basename.ljust(30), desc))
111 111
112 112
113def list_canned_image_help(scripts_path, fullpath): 113def list_canned_image_help(scripts_path, fullpath):
@@ -120,15 +120,15 @@ def list_canned_image_help(scripts_path, fullpath):
120 if not found: 120 if not found:
121 idx = line.find("long-description:") 121 idx = line.find("long-description:")
122 if idx != -1: 122 if idx != -1:
123 print 123 print()
124 print line[idx + len("long-description:"):].strip() 124 print(line[idx + len("long-description:"):].strip())
125 found = True 125 found = True
126 continue 126 continue
127 if not line.strip(): 127 if not line.strip():
128 break 128 break
129 idx = line.find("#") 129 idx = line.find("#")
130 if idx != -1: 130 if idx != -1:
131 print line[idx + len("#:"):].rstrip() 131 print(line[idx + len("#:"):].rstrip())
132 else: 132 else:
133 break 133 break
134 134
@@ -140,7 +140,7 @@ def list_source_plugins():
140 plugins = pluginmgr.get_source_plugins() 140 plugins = pluginmgr.get_source_plugins()
141 141
142 for plugin in plugins: 142 for plugin in plugins:
143 print " %s" % plugin 143 print(" %s" % plugin)
144 144
145 145
146def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, 146def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir,
@@ -178,7 +178,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir,
178 try: 178 try:
179 oe_builddir = os.environ["BUILDDIR"] 179 oe_builddir = os.environ["BUILDDIR"]
180 except KeyError: 180 except KeyError:
181 print "BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)" 181 print("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)")
182 sys.exit(1) 182 sys.exit(1)
183 183
184 if debug: 184 if debug:
@@ -189,7 +189,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir,
189 crobj.main(["direct", native_sysroot, kernel_dir, bootimg_dir, rootfs_dir, 189 crobj.main(["direct", native_sysroot, kernel_dir, bootimg_dir, rootfs_dir,
190 wks_file, image_output_dir, oe_builddir, compressor or ""]) 190 wks_file, image_output_dir, oe_builddir, compressor or ""])
191 191
192 print "\nThe image(s) were created using OE kickstart file:\n %s" % wks_file 192 print("\nThe image(s) were created using OE kickstart file:\n %s" % wks_file)
193 193
194 194
195def wic_list(args, scripts_path): 195def wic_list(args, scripts_path):
@@ -209,10 +209,10 @@ def wic_list(args, scripts_path):
209 wks_file = args[0] 209 wks_file = args[0]
210 fullpath = find_canned_image(scripts_path, wks_file) 210 fullpath = find_canned_image(scripts_path, wks_file)
211 if not fullpath: 211 if not fullpath:
212 print "No image named %s found, exiting. "\ 212 print("No image named %s found, exiting. "\
213 "(Use 'wic list images' to list available images, or "\ 213 "(Use 'wic list images' to list available images, or "\
214 "specify a fully-qualified OE kickstart (.wks) "\ 214 "specify a fully-qualified OE kickstart (.wks) "\
215 "filename)\n" % wks_file 215 "filename)\n" % wks_file)
216 sys.exit(1) 216 sys.exit(1)
217 list_canned_image_help(scripts_path, fullpath) 217 list_canned_image_help(scripts_path, fullpath)
218 return True 218 return True
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index 394e3fde2d..158b6c1ae0 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -55,7 +55,7 @@ def wic_help(args, usage_str, subcommands):
55 Subcommand help dispatcher. 55 Subcommand help dispatcher.
56 """ 56 """
57 if len(args) == 1 or not display_help(args[1], subcommands): 57 if len(args) == 1 or not display_help(args[1], subcommands):
58 print usage_str 58 print(usage_str)
59 59
60 60
61def get_wic_plugins_help(): 61def get_wic_plugins_help():
diff --git a/scripts/lib/wic/utils/oe/misc.py b/scripts/lib/wic/utils/oe/misc.py
index a3cbe5f1e2..11209be58e 100644
--- a/scripts/lib/wic/utils/oe/misc.py
+++ b/scripts/lib/wic/utils/oe/misc.py
@@ -187,8 +187,8 @@ class BitbakeVars(defaultdict):
187 for line in varsfile: 187 for line in varsfile:
188 self._parse_line(line, image) 188 self._parse_line(line, image)
189 else: 189 else:
190 print "Couldn't get bitbake variable from %s." % fname 190 print("Couldn't get bitbake variable from %s." % fname)
191 print "File %s doesn't exist." % fname 191 print("File %s doesn't exist." % fname)
192 return 192 return
193 else: 193 else:
194 # Get bitbake -e output 194 # Get bitbake -e output
@@ -202,8 +202,8 @@ class BitbakeVars(defaultdict):
202 msger.set_loglevel(log_level) 202 msger.set_loglevel(log_level)
203 203
204 if ret: 204 if ret:
205 print "Couldn't get '%s' output." % cmd 205 print("Couldn't get '%s' output." % cmd)
206 print "Bitbake failed with error:\n%s\n" % lines 206 print("Bitbake failed with error:\n%s\n" % lines)
207 return 207 return
208 208
209 # Parse bitbake -e output 209 # Parse bitbake -e output
diff --git a/scripts/wic b/scripts/wic
index 2286f20a96..11c8316b97 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -28,6 +28,7 @@
28# AUTHORS 28# AUTHORS
29# Tom Zanussi <tom.zanussi (at] linux.intel.com> 29# Tom Zanussi <tom.zanussi (at] linux.intel.com>
30# 30#
31from __future__ import print_function
31 32
32__version__ = "0.2.0" 33__version__ = "0.2.0"
33 34
@@ -140,8 +141,8 @@ def wic_create_subcommand(args, usage_str):
140 if not val: 141 if not val:
141 missed.append(opt) 142 missed.append(opt)
142 if missed: 143 if missed:
143 print "The following build artifacts are not specified:" 144 print("The following build artifacts are not specified:")
144 print " " + ", ".join(missed) 145 print(" " + ", ".join(missed))
145 sys.exit(1) 146 sys.exit(1)
146 147
147 if options.image_name: 148 if options.image_name:
@@ -153,12 +154,12 @@ def wic_create_subcommand(args, usage_str):
153 BB_VARS.vars_dir = options.vars_dir 154 BB_VARS.vars_dir = options.vars_dir
154 155
155 if options.build_check: 156 if options.build_check:
156 print "Checking basic build environment..." 157 print("Checking basic build environment...")
157 if not engine.verify_build_env(): 158 if not engine.verify_build_env():
158 print "Couldn't verify build environment, exiting\n" 159 print("Couldn't verify build environment, exiting\n")
159 sys.exit(1) 160 sys.exit(1)
160 else: 161 else:
161 print "Done.\n" 162 print("Done.\n")
162 163
163 bootimg_dir = "" 164 bootimg_dir = ""
164 165
@@ -168,7 +169,7 @@ def wic_create_subcommand(args, usage_str):
168 if options.debug: 169 if options.debug:
169 argv.append("--debug") 170 argv.append("--debug")
170 171
171 print "Building rootfs...\n" 172 print("Building rootfs...\n")
172 if bitbake_main(BitBakeConfigParameters(argv), 173 if bitbake_main(BitBakeConfigParameters(argv),
173 cookerdata.CookerConfiguration()): 174 cookerdata.CookerConfiguration()):
174 sys.exit(1) 175 sys.exit(1)
@@ -179,7 +180,7 @@ def wic_create_subcommand(args, usage_str):
179 options.image_name) 180 options.image_name)
180 else: 181 else:
181 if options.build_rootfs: 182 if options.build_rootfs:
182 print "Image name is not specified, exiting. (Use -e/--image-name to specify it)\n" 183 print("Image name is not specified, exiting. (Use -e/--image-name to specify it)\n")
183 sys.exit(1) 184 sys.exit(1)
184 185
185 wks_file = args[0] 186 wks_file = args[0]
@@ -187,9 +188,9 @@ def wic_create_subcommand(args, usage_str):
187 if not wks_file.endswith(".wks"): 188 if not wks_file.endswith(".wks"):
188 wks_file = engine.find_canned_image(scripts_path, wks_file) 189 wks_file = engine.find_canned_image(scripts_path, wks_file)
189 if not wks_file: 190 if not wks_file:
190 print "No image named %s found, exiting. (Use 'wic list images' "\ 191 print("No image named %s found, exiting. (Use 'wic list images' "\
191 "to list available images, or specify a fully-qualified OE "\ 192 "to list available images, or specify a fully-qualified OE "\
192 "kickstart (.wks) filename)\n" % args[0] 193 "kickstart (.wks) filename)\n" % args[0])
193 sys.exit(1) 194 sys.exit(1)
194 195
195 image_output_dir = "" 196 image_output_dir = ""
@@ -204,16 +205,16 @@ def wic_create_subcommand(args, usage_str):
204 kernel_dir = options.kernel_dir 205 kernel_dir = options.kernel_dir
205 native_sysroot = options.native_sysroot 206 native_sysroot = options.native_sysroot
206 if rootfs_dir and not os.path.isdir(rootfs_dir): 207 if rootfs_dir and not os.path.isdir(rootfs_dir):
207 print "--roofs-dir (-r) not found, exiting\n" 208 print("--roofs-dir (-r) not found, exiting\n")
208 sys.exit(1) 209 sys.exit(1)
209 if not os.path.isdir(bootimg_dir): 210 if not os.path.isdir(bootimg_dir):
210 print "--bootimg-dir (-b) not found, exiting\n" 211 print("--bootimg-dir (-b) not found, exiting\n")
211 sys.exit(1) 212 sys.exit(1)
212 if not os.path.isdir(kernel_dir): 213 if not os.path.isdir(kernel_dir):
213 print "--kernel-dir (-k) not found, exiting\n" 214 print("--kernel-dir (-k) not found, exiting\n")
214 sys.exit(1) 215 sys.exit(1)
215 if not os.path.isdir(native_sysroot): 216 if not os.path.isdir(native_sysroot):
216 print "--native-sysroot (-n) not found, exiting\n" 217 print("--native-sysroot (-n) not found, exiting\n")
217 sys.exit(1) 218 sys.exit(1)
218 else: 219 else:
219 not_found = not_found_dir = "" 220 not_found = not_found_dir = ""
@@ -226,12 +227,12 @@ def wic_create_subcommand(args, usage_str):
226 if not_found: 227 if not_found:
227 if not not_found_dir: 228 if not not_found_dir:
228 not_found_dir = "Completely missing artifact - wrong image (.wks) used?" 229 not_found_dir = "Completely missing artifact - wrong image (.wks) used?"
229 print "Build artifacts not found, exiting." 230 print("Build artifacts not found, exiting.")
230 print " (Please check that the build artifacts for the machine" 231 print(" (Please check that the build artifacts for the machine")
231 print " selected in local.conf actually exist and that they" 232 print(" selected in local.conf actually exist and that they")
232 print " are the correct artifacts for the image (.wks file)).\n" 233 print(" are the correct artifacts for the image (.wks file)).\n")
233 print "The artifact that couldn't be found was %s:\n %s" % \ 234 print("The artifact that couldn't be found was %s:\n %s" % \
234 (not_found, not_found_dir) 235 (not_found, not_found_dir))
235 sys.exit(1) 236 sys.exit(1)
236 237
237 krootfs_dir = options.rootfs_dir 238 krootfs_dir = options.rootfs_dir
@@ -241,7 +242,7 @@ def wic_create_subcommand(args, usage_str):
241 242
242 rootfs_dir = rootfs_dir_to_args(krootfs_dir) 243 rootfs_dir = rootfs_dir_to_args(krootfs_dir)
243 244
244 print "Creating image(s)...\n" 245 print("Creating image(s)...\n")
245 engine.wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, 246 engine.wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir,
246 native_sysroot, scripts_path, image_output_dir, 247 native_sysroot, scripts_path, image_output_dir,
247 options.compressor, options.debug) 248 options.compressor, options.debug)
@@ -318,6 +319,6 @@ if __name__ == "__main__":
318 try: 319 try:
319 sys.exit(main(sys.argv[1:])) 320 sys.exit(main(sys.argv[1:]))
320 except WicError as err: 321 except WicError as err:
321 print >> sys.stderr, "ERROR:", err 322 print("ERROR:", err, file=sys.stderr)
322 sys.exit(1) 323 sys.exit(1)
323 324