bug 1463425 - Fix flake8/pep8 issue by hand in build/ r=gps

MozReview-Commit-ID: AZdcEWyVV6e

--HG--
extra : rebase_source : b1c45028c8d46be5ba590a27a2f9f20e248a26b1
This commit is contained in:
Sylvestre Ledru 2018-05-21 23:58:19 +02:00
Родитель 8cd16bb55b
Коммит dcfef841a7
12 изменённых файлов: 95 добавлений и 80 удалений

Просмотреть файл

@ -107,7 +107,7 @@ def delete(path):
else:
try:
os.unlink(path)
except:
except Exception:
pass

Просмотреть файл

@ -2,6 +2,7 @@
import json
def generate(output, tpp_txt):
"""
This file generates a ThirdPartyPaths.cpp file from the ThirdPartyPaths.txt

Просмотреть файл

@ -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 <mozilla-clang-plugin-path> <clang-tidy-path>
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)

Просмотреть файл

@ -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)

Просмотреть файл

@ -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:

Просмотреть файл

@ -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)

Просмотреть файл

@ -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,

Просмотреть файл

@ -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:

Просмотреть файл

@ -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))

Просмотреть файл

@ -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()

Просмотреть файл

@ -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

Просмотреть файл

@ -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)