From 0c57dd96c85612e2c616966ae21fcbbb11bdc066 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Wed, 4 May 2016 16:06:14 +0300 Subject: 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 Signed-off-by: Richard Purdie --- scripts/lib/wic/engine.py | 20 ++++++++++---------- scripts/lib/wic/help.py | 2 +- scripts/lib/wic/utils/oe/misc.py | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'scripts/lib') 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(): Returns True if it is, false otherwise """ if not os.environ.get("BUILDDIR"): - print "BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)" + print("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)") sys.exit(1) return True @@ -107,7 +107,7 @@ def list_canned_images(scripts_path): desc = line[idx + len("short-description:"):].strip() break basename = os.path.splitext(fname)[0] - print " %s\t\t%s" % (basename.ljust(30), desc) + print(" %s\t\t%s" % (basename.ljust(30), desc)) def list_canned_image_help(scripts_path, fullpath): @@ -120,15 +120,15 @@ def list_canned_image_help(scripts_path, fullpath): if not found: idx = line.find("long-description:") if idx != -1: - print - print line[idx + len("long-description:"):].strip() + print() + print(line[idx + len("long-description:"):].strip()) found = True continue if not line.strip(): break idx = line.find("#") if idx != -1: - print line[idx + len("#:"):].rstrip() + print(line[idx + len("#:"):].rstrip()) else: break @@ -140,7 +140,7 @@ def list_source_plugins(): plugins = pluginmgr.get_source_plugins() for plugin in plugins: - print " %s" % plugin + print(" %s" % plugin) def 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, try: oe_builddir = os.environ["BUILDDIR"] except KeyError: - print "BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)" + print("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)") sys.exit(1) if debug: @@ -189,7 +189,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, crobj.main(["direct", native_sysroot, kernel_dir, bootimg_dir, rootfs_dir, wks_file, image_output_dir, oe_builddir, compressor or ""]) - print "\nThe image(s) were created using OE kickstart file:\n %s" % wks_file + print("\nThe image(s) were created using OE kickstart file:\n %s" % wks_file) def wic_list(args, scripts_path): @@ -209,10 +209,10 @@ def wic_list(args, scripts_path): wks_file = args[0] fullpath = find_canned_image(scripts_path, wks_file) if not fullpath: - print "No image named %s found, exiting. "\ + 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 + "filename)\n" % wks_file) sys.exit(1) list_canned_image_help(scripts_path, fullpath) 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): Subcommand help dispatcher. """ if len(args) == 1 or not display_help(args[1], subcommands): - print usage_str + print(usage_str) def 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): for line in varsfile: self._parse_line(line, image) else: - print "Couldn't get bitbake variable from %s." % fname - print "File %s doesn't exist." % fname + print("Couldn't get bitbake variable from %s." % fname) + print("File %s doesn't exist." % fname) return else: # Get bitbake -e output @@ -202,8 +202,8 @@ class BitbakeVars(defaultdict): msger.set_loglevel(log_level) if ret: - print "Couldn't get '%s' output." % cmd - print "Bitbake failed with error:\n%s\n" % lines + print("Couldn't get '%s' output." % cmd) + print("Bitbake failed with error:\n%s\n" % lines) return # Parse bitbake -e output -- cgit v1.2.3-54-g00ecf