diff --git a/doc/HACKING.asciidoc b/doc/HACKING.asciidoc index 49dcac845..76e7f0fe7 100644 --- a/doc/HACKING.asciidoc +++ b/doc/HACKING.asciidoc @@ -106,8 +106,6 @@ https://docs.python.org/3.4/library/unittest.html[unittest] framework * http://pylint.org/[pylint] * A custom checker for the following things: - untracked git files - - whitespace/CRLF problems - - `set_trace` invocations - VCS conflict markers If you changed `setup.py` or `MANIFEST.in`, add the `--setup` argument to run @@ -116,6 +114,9 @@ the following additional checkers: * https://pypi.python.org/pypi/pyroma/0.9.3[pyroma] * https://github.com/mgedmin/check-manifest[check-manifest] +It needs all the checkers to be installed and also needs +https://pypi.python.org/pypi/colorama/[colorama]. + Please make sure this script runs without any warnings on your new contributions. There's of course the possibility of false-positives, and the following techniques are useful to handle these: diff --git a/qutebrowser/utils/earlyinit.py b/qutebrowser/utils/earlyinit.py index c81202fe5..89e714f2a 100644 --- a/qutebrowser/utils/earlyinit.py +++ b/qutebrowser/utils/earlyinit.py @@ -41,30 +41,29 @@ def _missing_str(name, debian=None, arch=None, windows=None, pip=None): windows: String to be displayed for Windows. pip: pypi package name. """ - blocks = ["Fatal error: {} is required to run qutebrowser but could " - "not be imported! Maybe it's not installed?".format(name)] + blocks = ["Fatal error: {} is required to run qutebrowser but " + "could not be imported! Maybe it's not installed?".format(name)] if debian is not None: - lines = ["On Debian/Ubuntu:"] - for line in debian.splitlines(): - lines.append(' ' + line) - blocks.append('\n'.join(lines)) + lines = ["On Debian/Ubuntu:"] + lines += debian.splitlines() + blocks.append('
'.join(lines)) if arch is not None: - lines = ["On Archlinux:"] - for line in arch.splitlines(): - lines.append(' ' + line) - blocks.append('\n'.join(lines)) + lines = ["On Archlinux:"] + lines += arch.splitlines() + blocks.append('
'.join(lines)) if windows is not None: - lines = ["On Windows:"] - for line in windows.splitlines(): - lines.append(' ' + line) - blocks.append('\n'.join(lines)) - lines = ["For other distributions:", - " Check your package manager for similiarly named packages."] + lines = ["On Windows:"] + lines += windows.splitlines() + blocks.append('
'.join(lines)) + lines = ["For other distributions:", + "Check your package manager for similiarly named packages or " + "install via pip."] + blocks.append('
'.join(lines)) if pip is not None: - lines.append(" Or run pip install {} (using python3/pip3)".format( - pip)) - blocks.append('\n'.join(lines)) - return '\n\n'.join(blocks) + lines = ["Using pip:"] + lines.append("pip3 install {}".format(pip)) + blocks.append('
'.join(lines)) + return '

'.join(blocks) def _die(message, exception=True): @@ -77,12 +76,14 @@ def _die(message, exception=True): exception: Whether to print an exception with --debug. """ from PyQt5.QtWidgets import QApplication, QMessageBox + from PyQt5.QtCore import Qt if '--debug' in sys.argv and exception: print(file=sys.stderr) traceback.print_exc() app = QApplication(sys.argv) msgbox = QMessageBox(QMessageBox.Critical, "qutebrowser: Fatal error!", message) + msgbox.setTextFormat(Qt.RichText) msgbox.resize(msgbox.sizeHint()) msgbox.exec_() app.quit() @@ -176,12 +177,15 @@ def check_pyqt_core(): text = _missing_str('PyQt5', debian="apt-get install python3-pyqt5 " "python3-pyqt5.qtwebkit", - arch="pacman -S python-pyqt5 qt5-webkit\n" + arch="pacman -S python-pyqt5 qt5-webkit
" "or install the qutebrowser package from AUR", windows="Use the installer by Riverbank computing " - "or the standalone qutebrowser exe.\n" + "or the standalone qutebrowser exe.
" "http://www.riverbankcomputing.co.uk/" "software/pyqt/download5") + text = text.replace('', '') + text = text.replace('', '') + text = text.replace('
', '\n') if Tk: root = Tk() root.withdraw() @@ -237,15 +241,9 @@ def check_pypeg2(): import pypeg2 # pylint: disable=unused-variable except ImportError: text = _missing_str("pypeg2", - debian="No package available, try:\n" - "pip3 install pypeg2 " - "--allow-external pypeg2 " - "--allow-unverified pypeg2", - arch="pacman -S python-pypeg2", - windows="pip install pypeg2 " - "--allow-external pypeg2 " - "--allow-unverified pypeg2 " - "(using python3)", + debian="No package available, install via pip.", + arch="Install python-pypeg2 from the AUR", + windows="Install via pip.", pip="pypeg2 --allow-external pypeg2 " "--allow-unverified pypeg2") _die(text) diff --git a/scripts/ez_setup.py b/scripts/ez_setup.py index 6de57c040..4b9eee61b 100644 --- a/scripts/ez_setup.py +++ b/scripts/ez_setup.py @@ -36,7 +36,7 @@ try: except ImportError: USER_SITE = None -DEFAULT_VERSION = "5.5.1" +DEFAULT_VERSION = "5.6" DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/" def _python_cmd(*args): diff --git a/scripts/run_checks.py b/scripts/run_checks.py index bacb17a6e..264d43d1a 100755 --- a/scripts/run_checks.py +++ b/scripts/run_checks.py @@ -18,7 +18,7 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -# pylint: disable=broad-except +# pylint: disable=broad-except, no-member """ Run different codecheckers over a codebase. @@ -42,6 +42,7 @@ from collections import OrderedDict from functools import partial from contextlib import contextmanager +import colorama as col import pep257 from pkg_resources import load_entry_point, DistributionNotFound @@ -154,7 +155,7 @@ def check_git(): untracked.append(name) if untracked: status = False - print("Untracked files:") + print("{}Untracked files:{}".format(col.Fore.RED, col.Fore.RESET)) print('\n'.join(untracked)) else: status = True @@ -260,9 +261,22 @@ def _get_checkers(): return checkers +def _checker_enabled(args, group, name): + """Check if a named checker is enabled.""" + if args.checkers == 'all': + if not args.setup and group == 'setup': + return False + else: + return True + else: + return name in args.checkers.split(',') + + def main(): """Main entry point.""" + col.init() exit_status = OrderedDict() + exit_status_bool = {} parser = argparse.ArgumentParser(description='Run various checkers.') parser.add_argument('-s', '--setup', help="Run additional setup checks", action='store_true') @@ -274,27 +288,40 @@ def main(): groups = ['global'] groups += config.get('DEFAULT', 'targets').split(',') - if args.setup: - groups.append('setup') + groups.append('setup') for group in groups: print() - print("==================== {} ====================".format(group)) - if args.checkers == 'all': - configured_checkers = None - else: - configured_checkers = args.checkers.split(',') + print("{}==================== {} ===================={}".format( + col.Fore.YELLOW, group, col.Fore.RESET)) for name, func in checkers[group].items(): - if configured_checkers is None or name in configured_checkers: - print("------ {} ------".format(name)) + print("{}------ {} ------{}".format(col.Fore.CYAN, name, + col.Fore.RESET)) + if _checker_enabled(args, group, name): status = func() - exit_status['{}_{}'.format(group, name)] = status - - print("Exit status values:") + key = '{}_{}'.format(group, name) + exit_status[key] = status + if name == 'flake8': + # pyflakes uses True for errors and False for ok. + exit_status_bool[key] = not status + elif isinstance(status, bool): + exit_status_bool[key] = status + else: + # sys.exit(0) means no problems -> True, anything != 0 + # means problems. + exit_status_bool[key] = (status == 0) + else: + print("{}Checker disabled.{}".format( + col.Fore.BLUE, col.Fore.RESET)) + print() + print("{}Exit status values:{}".format(col.Fore.YELLOW, col.Fore.RESET)) for (k, v) in exit_status.items(): - print(' {} - {}'.format(k, v)) + ok = exit_status_bool[k] + color = col.Fore.GREEN if ok else col.Fore.RED + print('{} {} - {} ({}){}'.format(color, k, 'ok' if ok else 'FAIL', + v, col.Fore.RESET)) - if all(val in (True, 0) for val in exit_status): + if all(exit_status_bool): return 0 else: return 1