Add flake8 to the tidy process for Python files

Fixes #6236

Also included in this commit are the changes need to make flake8 pass
for the existing python file
This commit is contained in:
Corey Farwell 2015-06-03 20:29:13 -04:00
parent 907c051bd1
commit 848c57653c
15 changed files with 113 additions and 68 deletions

View file

@ -40,7 +40,8 @@ def download(desc, src, dst):
with open(dst, 'wb') as fd:
while True:
chunk = resp.read(chunk_size)
if not chunk: break
if not chunk:
break
recved += len(chunk)
if not dumb:
pct = recved * 100.0 / fsize
@ -61,6 +62,7 @@ def download(desc, src, dst):
sys.exit(1)
def extract(src, dst, movedir=None):
tarfile.open(src).extractall(dst)

View file

@ -58,13 +58,14 @@ def notify_win(title, text):
FLASHW_TIMERNOFG = 0x0C
params = FLASHWINDOW(sizeof(FLASHWINDOW),
windll.kernel32.GetConsoleWindow(),
FLASHW_CAPTION | FLASHW_TRAY | FLASHW_TIMERNOFG, 3, 0)
windll.kernel32.GetConsoleWindow(),
FLASHW_CAPTION | FLASHW_TRAY | FLASHW_TIMERNOFG, 3, 0)
FlashWindowEx(params)
def notify_darwin(title, text):
import Foundation, objc
import Foundation
import objc
NSUserNotification = objc.lookUpClass("NSUserNotification")
NSUserNotificationCenter = objc.lookUpClass("NSUserNotificationCenter")
@ -291,7 +292,7 @@ class MachCommands(CommandBase):
opts += ["--release"]
opts += ["--target", "arm-linux-androideabi"]
env=self.build_env(gonk=True)
env = self.build_env(gonk=True)
build_start = time()
with cd(path.join("ports", "gonk")):
ret = subprocess.call(["cargo", "build"] + opts, env=env)
@ -304,7 +305,6 @@ class MachCommands(CommandBase):
return ret
@Command('build-tests',
description='Build the Servo test suites',
category='build')
@ -329,7 +329,6 @@ class MachCommands(CommandBase):
@CommandArgument('--verbose', '-v',
action='store_true',
help='Print verbose output')
@CommandArgument('params', nargs='...',
help="Command-line arguments to be passed through to Cargo")
def clean(self, manifest_path, params, verbose=False):

View file

@ -165,7 +165,7 @@ class CommandBase(object):
print("The %s profile is not built. Please run './mach build%s' "
"and try again." % ("release" if release else "dev",
" --release" if release else ""))
" --release" if release else ""))
sys.exit()
def build_env(self, gonk=False, hosts_file_path=None):

View file

@ -36,8 +36,8 @@ class MachCommands(CommandBase):
if self.context.topdir == getcwd():
with cd(path.join('components', 'servo')):
return subprocess.call(["cargo"] + params,
env=self.build_env())
return subprocess.call(
["cargo"] + params, env=self.build_env())
return subprocess.call(['cargo'] + params,
env=self.build_env())
@ -51,7 +51,7 @@ class MachCommands(CommandBase):
'--package', '-p', default=None,
help='Updates selected package')
@CommandArgument(
'--all-packages','-a',action='store_true',
'--all-packages', '-a', action='store_true',
help='Updates all packages')
def cargo_update(self, params=None, package=None, all_packages=None):
self.update_cargo(params, package, all_packages)
@ -63,10 +63,10 @@ class MachCommands(CommandBase):
'params', default=None, nargs='...',
help='Command-line arguments to be passed through to cargo update')
@CommandArgument(
'--package','-p',default=None,
'--package', '-p', default=None,
help='Updates selected package')
@CommandArgument(
'--all-packages','-a',action='store_true',
'--all-packages', '-a', action='store_true',
help='Updates all packages')
def update_cargo(self, params=None, package=None, all_packages=None):
if not params:

View file

@ -12,7 +12,6 @@ from __future__ import print_function, unicode_literals
import os
import os.path as path
import subprocess
import sys
from shutil import copytree, rmtree, copy2
from mach.registrar import Registrar
@ -49,7 +48,7 @@ class MachCommands(CommandBase):
'debugger being used. The following arguments '
'have no effect without this.')
@CommandArgument('--debugger', default=None, type=str,
help='Name of debugger to use.')
help='Name of debugger to use.')
@CommandArgument(
'params', nargs='...',
help="Command-line arguments to be passed through to Servo")
@ -74,8 +73,8 @@ class MachCommands(CommandBase):
return 1
# Prepend the debugger args.
args = ([self.debuggerInfo.path] + self.debuggerInfo.args
+ args + params)
args = ([self.debuggerInfo.path] + self.debuggerInfo.args +
args + params)
else:
args = args + params
@ -84,7 +83,7 @@ class MachCommands(CommandBase):
except OSError as e:
if e.errno == 2:
print("Servo Binary can't be found! Run './mach build'"
" and try again!")
" and try again!")
else:
raise e
@ -132,8 +131,7 @@ class MachCommands(CommandBase):
help="Command-line arguments to be passed through to cargo doc")
def doc(self, params):
self.ensure_bootstrapped()
if not path.exists(path.join(
self.config["tools"]["rust-root"], "doc")):
if not path.exists(path.join(self.config["tools"]["rust-root"], "doc")):
Registrar.dispatch("bootstrap-rust-docs", context=self.context)
rust_docs = path.join(self.config["tools"]["rust-root"], "doc")
docs = path.join(

View file

@ -281,7 +281,6 @@ class MachCommands(CommandBase):
execfile(run_file, run_globals)
return run_globals["update_tests"](**kwargs)
def ensure_wpt_virtualenv(self):
virtualenv_path = path.join("tests", "wpt", "_virtualenv")
python = self.get_exec("python2", "python")
@ -295,8 +294,8 @@ class MachCommands(CommandBase):
execfile(activate_path, dict(__file__=activate_path))
try:
import wptrunner
from wptrunner.browsers import servo
import wptrunner # noqa
from wptrunner.browsers import servo # noqa
except ImportError:
subprocess.check_call(["pip", "install", "-r",
path.join("tests", "wpt", "harness", "requirements.txt")])
@ -311,7 +310,7 @@ class MachCommands(CommandBase):
# before the virtualenv is initalised it doesn't see the blessings module so we don't
# get coloured output. Setting the blessings global explicitly fixes that.
from mozlog.structured.formatters import machformatter
import blessings
import blessings # noqa
machformatter.blessings = blessings
def get_exec(self, name, default=None):