Simplify checks to always use subprocess.
This commit is contained in:
parent
b209be5739
commit
58f210e9cf
@ -19,12 +19,18 @@
|
|||||||
|
|
||||||
"""Custom astroid checker for config calls."""
|
"""Custom astroid checker for config calls."""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
|
||||||
import astroid
|
import astroid
|
||||||
from pylint import interfaces, checkers
|
from pylint import interfaces, checkers
|
||||||
from pylint.checkers import utils
|
from pylint.checkers import utils
|
||||||
|
|
||||||
from qutebrowser.config import configdata
|
sys.path.insert(
|
||||||
|
0, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
|
||||||
|
|
||||||
|
from qutebrowser.config import configdata
|
||||||
|
|
||||||
class ConfigChecker(checkers.BaseChecker):
|
class ConfigChecker(checkers.BaseChecker):
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ import contextlib
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import pep257
|
import pep257
|
||||||
import pkg_resources as pkg
|
|
||||||
|
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
|
||||||
@ -79,28 +78,6 @@ def _adjusted_pythonpath(name):
|
|||||||
del os.environ['PYTHONPATH']
|
del os.environ['PYTHONPATH']
|
||||||
|
|
||||||
|
|
||||||
def _run_distutils(name, args):
|
|
||||||
"""Run a checker via its distutils entry point."""
|
|
||||||
sys.argv = [name] + args
|
|
||||||
try:
|
|
||||||
ep = pkg.load_entry_point(name, 'console_scripts', name)
|
|
||||||
ep()
|
|
||||||
except SystemExit as e:
|
|
||||||
return e.code
|
|
||||||
except Exception:
|
|
||||||
traceback.print_exc()
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _run_subprocess(name, args):
|
|
||||||
"""Run a checker via subprocess."""
|
|
||||||
try:
|
|
||||||
return subprocess.call([name] + args)
|
|
||||||
except OSError:
|
|
||||||
traceback.print_exc()
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def run(name, target=None):
|
def run(name, target=None):
|
||||||
"""Run a checker via distutils with optional args.
|
"""Run a checker via distutils with optional args.
|
||||||
|
|
||||||
@ -114,9 +91,10 @@ def run(name, target=None):
|
|||||||
args.append(target)
|
args.append(target)
|
||||||
with _adjusted_pythonpath(name):
|
with _adjusted_pythonpath(name):
|
||||||
try:
|
try:
|
||||||
status = _run_distutils(name, args)
|
status = subprocess.call([name] + args)
|
||||||
except pkg.DistributionNotFound:
|
except OSError:
|
||||||
status = _run_subprocess(name, args)
|
traceback.print_exc()
|
||||||
|
status = None
|
||||||
print()
|
print()
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user