From dcfef841a7255c59fce19d98f92fff129af19df6 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 21 May 2018 23:58:19 +0200 Subject: [PATCH] bug 1463425 - Fix flake8/pep8 issue by hand in build/ r=gps MozReview-Commit-ID: AZdcEWyVV6e --HG-- extra : rebase_source : b1c45028c8d46be5ba590a27a2f9f20e248a26b1 --- build/build-clang/build-clang.py | 2 +- build/clang-plugin/ThirdPartyPaths.py | 1 + build/clang-plugin/import_mozilla_checks.py | 9 ++- build/compare-mozconfig/compare-mozconfigs.py | 10 ++- build/mobile/remoteautomation.py | 66 ++++++++++--------- build/pgo/genpgocert.py | 26 ++++---- build/pgo/profileserver.py | 7 +- build/unix/rewrite_asan_dylib.py | 8 ++- build/util/count_ctors.py | 3 +- build/valgrind/mach_commands.py | 15 ++--- build/valgrind/output_handler.py | 2 +- build/win32/autobinscope.py | 26 ++++---- 12 files changed, 95 insertions(+), 80 deletions(-) diff --git a/build/build-clang/build-clang.py b/build/build-clang/build-clang.py index f85d73ea7411..716f17874e51 100755 --- a/build/build-clang/build-clang.py +++ b/build/build-clang/build-clang.py @@ -107,7 +107,7 @@ def delete(path): else: try: os.unlink(path) - except: + except Exception: pass diff --git a/build/clang-plugin/ThirdPartyPaths.py b/build/clang-plugin/ThirdPartyPaths.py index 1124e540ae43..83611a5007f5 100644 --- a/build/clang-plugin/ThirdPartyPaths.py +++ b/build/clang-plugin/ThirdPartyPaths.py @@ -2,6 +2,7 @@ import json + def generate(output, tpp_txt): """ This file generates a ThirdPartyPaths.cpp file from the ThirdPartyPaths.txt diff --git a/build/clang-plugin/import_mozilla_checks.py b/build/clang-plugin/import_mozilla_checks.py index f400d6fb8cd1..c755fbc78c28 100755 --- a/build/clang-plugin/import_mozilla_checks.py +++ b/build/clang-plugin/import_mozilla_checks.py @@ -4,7 +4,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. import os -import re import sys import glob import shutil @@ -129,20 +128,20 @@ static int LLVM_ATTRIBUTE_UNUSED MozillaModuleAnchorDestination = def main(): if len(sys.argv) != 3: - print """\ + print("""\ Usage: import_mozilla_checks.py Imports the Mozilla static analysis checks into a clang-tidy source tree. -""" +""") return mozilla_path = sys.argv[1] if not os.path.isdir(mozilla_path): - print "Invalid path to mozilla clang plugin" + print("Invalid path to mozilla clang plugin") clang_tidy_path = sys.argv[2] if not os.path.isdir(mozilla_path): - print "Invalid path to clang-tidy source directory" + print("Invalid path to clang-tidy source directory") do_import(mozilla_path, clang_tidy_path) diff --git a/build/compare-mozconfig/compare-mozconfigs.py b/build/compare-mozconfig/compare-mozconfigs.py index 43b7d1f5504d..c6ef7fcc07c2 100644 --- a/build/compare-mozconfig/compare-mozconfigs.py +++ b/build/compare-mozconfig/compare-mozconfigs.py @@ -3,7 +3,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -# originally from https://hg.mozilla.org/build/tools/file/4ab9c1a4e05b/scripts/release/compare-mozconfigs.py +# originally from https://hg.mozilla.org/build/tools/file/4ab9c1a4e05b/scripts/release/compare-mozconfigs.py # NOQA: E501 from __future__ import unicode_literals @@ -28,14 +28,17 @@ PLATFORMS = ( log = logging.getLogger(__name__) + class ConfigError(Exception): pass + def readConfig(configfile): c = {} execfile(configfile, c) return c['whitelist'] + def verify_mozconfigs(mozconfig_pair, nightly_mozconfig_pair, platform, mozconfigWhitelist): """Compares mozconfig to nightly_mozconfig and compare to an optional @@ -55,7 +58,8 @@ def verify_mozconfigs(mozconfig_pair, nightly_mozconfig_pair, platform, success = True diff_instance = difflib.Differ() - diff_result = diff_instance.compare(mozconfig_lines, nightly_mozconfig_lines) + diff_result = diff_instance.compare( + mozconfig_lines, nightly_mozconfig_lines) diff_list = list(diff_result) for line in diff_list: @@ -98,6 +102,7 @@ def verify_mozconfigs(mozconfig_pair, nightly_mozconfig_pair, platform, success = False return success + def get_mozconfig(path): """Consumes a path and returns a list of lines from the mozconfig file.""" with open(path, 'rb') as fh: @@ -114,7 +119,6 @@ def compare(topsrcdir): def normalize_lines(lines): return {l.strip() for l in lines} - for platform in PLATFORMS: log.info('Comparing platform %s' % platform) diff --git a/build/mobile/remoteautomation.py b/build/mobile/remoteautomation.py index 39687b794bff..45671048aa24 100644 --- a/build/mobile/remoteautomation.py +++ b/build/mobile/remoteautomation.py @@ -37,7 +37,8 @@ class RemoteAutomation(Automation): Automation.__init__(self) # Set up what we need for the remote environment - def environment(self, env=None, xrePath=None, crashreporter=True, debugger=False, lsanPath=None, ubsanPath=None): + def environment(self, env=None, xrePath=None, crashreporter=True, debugger=False, + lsanPath=None, ubsanPath=None): # Because we are running remote, we don't want to mimic the local env # so no copying of os.environ if env is None: @@ -66,14 +67,15 @@ class RemoteAutomation(Automation): # Set WebRTC logging in case it is not set yet. # On Android, environment variables cannot contain ',' so the # standard WebRTC setting for NSPR_LOG_MODULES is not available. - # env.setdefault('NSPR_LOG_MODULES', 'signaling:5,mtransport:5,datachannel:5,jsep:5,MediaPipelineFactory:5') + # env.setdefault('NSPR_LOG_MODULES', 'signaling:5,mtransport:5,datachannel:5,jsep:5,MediaPipelineFactory:5') # NOQA: E501 env.setdefault('R_LOG_LEVEL', '6') env.setdefault('R_LOG_DESTINATION', 'stderr') env.setdefault('R_LOG_VERBOSE', '1') return env - def waitForFinish(self, proc, utilityPath, timeout, maxTime, startTime, debuggerInfo, symbolsPath, outputHandler=None): + def waitForFinish(self, proc, utilityPath, timeout, maxTime, startTime, debuggerInfo, + symbolsPath, outputHandler=None): """ Wait for tests to finish. If maxTime seconds elapse or no output is detected for timeout seconds, kill the process and fail the test. @@ -85,19 +87,20 @@ class RemoteAutomation(Automation): topActivity = self._device.get_top_activity(timeout=60) if topActivity == proc.procName: - print "Browser unexpectedly found running. Killing..." + print("Browser unexpectedly found running. Killing...") proc.kill(True) if status == 1: if maxTime: - print "TEST-UNEXPECTED-FAIL | %s | application ran for longer than " \ + print("TEST-UNEXPECTED-FAIL | %s | application ran for longer than " "allowed maximum time of %s seconds" % ( - self.lastTestSeen, maxTime) + self.lastTestSeen, maxTime)) else: - print "TEST-UNEXPECTED-FAIL | %s | application ran for longer than " \ - "allowed maximum time" % (self.lastTestSeen) + print("TEST-UNEXPECTED-FAIL | %s | application ran for longer than " + "allowed maximum time" % (self.lastTestSeen)) if status == 2: - print "TEST-UNEXPECTED-FAIL | %s | application timed out after %d seconds with no output" \ - % (self.lastTestSeen, int(timeout)) + print("TEST-UNEXPECTED-FAIL | %s | application timed out after %d seconds with" + "no output" + % (self.lastTestSeen, int(timeout))) return status @@ -109,7 +112,7 @@ class RemoteAutomation(Automation): self._device.shell_output('echo > %s' % traces, root=True) self._device.shell_output('chmod 666 %s' % traces, root=True) except Exception as e: - print "Error deleting %s: %s" % (traces, str(e)) + print("Error deleting %s: %s" % (traces, str(e))) def checkForANRs(self): traces = "/data/anr/traces.txt" @@ -119,14 +122,14 @@ class RemoteAutomation(Automation): if t: stripped = t.strip() if len(stripped) > 0: - print "Contents of %s:" % traces - print t + print("Contents of %s:" % traces) + print(t) # Once reported, delete traces self.deleteANRs() except Exception as e: - print "Error pulling %s: %s" % (traces, str(e)) + print("Error pulling %s: %s" % (traces, str(e))) else: - print "%s not found" % traces + print("%s not found" % traces) def deleteTombstones(self): # delete any tombstone files from device @@ -155,9 +158,9 @@ class RemoteAutomation(Automation): os.rename(f, newname) break else: - print "%s does not exist; tombstone check skipped" % remoteDir + print("%s does not exist; tombstone check skipped" % remoteDir) else: - print "MOZ_UPLOAD_DIR not defined; tombstone check skipped" + print("MOZ_UPLOAD_DIR not defined; tombstone check skipped") def checkForCrashes(self, directory, symbolsPath): self.checkForANRs() @@ -184,7 +187,8 @@ class RemoteAutomation(Automation): # minidumps directory is automatically created when Fennec # (first) starts, so its lack of presence is a hint that # something went wrong. - print "Automation Error: No crash directory (%s) found on remote device" % remoteCrashDir + print("Automation Error: No crash directory (%s) found on remote device" % + remoteCrashDir) return True self._device.pull(remoteCrashDir, dumpDir) @@ -196,8 +200,8 @@ class RemoteAutomation(Automation): try: shutil.rmtree(dumpDir) except Exception as e: - print "WARNING: unable to remove directory %s: %s" % ( - dumpDir, str(e)) + print("WARNING: unable to remove directory %s: %s" % ( + dumpDir, str(e))) return crashed def buildCommandLine(self, app, debuggerInfo, profileDir, testURL, extraArgs): @@ -214,7 +218,7 @@ class RemoteAutomation(Automation): self, app, debuggerInfo, profileDir, testURL, extraArgs) try: args.remove('-foreground') - except: + except Exception: pass return app, args @@ -243,7 +247,7 @@ class RemoteAutomation(Automation): cmd = ' '.join(cmd) self.procName = app if not self.device.shell_bool(cmd): - print "remote_automation.py failed to launch %s" % cmd + print("remote_automation.py failed to launch %s" % cmd) else: args = cmd if args[0] == app: @@ -302,7 +306,7 @@ class RemoteAutomation(Automation): r"TEST-START \| ([^\s]*)", newLogContent) if testStartFilenames: self.lastTestSeen = testStartFilenames[-1] - print newLogContent + print(newLogContent) return True self.logBuffer += newLogContent @@ -340,7 +344,7 @@ class RemoteAutomation(Automation): self.counts['fail'] += val elif "Todo:" in line: self.counts['todo'] += val - except: + except Exception: pass return True @@ -359,7 +363,7 @@ class RemoteAutomation(Automation): timer = 0 noOutputTimer = 0 interval = 10 - if timeout == None: + if timeout is None: timeout = self.timeout status = 0 top = self.procName @@ -390,7 +394,7 @@ class RemoteAutomation(Automation): if not hasOutput: top = self.device.get_top_activity(timeout=60) if top is None: - print "Failed to get top activity, retrying, once..." + print("Failed to get top activity, retrying, once...") top = self.device.get_top_activity(timeout=60) # Flush anything added to stdout during the sleep self.read_stdout() @@ -408,27 +412,27 @@ class RemoteAutomation(Automation): # Trigger an ANR report with "kill -3" (SIGQUIT) try: self.device.pkill(self.procName, sig=3, attempts=1) - except: + except: # NOQA: E722 pass time.sleep(3) # Trigger a breakpad dump with "kill -6" (SIGABRT) try: self.device.pkill(self.procName, sig=6, attempts=1) - except: + except: # NOQA: E722 pass # Wait for process to end retries = 0 while retries < 3: if self.device.process_exist(self.procName): - print "%s still alive after SIGABRT: waiting..." % self.procName + print("%s still alive after SIGABRT: waiting..." % self.procName) time.sleep(5) else: return retries += 1 try: self.device.pkill(self.procName, sig=9, attempts=1) - except: - print "%s still alive after SIGKILL!" % self.procName + except: # NOQA: E722 + print("%s still alive after SIGKILL!" % self.procName) if self.device.process_exist(self.procName): self.device.stop_application(self.procName) else: diff --git a/build/pgo/genpgocert.py b/build/pgo/genpgocert.py index 5f881b3991b4..173c6cf144fc 100644 --- a/build/pgo/genpgocert.py +++ b/build/pgo/genpgocert.py @@ -14,7 +14,6 @@ import re import shutil import subprocess import sys -import tempfile import distutils from mozbuild.base import MozbuildObject @@ -81,7 +80,7 @@ def writeCertspecForServerLocations(fd): if not customCertOption: SAN.append(loc.host) - fd.write("issuer:printableString/CN=Temporary Certificate Authority/O=Mozilla Testing/OU=Profile Guided Optimization\n") + fd.write("issuer:printableString/CN=Temporary Certificate Authority/O=Mozilla Testing/OU=Profile Guided Optimization\n") # NOQA: E501 fd.write("subject:{}\n".format(SAN[0])) fd.write("extension:subjectAlternativeName:{}\n".format(",".join(SAN))) @@ -95,9 +94,7 @@ def constructCertDatabase(build, srcDir): pykey = os.path.join(build.topsrcdir, "security", "manager", "ssl", "tests", "unit", "pykey.py") - with NamedTemporaryFile() as pwfile, NamedTemporaryFile() as rndfile, TemporaryDirectory() as pemfolder: - pgoCAPath = os.path.join(srcDir, "pgoca.p12") - + with NamedTemporaryFile() as pwfile, TemporaryDirectory() as pemfolder: pwfile.write("\n") pwfile.flush() @@ -136,7 +133,9 @@ def constructCertDatabase(build, srcDir): return status status = runUtil(certutil, [ - "-A", "-n", name, "-t", "P,,", "-i", pem, "-d", srcDir, "-f", pwfile.name]) + "-A", "-n", name, "-t", "P,,", "-i", pem, + "-d", srcDir, "-f", pwfile.name + ]) if status: return status @@ -145,8 +144,9 @@ def constructCertDatabase(build, srcDir): name = parts[0] key_type = parts[1] if key_type not in ["ca", "client", "server"]: - raise Exception("{}: keyspec filenames must be of the form XXX.client.keyspec or XXX.ca.keyspec (key_type={})".format( - keyspec, key_type)) + raise Exception("{}: keyspec filenames must be of the form XXX.client.keyspec " + "or XXX.ca.keyspec (key_type={})".format( + keyspec, key_type)) key_pem = os.path.join(pemfolder, "{}.key.pem".format(name)) print("Generating private key {} (pem={})".format(name, key_pem)) @@ -161,14 +161,16 @@ def constructCertDatabase(build, srcDir): cert_pem = os.path.join(pemfolder, "{}.cert.pem".format(name)) if not os.path.exists(cert_pem): - raise Exception("There has to be a corresponding certificate named {} for the keyspec {}".format( - cert_pem, keyspec)) + raise Exception("There has to be a corresponding certificate named {} for " + "the keyspec {}".format( + cert_pem, keyspec)) p12 = os.path.join(pemfolder, "{}.key.p12".format(name)) print("Converting private key {} to PKCS12 (p12={})".format( key_pem, p12)) status = runUtil(openssl, ["pkcs12", "-export", "-inkey", key_pem, "-in", - cert_pem, "-name", name, "-out", p12, "-passout", "file:"+pwfile.name]) + cert_pem, "-name", name, "-out", p12, "-passout", + "file:"+pwfile.name]) if status: return status @@ -197,5 +199,5 @@ build = MozbuildObject.from_environment() certdir = os.path.join(build.topsrcdir, "build", "pgo", "certs") certificateStatus = constructCertDatabase(build, certdir) if certificateStatus: - print "TEST-UNEXPECTED-FAIL | SSL Server Certificate generation" + print("TEST-UNEXPECTED-FAIL | SSL Server Certificate generation") sys.exit(certificateStatus) diff --git a/build/pgo/profileserver.py b/build/pgo/profileserver.py index 15ed80089000..e76afc85adb7 100755 --- a/build/pgo/profileserver.py +++ b/build/pgo/profileserver.py @@ -11,7 +11,7 @@ from buildconfig import substs from mozbuild.base import MozbuildObject from mozfile import TemporaryDirectory from mozhttpd import MozHttpd -from mozprofile import FirefoxProfile, Profile, Preferences +from mozprofile import FirefoxProfile, Preferences from mozprofile.permissions import ServerLocations from mozrunner import FirefoxRunner, CLI from six import string_types @@ -66,7 +66,8 @@ if __name__ == '__main__': profile = FirefoxProfile(profile=profilePath, preferences=prefs, addons=[os.path.join( - build.topsrcdir, 'tools', 'quitter', 'quitter@mozilla.org.xpi')], + build.topsrcdir, 'tools', 'quitter', + 'quitter@mozilla.org.xpi')], locations=locations) env = os.environ.copy() @@ -96,7 +97,7 @@ if __name__ == '__main__': jarlog = os.getenv("JARLOG_FILE") if jarlog: env["MOZ_JAR_LOG_FILE"] = os.path.abspath(jarlog) - print "jarlog: %s" % env["MOZ_JAR_LOG_FILE"] + print("jarlog: %s" % env["MOZ_JAR_LOG_FILE"]) cmdargs = ["http://localhost:%d/index.html" % PORT] runner = FirefoxRunner(profile=profile, diff --git a/build/unix/rewrite_asan_dylib.py b/build/unix/rewrite_asan_dylib.py index e9fc537a5563..ee76936ccdca 100644 --- a/build/unix/rewrite_asan_dylib.py +++ b/build/unix/rewrite_asan_dylib.py @@ -90,7 +90,9 @@ def scan_directory(path): # Now rewrite the library itself subprocess.check_call( - [substs['INSTALL_NAME_TOOL'], '-id', '@executable_path/' + DYLIB_NAME, os.path.join(path, DYLIB_NAME)]) + [substs['INSTALL_NAME_TOOL'], '-id', + '@executable_path/' + DYLIB_NAME, + os.path.join(path, DYLIB_NAME)]) dylibCopied = True else: sys.stderr.write('dylib path in %s was not found at: %s\n' % ( @@ -100,7 +102,9 @@ def scan_directory(path): relpath = '' if path == root else os.path.relpath( path, root) + '/' subprocess.check_call([substs['INSTALL_NAME_TOOL'], '-change', - absDylibPath, '@executable_path/' + relpath + DYLIB_NAME, filename]) + absDylibPath, + '@executable_path/' + relpath + DYLIB_NAME, + filename]) break if not dylibCopied: diff --git a/build/util/count_ctors.py b/build/util/count_ctors.py index 5796026ae4f8..5b3745f1c047 100644 --- a/build/util/count_ctors.py +++ b/build/util/count_ctors.py @@ -1,4 +1,3 @@ - #!/usr/bin/python import json @@ -64,4 +63,4 @@ if __name__ == '__main__': }]} ] } - print "PERFHERDER_DATA: %s" % json.dumps(perfherder_data) + print("PERFHERDER_DATA: %s" % json.dumps(perfherder_data)) diff --git a/build/valgrind/mach_commands.py b/build/valgrind/mach_commands.py index 8ebc8ee88ee6..ac5e86249933 100644 --- a/build/valgrind/mach_commands.py +++ b/build/valgrind/mach_commands.py @@ -8,7 +8,6 @@ import json import logging import mozinfo import os -import subprocess from mach.decorators import ( Command, @@ -45,10 +44,7 @@ class MachCommands(MachCommandBase): '--suppression multiple times to specify multiple suppression ' 'files.') def valgrind_test(self, suppressions): - import sys - import tempfile - from mozbuild.base import MozbuildObject from mozfile import TemporaryDirectory from mozhttpd import MozHttpd from mozprofile import FirefoxProfile, Preferences @@ -172,7 +168,8 @@ class MachCommands(MachCommandBase): status = 1 # turns the TBPL job orange self.log(logging.ERROR, 'valgrind-fail-parsing', {'errs': errs, 'supps': supps}, - 'TEST-UNEXPECTED-FAIL | valgrind-test | error parsing: {errs} errors seen, but {supps} generated suppressions seen') + 'TEST-UNEXPECTED-FAIL | valgrind-test | error parsing: {errs} errors ' + 'seen, but {supps} generated suppressions seen') elif errs == 0: status = 0 @@ -182,15 +179,17 @@ class MachCommands(MachCommandBase): status = 1 # turns the TBPL job orange # We've already printed details of the errors. - if exitcode == None: + if exitcode is None: status = 2 # turns the TBPL job red self.log(logging.ERROR, 'valgrind-fail-timeout', {'timeout': timeout}, - 'TEST-UNEXPECTED-FAIL | valgrind-test | Valgrind timed out (reached {timeout} second limit)') + 'TEST-UNEXPECTED-FAIL | valgrind-test | Valgrind timed out ' + '(reached {timeout} second limit)') elif exitcode != 0: status = 2 # turns the TBPL job red self.log(logging.ERROR, 'valgrind-fail-errors', {}, - 'TEST-UNEXPECTED-FAIL | valgrind-test | non-zero exit code from Valgrind') + 'TEST-UNEXPECTED-FAIL | valgrind-test | non-zero exit code' + 'from Valgrind') httpd.stop() diff --git a/build/valgrind/output_handler.py b/build/valgrind/output_handler.py index 198663920e62..9557bb534391 100644 --- a/build/valgrind/output_handler.py +++ b/build/valgrind/output_handler.py @@ -38,7 +38,7 @@ class OutputHandler(object): the count of these lines doesn't match the error count found during parsing, then the parsing has missed one or more errors and we can fail appropriately. - ''' + ''' # NOQA: E501 def __init__(self, logger): # The regexps in this list match all of Valgrind's errors. Note that diff --git a/build/win32/autobinscope.py b/build/win32/autobinscope.py index f1ef115fa2fc..baf3ed68575c 100644 --- a/build/win32/autobinscope.py +++ b/build/win32/autobinscope.py @@ -19,8 +19,8 @@ BINSCOPE_OUTPUT_LOGFILE = r".\binscope_xml_output.log" # usage if len(sys.argv) < 3: - print """usage : autobinscope.by path_to_binary path_to_symbols [log_file_path]" - log_file_path is optional, log will be written to .\binscope_xml_output.log by default""" + print("""usage : autobinscope.by path_to_binary path_to_symbols [log_file_path]" + log_file_path is optional, log will be written to .\binscope_xml_output.log by default""") sys.exit(0) binary_path = sys.argv[1] @@ -36,7 +36,8 @@ else: try: binscope_path = os.environ['BINSCOPE'] except KeyError: - print "TEST-UNEXPECTED-FAIL | autobinscope.py | BINSCOPE environment variable is not set, can't check DEP/ASLR etc. status." + print("TEST-UNEXPECTED-FAIL | autobinscope.py | BINSCOPE environment variable is not set, " + "can't check DEP/ASLR etc. status.") sys.exit(0) try: @@ -49,7 +50,7 @@ try: "/Checks", "ATLVulnCheck", # We do not ship in the Windows Store "/SkippedChecks", "AppContainerCheck", - # The CompilerVersionCheck doesn't like clang-cl (we would need to set MinimumCompilerVersion) + # The CompilerVersionCheck doesn't like clang-cl (we would need to set MinimumCompilerVersion) # NOQA: E501 # But we check the compiler in our build system anyway, so this doesn't seem useful "/SkippedChecks", "CompilerVersionCheck", "/Checks", "DBCheck", @@ -73,11 +74,12 @@ try: except WindowsError, (errno, strerror): if errno != 2 and errno != 3: - print "TEST-UNEXPECTED-FAIL | autobinscope.py | Unexpected error %d : %s" ( - errno, strerror) + print("TEST-UNEXPECTED-FAIL | autobinscope.py | Unexpected error %d : %s" ( + errno, strerror)) sys.exit(0) else: - print "TEST-UNEXPECTED-FAIL | autobinscope.py | Could not locate binscope at location : %s\n" % binscope_path + print("TEST-UNEXPECTED-FAIL | autobinscope.py | Could not locate binscope at location : " + "%s\n" % binscope_path) sys.exit(0) proc.wait() @@ -91,10 +93,10 @@ for line in output: errors += 1 if proc.returncode != 0: - print "TEST-UNEXPECTED-FAIL | autobinscope.py | Binscope returned error code %d for file %s" % ( - proc.returncode, binary_path) + print("TEST-UNEXPECTED-FAIL | autobinscope.py | Binscope returned error code %d for file %s" % + (proc.returncode, binary_path)) elif errors != 0: - print "TEST-UNEXPECTED-FAIL | autobinscope.py | Binscope reported %d error(s) for file %s" % ( - errors, binary_path) + print("TEST-UNEXPECTED-FAIL | autobinscope.py | Binscope reported %d error(s) for file %s" % ( + errors, binary_path)) else: - print "TEST-PASS | autobinscope.py | %s succeeded" % binary_path + print("TEST-PASS | autobinscope.py | %s succeeded" % binary_path)