Coding style.

This commit is contained in:
Andrew Hamilton 2016-02-19 18:27:20 +00:00
parent 785d3b0bca
commit a03a47977f
2 changed files with 11 additions and 11 deletions

View file

@ -20,15 +20,15 @@ import stat
import subprocess import subprocess
import tempfile import tempfile
import time import time
import traceback
import lscolors
import pygments import pygments
import pygments.lexers import pygments.lexers
import pygments.styles import pygments.styles
import traceback
import fill3 import fill3
import gut import gut
import lscolors
import termstr import termstr
@ -55,8 +55,6 @@ _STATUS_COLORS = {Status.ok: termstr.Color.green,
Status.running: termstr.Color.light_blue, Status.running: termstr.Color.light_blue,
Status.paused: termstr.Color.yellow, Status.paused: termstr.Color.yellow,
Status.timed_out: termstr.Color.purple} Status.timed_out: termstr.Color.purple}
STATUS_MEANINGS = [ STATUS_MEANINGS = [
(Status.normal, "Normal"), (Status.ok, "Ok"), (Status.normal, "Normal"), (Status.ok, "Ok"),
(Status.problem, "Problem"), (Status.not_applicable, "Not applicable"), (Status.problem, "Problem"), (Status.not_applicable, "Not applicable"),
@ -300,9 +298,9 @@ _python_console_lexer = pygments.lexers.PythonConsoleLexer()
def python_unittests(path): def python_unittests(path):
if str(path).endswith("_test.py"): if str(path).endswith("_test.py"):
python_version = _python_version(path) command = ([path] if _has_shebang_line(path)
cmd = [path] if _has_shebang_line(path) else [python_version, path] else [_python_version(path), path])
stdout, stderr, returncode = _do_command(cmd, timeout=TIMEOUT) stdout, stderr, returncode = _do_command(command, timeout=TIMEOUT)
status = Status.ok if returncode == 0 else Status.problem status = Status.ok if returncode == 0 else Status.problem
native_style = pygments.styles.get_style_by_name("native") native_style = pygments.styles.get_style_by_name("native")
return status, _syntax_highlight(stderr, _python_console_lexer, return status, _syntax_highlight(stderr, _python_console_lexer,

10
vigil
View file

@ -919,8 +919,10 @@ def _update_screen(main_widget, appearance_changed_event):
fill3.patch_screen(main_widget) fill3.patch_screen(main_widget)
def main(root_path, worker_count=multiprocessing.cpu_count()*2, def main(root_path, worker_count=None, is_sandboxed=True, editor_command=None,
is_sandboxed=True, editor_command=None, is_being_tested=False): is_being_tested=False):
if worker_count is None:
worker_count = multiprocessing.cpu_count()*2
global _UPDATE_THREAD_STOPPED global _UPDATE_THREAD_STOPPED
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
jobs_added_event = threading.Event() jobs_added_event = threading.Event()
@ -1051,8 +1053,8 @@ def _check_arguments():
print(_get_help_text()) print(_get_help_text())
sys.exit(0) sys.exit(0)
try: try:
worker_count = (int(arguments["--workers"]) if arguments["--workers"] if arguments["--workers"] is not None:
is not None else multiprocessing.cpu_count() * 2) worker_count = int(arguments["--workers"])
except ValueError: except ValueError:
print("--workers requires a number.") print("--workers requires a number.")
sys.exit(1) sys.exit(1)