mirror of
https://github.com/servo/servo.git
synced 2025-07-02 21:13:39 +01:00
Auto merge of #27007 - saschanaz:py3-flake, r=jdm
Upgrade flake8/pyflakes for Py3 compatibility <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
3f999ce785
33 changed files with 377 additions and 357 deletions
|
@ -244,7 +244,7 @@ class MachCommands(CommandBase):
|
|||
|
||||
with open(path.join(preload_path, preload_filename), 'w') as fd:
|
||||
json.dump(entries, fd, indent=4)
|
||||
except ValueError as e:
|
||||
except ValueError:
|
||||
print("Unable to parse chromium HSTS preload list, has the format changed?")
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -262,8 +262,8 @@ class MachCommands(CommandBase):
|
|||
print("Unable to download the public suffix list; are you connected to the internet?")
|
||||
sys.exit(1)
|
||||
|
||||
lines = [l.strip() for l in content.decode("utf8").split("\n")]
|
||||
suffixes = [l for l in lines if not l.startswith("//") and not l == ""]
|
||||
lines = [line.strip() for line in content.decode("utf8").split("\n")]
|
||||
suffixes = [line for line in lines if not line.startswith("//") and not line == ""]
|
||||
|
||||
with open(dst_filename, "wb") as fo:
|
||||
for suffix in suffixes:
|
||||
|
@ -475,7 +475,7 @@ class MachCommands(CommandBase):
|
|||
if os.path.exists(crate_path):
|
||||
try:
|
||||
delete(crate_path)
|
||||
except:
|
||||
except Exception:
|
||||
print(traceback.format_exc())
|
||||
print("Delete %s failed!" % crate_path)
|
||||
else:
|
||||
|
|
|
@ -46,7 +46,7 @@ def notify_linux(title, text):
|
|||
notify_obj = bus.get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
|
||||
method = notify_obj.get_dbus_method("Notify", "org.freedesktop.Notifications")
|
||||
method(title, 0, "", text, "", [], {"transient": True}, -1)
|
||||
except:
|
||||
except ImportError:
|
||||
raise Exception("Optional Python module 'dbus' is not installed.")
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@ def notify_win(title, text):
|
|||
from servo.win32_toast import WindowsToast
|
||||
w = WindowsToast()
|
||||
w.balloon_tip(title, text)
|
||||
except:
|
||||
except WindowsError:
|
||||
from ctypes import Structure, windll, POINTER, sizeof
|
||||
from ctypes.wintypes import DWORD, HANDLE, WINFUNCTYPE, BOOL, UINT
|
||||
|
||||
|
@ -920,7 +920,7 @@ def package_gstreamer_dlls(env, servo_exe_dir, target, uwp):
|
|||
for gst_lib in gst_dlls:
|
||||
try:
|
||||
shutil.copy(path.join(gst_root, "bin", gst_lib), servo_exe_dir)
|
||||
except:
|
||||
except Exception:
|
||||
missing += [str(gst_lib)]
|
||||
|
||||
for gst_lib in missing:
|
||||
|
@ -976,7 +976,7 @@ def package_gstreamer_dlls(env, servo_exe_dir, target, uwp):
|
|||
for gst_lib in gst_dlls:
|
||||
try:
|
||||
shutil.copy(path.join(gst_plugin_path, gst_lib), servo_exe_dir)
|
||||
except:
|
||||
except Exception:
|
||||
missing += [str(gst_lib)]
|
||||
|
||||
for gst_lib in missing:
|
||||
|
|
|
@ -487,7 +487,7 @@ class CommandBase(object):
|
|||
print("Could not fetch the available nightly versions from the repository : {}".format(
|
||||
e.reason))
|
||||
sys.exit(1)
|
||||
except AttributeError as e:
|
||||
except AttributeError:
|
||||
print("Could not fetch a nightly version for date {} and platform {}".format(
|
||||
nightly_date, os_prefix))
|
||||
sys.exit(1)
|
||||
|
@ -517,8 +517,8 @@ class CommandBase(object):
|
|||
else:
|
||||
print("The nightly {} does not exist yet, downloading it.".format(
|
||||
destination_file))
|
||||
download_file(destination_file, NIGHTLY_REPOSITORY_URL +
|
||||
file_to_download, destination_file)
|
||||
download_file(destination_file, NIGHTLY_REPOSITORY_URL
|
||||
+ file_to_download, destination_file)
|
||||
|
||||
# Extract the downloaded nightly version
|
||||
if os.path.isdir(destination_folder):
|
||||
|
@ -537,7 +537,7 @@ class CommandBase(object):
|
|||
try:
|
||||
if check_gstreamer_lib():
|
||||
return False
|
||||
except:
|
||||
except Exception:
|
||||
# Some systems don't have pkg-config; we can't probe in this case
|
||||
# and must hope for the best
|
||||
return False
|
||||
|
@ -552,7 +552,7 @@ class CommandBase(object):
|
|||
raise Exception("Your system's gstreamer libraries are out of date \
|
||||
(we need at least 1.16). Please run ./mach bootstrap-gstreamer")
|
||||
else:
|
||||
raise Exception("Your system's gstreamer libraries are out of date \
|
||||
raise Exception("Your system's gstreamer libraries are out of date \
|
||||
(we need at least 1.16). If you're unable to \
|
||||
install them, let us know by filing a bug!")
|
||||
return False
|
||||
|
@ -858,9 +858,9 @@ install them, let us know by filing a bug!")
|
|||
def pick_media_stack(self, media_stack, target):
|
||||
if not(media_stack):
|
||||
if (
|
||||
not(target) or
|
||||
("armv7" in target and "android" in target) or
|
||||
("x86_64" in target)
|
||||
not(target)
|
||||
or ("armv7" in target and "android" in target)
|
||||
or ("x86_64" in target)
|
||||
):
|
||||
media_stack = "gstreamer"
|
||||
else:
|
||||
|
@ -1032,7 +1032,7 @@ install them, let us know by filing a bug!")
|
|||
print()
|
||||
sys.exit(1)
|
||||
raise
|
||||
version = tuple(map(int, re.match(b"rustup (\d+)\.(\d+)\.(\d+)", version_line).groups()))
|
||||
version = tuple(map(int, re.match(br"rustup (\d+)\.(\d+)\.(\d+)", version_line).groups()))
|
||||
version_needed = (1, 21, 0)
|
||||
if version < version_needed:
|
||||
print("rustup is at version %s.%s.%s, Servo requires %s.%s.%s or more recent." % (version + version_needed))
|
||||
|
@ -1069,8 +1069,8 @@ install them, let us know by filing a bug!")
|
|||
|
||||
def find_highest_msvc_version_ext():
|
||||
def vswhere(args):
|
||||
program_files = (os.environ.get('PROGRAMFILES(X86)') or
|
||||
os.environ.get('PROGRAMFILES'))
|
||||
program_files = (os.environ.get('PROGRAMFILES(X86)')
|
||||
or os.environ.get('PROGRAMFILES'))
|
||||
if not program_files:
|
||||
return []
|
||||
vswhere = os.path.join(program_files, 'Microsoft Visual Studio',
|
||||
|
@ -1107,8 +1107,8 @@ def find_highest_msvc_version():
|
|||
|
||||
versions = sorted(find_highest_msvc_version_ext(), key=lambda tup: float(tup[1]))
|
||||
if not versions:
|
||||
print("Can't find MSBuild.exe installation under %s. Please set the VSINSTALLDIR and VisualStudioVersion" +
|
||||
" environment variables" % base_vs_path)
|
||||
print("Can't find MSBuild.exe installation under %s. Please set the VSINSTALLDIR and VisualStudioVersion"
|
||||
+ " environment variables" % base_vs_path)
|
||||
sys.exit(1)
|
||||
return versions[0]
|
||||
|
||||
|
|
|
@ -93,8 +93,8 @@ class MachCommands(CommandBase):
|
|||
help='Updates the selected package')
|
||||
@CommandArgument(
|
||||
'--all-packages', '-a', action='store_true',
|
||||
help='Updates all packages. NOTE! This is very likely to break your ' +
|
||||
'working copy, making it impossible to build servo. Only do ' +
|
||||
help='Updates all packages. NOTE! This is very likely to break your '
|
||||
'working copy, making it impossible to build servo. Only do '
|
||||
'this if you really know what you are doing.')
|
||||
@CommandArgument(
|
||||
'--dry-run', '-d', action='store_true',
|
||||
|
|
|
@ -138,8 +138,8 @@ class DuplicateLine(Strategy):
|
|||
plus_equals_statement = r".+?\s\+\=\s.*"
|
||||
minus_equals_statement = r".+?\s\-\=\s.*"
|
||||
self._replace_strategy = {
|
||||
'regex': (append_statement + '|' + remove_statement + '|' + push_statement +
|
||||
'|' + pop_statement + '|' + plus_equals_statement + '|' + minus_equals_statement),
|
||||
'regex': (append_statement + '|' + remove_statement + '|' + push_statement
|
||||
+ '|' + pop_statement + '|' + plus_equals_statement + '|' + minus_equals_statement),
|
||||
'replaceString': r"\g<0>\n\g<0>",
|
||||
}
|
||||
|
||||
|
|
|
@ -30,9 +30,6 @@ from mach.decorators import (
|
|||
Command,
|
||||
)
|
||||
from mach.registrar import Registrar
|
||||
# Note: mako cannot be imported at the top level because it breaks mach bootstrap
|
||||
sys.path.append(path.join(path.dirname(__file__), "..", "..",
|
||||
"components", "style", "properties", "Mako-1.1.2-py2.py3-none-any.whl"))
|
||||
|
||||
from servo.command_base import (
|
||||
archive_deterministically,
|
||||
|
@ -44,6 +41,9 @@ from servo.command_base import (
|
|||
)
|
||||
from servo.util import delete
|
||||
|
||||
# Note: mako cannot be imported at the top level because it breaks mach bootstrap
|
||||
sys.path.append(path.join(path.dirname(__file__), "..", "..",
|
||||
"components", "style", "properties", "Mako-1.1.2-py2.py3-none-any.whl"))
|
||||
|
||||
PACKAGES = {
|
||||
'android': [
|
||||
|
@ -96,18 +96,18 @@ else:
|
|||
|
||||
def get_taskcluster_secret(name):
|
||||
url = (
|
||||
os.environ.get("TASKCLUSTER_PROXY_URL", "http://taskcluster") +
|
||||
"/api/secrets/v1/secret/project/servo/" +
|
||||
name
|
||||
os.environ.get("TASKCLUSTER_PROXY_URL", "http://taskcluster")
|
||||
+ "/api/secrets/v1/secret/project/servo/"
|
||||
+ name
|
||||
)
|
||||
return json.load(urllib.request.urlopen(url))["secret"]
|
||||
|
||||
|
||||
def otool(s):
|
||||
o = subprocess.Popen(['/usr/bin/otool', '-L', s], stdout=subprocess.PIPE)
|
||||
for l in o.stdout:
|
||||
if l[0] == '\t':
|
||||
yield l.split(' ', 1)[0][1:]
|
||||
for line in o.stdout:
|
||||
if line[0] == '\t':
|
||||
yield line.split(' ', 1)[0][1:]
|
||||
|
||||
|
||||
def listfiles(directory):
|
||||
|
@ -781,7 +781,7 @@ def setup_uwp_signing(ms_app_store, publisher):
|
|||
print("Packaging on TC. Using secret certificate")
|
||||
pfx = get_taskcluster_secret("windows-codesign-cert/latest")["pfx"]
|
||||
open("servo.pfx", "wb").write(base64.b64decode(pfx["base64"]))
|
||||
run_powershell_cmd('Import-PfxCertificate -FilePath .\servo.pfx -CertStoreLocation Cert:\CurrentUser\My')
|
||||
run_powershell_cmd('Import-PfxCertificate -FilePath .\\servo.pfx -CertStoreLocation Cert:\\CurrentUser\\My')
|
||||
os.remove("servo.pfx")
|
||||
|
||||
# Powershell command that lists all certificates for publisher
|
||||
|
@ -796,7 +796,7 @@ def setup_uwp_signing(ms_app_store, publisher):
|
|||
# PowerShell command that creates and install signing certificate for publisher
|
||||
cmd = '(New-SelfSignedCertificate -Type Custom -Subject ' + publisher + \
|
||||
' -FriendlyName "Allizom Signing Certificate (temporary)"' + \
|
||||
' -KeyUsage DigitalSignature -CertStoreLocation "Cert:\CurrentUser\My"' + \
|
||||
' -KeyUsage DigitalSignature -CertStoreLocation "Cert:\\CurrentUser\\My"' + \
|
||||
' -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")).Thumbprint'
|
||||
thumbprint = run_powershell_cmd(cmd)
|
||||
elif len(certs) > 1:
|
||||
|
|
|
@ -161,8 +161,8 @@ class PostBuildCommands(CommandBase):
|
|||
command = rustCommand
|
||||
|
||||
# Prepend the debugger args.
|
||||
args = ([command] + self.debuggerInfo.args +
|
||||
args + params)
|
||||
args = ([command] + self.debuggerInfo.args
|
||||
+ args + params)
|
||||
else:
|
||||
args = args + params
|
||||
|
||||
|
@ -208,8 +208,8 @@ class PostBuildCommands(CommandBase):
|
|||
env = self.build_env()
|
||||
env["RUST_BACKTRACE"] = "1"
|
||||
|
||||
servo_cmd = [bin or self.get_nightly_binary_path(nightly) or
|
||||
self.get_binary_path(release, dev)] + params
|
||||
servo_cmd = [bin or self.get_nightly_binary_path(nightly)
|
||||
or self.get_binary_path(release, dev)] + params
|
||||
rr_cmd = ['rr', '--fatal-errors', 'record']
|
||||
try:
|
||||
check_call(rr_cmd + servo_cmd)
|
||||
|
|
|
@ -117,8 +117,8 @@ class MachCommands(CommandBase):
|
|||
help="Optionally select test based on "
|
||||
"test file directory")
|
||||
@CommandArgument('--render-mode', '-rm', default=DEFAULT_RENDER_MODE,
|
||||
help="The render mode to be used on all tests. " +
|
||||
HELP_RENDER_MODE)
|
||||
help="The render mode to be used on all tests. "
|
||||
+ HELP_RENDER_MODE)
|
||||
@CommandArgument('--release', default=False, action="store_true",
|
||||
help="Run with a release build of servo")
|
||||
@CommandArgument('--tidy-all', default=False, action="store_true",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue