From d1166c9415ed8e6a8729bb6b72084f71adf1cd54 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Tue, 22 Jan 2013 12:58:30 +0000 Subject: Python 3 compatibility --- (limited to 'devbot') diff --git a/devbot/build.py b/devbot/build.py index 01638c9..c74df46 100644 --- a/devbot/build.py +++ b/devbot/build.py @@ -40,7 +40,7 @@ def pull(revisions={}, lazy=False): to_pull.append(module) if to_pull: - print "\n= Pulling =\n" + print("\n= Pulling =\n") for module in to_pull: revision = revisions.get(module.name, None) @@ -59,7 +59,7 @@ def build(full=False): if not to_build: return True - print "\n= Building =\n" + print("\n= Building =\n") _ccache_reset() @@ -82,16 +82,16 @@ def distribute(): def clean(): - print "* Emptying install directory" + print("* Emptying install directory") _empty_dir(config.install_dir) - print "* Emptying build directory" + print("* Emptying build directory") _empty_dir(config.get_build_dir()) for module in config.load_modules(): if not module.out_of_source: if git.get_module(module).clean(): - print "* Cleaning %s" % module.name + print("* Cleaning %s" % module.name) def _ccache_reset(): @@ -99,7 +99,7 @@ def _ccache_reset(): def _ccache_print_stats(): - print "\n= ccache statistics =\n" + print("\n= ccache statistics =\n") subprocess.check_call(["ccache", "-s"]) @@ -112,7 +112,7 @@ def _unlink_libtool_files(): def _pull_module(module, revision=None): - print "* Pulling %s" % module.name + print("* Pulling %s" % module.name) git_module = git.get_module(module) @@ -177,7 +177,7 @@ def _distribute_autotools(module): if description != "v%s" % version: match = re.match(r"(v[\d\.]+)", description) if match is None: - print "No version tag was found" + print("No version tag was found") return False else: version_revision = match.groups()[0] @@ -191,13 +191,13 @@ _distributors["autotools"] = _distribute_autotools def _build_module(module, log=None): - print "* Building %s" % module.name + print("* Building %s" % module.name) source_dir = module.get_source_dir() if not os.path.exists(source_dir): - print "Source directory does not exist. Please pull the sources " \ - "before building." + print("Source directory does not exist. Please pull the sources " \ + "before building.") return False if module.out_of_source: @@ -225,13 +225,13 @@ def _build_module(module, log=None): def _distribute_module(module, log=None): - print "\n=== Distribute %s ===\n" % module.name + print("\n=== Distribute %s ===\n" % module.name) build_dir = module.get_build_dir() if not os.path.exists(build_dir): - print "Build directory does not exist. Please build before " \ - "distributing." + print("Build directory does not exist. Please build before " \ + "distributing.") return False os.chdir(build_dir) diff --git a/devbot/check.py b/devbot/check.py index aca4fed..c335ff0 100644 --- a/devbot/check.py +++ b/devbot/check.py @@ -31,7 +31,7 @@ def _check_module(module): result = True if module.has_checks: - print "* Checking %s" % module.name + print("* Checking %s" % module.name) os.chdir(module.get_build_dir()) diff --git a/devbot/clean.py b/devbot/clean.py index 8d0c7a0..c31e058 100644 --- a/devbot/clean.py +++ b/devbot/clean.py @@ -4,7 +4,7 @@ from devbot import state def clean(build_only=False): - print "\n= Clean =\n" + print("\n= Clean =\n") build.clean() state.clean(build_only=build_only) diff --git a/devbot/command.py b/devbot/command.py index b3bd6fc..eb3a3cd 100644 --- a/devbot/command.py +++ b/devbot/command.py @@ -6,7 +6,7 @@ from devbot import config def run(args, test=False, interactive=False, retry=0): if test: - print " ".join(args) + print(" ".join(args)) return log_file = None @@ -23,13 +23,13 @@ def run(args, test=False, interactive=False, retry=0): tries = tries + 1 subprocess.check_call(**subprocess_args) break - except subprocess.CalledProcessError, e: - print "\nCommand failed, tail of %s\n" % config.log_path + except subprocess.CalledProcessError as e: + print("\nCommand failed, tail of %s\n" % config.log_path) if config.log_path: subprocess.call(["tail", config.log_path]) if tries < retry + 1: - print "Retrying (attempt %d) in 1 minute" % tries + print("Retrying (attempt %d) in 1 minute" % tries) time.sleep(60) else: raise e @@ -42,6 +42,6 @@ def run_with_sudo(args, test=False, interactive=False, retry=0): args_with_sudo = ["sudo"] args_with_sudo.extend(args) - print " ".join(args_with_sudo) + print(" ".join(args_with_sudo)) run(args_with_sudo, test=test, retry=retry, interactive=interactive) diff --git a/devbot/config.py b/devbot/config.py index 73cad0c..9a79dcc 100644 --- a/devbot/config.py +++ b/devbot/config.py @@ -55,8 +55,8 @@ class Module: elif os.path.exists(os.path.join(source_dir, "autogen.sh")): return "autotools" else: - print "The source directory has unexpected content, please " \ - "delete it and pull\nthe source again." + print("The source directory has unexpected content, please " \ + "delete it and pull\nthe source again.") return None diff --git a/devbot/distro.py b/devbot/distro.py index 681b014..2d006da 100644 --- a/devbot/distro.py +++ b/devbot/distro.py @@ -21,13 +21,13 @@ def get_package_manager(test=False, interactive=True): def print_distro_info(): info = get_distro_info() - print "\n= Distribution information =\n" - print "Name: %s" % info.name - print "Version: %s" % info.version - print "GNOME version: %s" % info.gnome_version - print "Gstreamer version: %s" % info.gstreamer_version - print "Lib directory: %s" % info.lib_dir - print "Supported: %s\n" % info.supported + print("\n= Distribution information =\n") + print("Name: %s" % info.name) + print("Version: %s" % info.version) + print("GNOME version: %s" % info.gnome_version) + print("Gstreamer version: %s" % info.gstreamer_version) + print("Lib directory: %s" % info.lib_dir) + print("Supported: %s\n" % info.supported) def get_distro_info(): @@ -50,12 +50,12 @@ def get_distro_info(): _distro_info = unknown_distro if not _distro_info.supported: - print "*********************************************************\n" \ + print("*********************************************************\n" \ "You are running an unsupported distribution. You might be\n" \ "able to make sugar work by installing or building \n" \ "packages but it certainly won't work out of the box.\n" \ "You are strongly encouraged to pick one of the supported \n" \ "distributions listed in the README.\n" \ - "*********************************************************\n" + "*********************************************************\n") return _distro_info diff --git a/devbot/logs.py b/devbot/logs.py index e85d21d..e061a00 100644 --- a/devbot/logs.py +++ b/devbot/logs.py @@ -6,7 +6,7 @@ from devbot import config def clean(): - print "* Deleting logs" + print("* Deleting logs") try: for filename in os.listdir(config.logs_dir): diff --git a/devbot/plugins/debian.py b/devbot/plugins/debian.py index 437846d..9598a57 100644 --- a/devbot/plugins/debian.py +++ b/devbot/plugins/debian.py @@ -56,12 +56,12 @@ class PackageManager(interfaces.PackageManager): return if package not in self._cache: - print "Package %s not in cache" % package + print("Package %s not in cache" % package) return installed = self._cache[package].installed if installed is None: - print "Package %s not installed" % package + print("Package %s not installed" % package) return for dependency in installed.dependencies: diff --git a/devbot/plugins/fedora.py b/devbot/plugins/fedora.py index d1a2936..bb10357 100644 --- a/devbot/plugins/fedora.py +++ b/devbot/plugins/fedora.py @@ -63,7 +63,7 @@ class PackageManager(interfaces.PackageManager): query_format, package]).strip() except subprocess.CalledProcessError: - print "Package %s not installed" % package + print("Package %s not installed" % package) return filtered = [cap for cap in capabilities.split(" ") diff --git a/devbot/run.py b/devbot/run.py index 076217b..95a0510 100644 --- a/devbot/run.py +++ b/devbot/run.py @@ -45,4 +45,4 @@ def collect_logs(source_path): def _get_random_id(): - return ''.join(random.choice(string.letters) for i in xrange(8)) + return ''.join(random.choice(string.letters) for i in range(8)) diff --git a/devbot/state.py b/devbot/state.py index f3cce7a..0a6f7b9 100644 --- a/devbot/state.py +++ b/devbot/state.py @@ -67,7 +67,7 @@ def full_build_touch(): def clean(build_only=False): - print "* Deleting state" + print("* Deleting state") names = [_BUILT_MODULES, _FULL_BUILD] if not build_only: diff --git a/devbot/system.py b/devbot/system.py index dc2ac42..6d51ecc 100644 --- a/devbot/system.py +++ b/devbot/system.py @@ -34,7 +34,7 @@ def check(remove=False, update=False, test=False, interactive=True, xvfb.stop(xvfb_proc, orig_display) - print "All the required dependencies are installed." + print("All the required dependencies are installed.") if update: package_manager.update() @@ -126,7 +126,7 @@ _checkers["gstreamer-1.0"] = _check_gstreamer_1_0 def _print_checks(checks): for check in checks: - print "[%s] %s" % (check["checker"], check["check"]) + print("[%s] %s" % (check["checker"], check["check"])) def _eval_check_if(check): @@ -136,7 +136,7 @@ def _eval_check_if(check): distro_info = distro.get_distro_info() globals = {"distro": "%s-%s" % (distro_info.name, distro_info.version)} - print eval(check["check_if"], globals) + print(eval(check["check_if"], globals)) return eval(check["check_if"], globals) == "True" @@ -168,19 +168,19 @@ def _run_checks(package_manager, checks, packages): if distro_info.supported: if packages_not_found: - print "\nPackages not found for" + print("\nPackages not found for") _print_checks(packages_not_found) return False if to_install: package_manager.install_packages(to_install) elif failed_checks: - print "Failed checks\n" + print("Failed checks\n") _print_checks(failed_checks) if to_install: - print "\nYou might try to install the following packages\n" - print " ".join(to_install) + print("\nYou might try to install the following packages\n") + print(" ".join(to_install)) return False -- cgit v0.9.1