From 58f210e9cf8fb38924d6c3451047e23ddd31565f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 5 Dec 2014 08:44:58 +0100 Subject: [PATCH] Simplify checks to always use subprocess. --- scripts/pylint_checkers/config.py | 8 +++++++- scripts/run_checks.py | 30 ++++-------------------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/scripts/pylint_checkers/config.py b/scripts/pylint_checkers/config.py index 2c1115e1f..0ce891894 100644 --- a/scripts/pylint_checkers/config.py +++ b/scripts/pylint_checkers/config.py @@ -19,12 +19,18 @@ """Custom astroid checker for config calls.""" +import sys +import os +import os.path + import astroid from pylint import interfaces, checkers 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): diff --git a/scripts/run_checks.py b/scripts/run_checks.py index 7a1588089..2381fc556 100755 --- a/scripts/run_checks.py +++ b/scripts/run_checks.py @@ -44,7 +44,6 @@ import contextlib import traceback import pep257 -import pkg_resources as pkg 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'] -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): """Run a checker via distutils with optional args. @@ -114,9 +91,10 @@ def run(name, target=None): args.append(target) with _adjusted_pythonpath(name): try: - status = _run_distutils(name, args) - except pkg.DistributionNotFound: - status = _run_subprocess(name, args) + status = subprocess.call([name] + args) + except OSError: + traceback.print_exc() + status = None print() return status