mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1460402 - Update the flake8 support to use the pip class r=ahal
MozReview-Commit-ID: 9BWa0cnWJdS --HG-- extra : rebase_source : 6de8669427b1724aadc39c0d10dd30e0e26abdc8
This commit is contained in:
parent
c2704ae938
commit
814ff726f3
@ -5,13 +5,13 @@
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
from collections import defaultdict
|
||||
|
||||
import which
|
||||
from mozprocess import ProcessHandlerMixin
|
||||
|
||||
from mozlint import result
|
||||
from mozlint.util import pip
|
||||
from mozlint.pathutils import get_ancestors_by_name
|
||||
|
||||
|
||||
@ -105,32 +105,6 @@ def get_flake8_binary():
|
||||
return None
|
||||
|
||||
|
||||
def _run_pip(*args):
|
||||
"""
|
||||
Helper function that runs pip with subprocess
|
||||
"""
|
||||
try:
|
||||
subprocess.check_output(['pip'] + list(args),
|
||||
stderr=subprocess.STDOUT)
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(e.output)
|
||||
return False
|
||||
|
||||
|
||||
def reinstall_flake8():
|
||||
"""
|
||||
Try to install flake8 at the target version, returns True on success
|
||||
otherwise prints the otuput of the pip command and returns False
|
||||
"""
|
||||
if _run_pip('install', '-U',
|
||||
'--require-hashes', '-r',
|
||||
FLAKE8_REQUIREMENTS_PATH):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def run_process(config, cmd):
|
||||
proc = Flake8Process(config, cmd)
|
||||
proc.run()
|
||||
@ -142,7 +116,7 @@ def run_process(config, cmd):
|
||||
|
||||
def lint(paths, config, **lintargs):
|
||||
|
||||
if not reinstall_flake8():
|
||||
if not pip.reinstall_program(FLAKE8_REQUIREMENTS_PATH):
|
||||
print(FLAKE8_INSTALL_ERROR)
|
||||
return 1
|
||||
|
||||
|
@ -6,13 +6,13 @@ import json
|
||||
import os
|
||||
import platform
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
|
||||
from mozprocess import ProcessHandlerMixin
|
||||
|
||||
from mozlint import result
|
||||
from mozlint.util import pip
|
||||
from mozlint.pathutils import get_ancestors_by_name
|
||||
|
||||
|
||||
@ -98,32 +98,6 @@ class Flake8Process(ProcessHandlerMixin):
|
||||
signal.signal(signal.SIGINT, orig)
|
||||
|
||||
|
||||
def _run_pip(*args):
|
||||
"""
|
||||
Helper function that runs pip with subprocess
|
||||
"""
|
||||
try:
|
||||
subprocess.check_output([os.path.join(bindir, 'pip')] + list(args),
|
||||
stderr=subprocess.STDOUT)
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(e.output)
|
||||
return False
|
||||
|
||||
|
||||
def reinstall_flake8():
|
||||
"""
|
||||
Try to install flake8 at the target version, returns True on success
|
||||
otherwise prints the otuput of the pip command and returns False
|
||||
"""
|
||||
if _run_pip('install', '-U',
|
||||
'--require-hashes', '-r',
|
||||
FLAKE8_REQUIREMENTS_PATH):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def run_process(config, cmd):
|
||||
proc = Flake8Process(config, cmd)
|
||||
proc.run()
|
||||
@ -135,7 +109,7 @@ def run_process(config, cmd):
|
||||
|
||||
|
||||
def setup(root):
|
||||
if not reinstall_flake8():
|
||||
if not pip.reinstall_program(FLAKE8_REQUIREMENTS_PATH):
|
||||
print(FLAKE8_INSTALL_ERROR)
|
||||
return 1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user