From 9285b53f953d755f0775f01efdd05a9d06e43e74 Mon Sep 17 00:00:00 2001 From: Chad Sharp Date: Sun, 10 Sep 2017 21:13:52 -0400 Subject: [PATCH 1/8] Fixed EOF messages --- check50.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/check50.py b/check50.py index 827da9ed..ce9e6f86 100755 --- a/check50.py +++ b/check50.py @@ -473,14 +473,15 @@ def stdout(self, output=None, str_output=None, timeout=1): else: expect = self.child.expect_exact + if str_output is None: + str_output = output + if output == EOF: - str_output = "EOF" + self.test.log.append("checking for EOF...") else: - if str_output is None: - str_output = output output = output.replace("\n", "\r\n") + self.test.log.append("checking for output \"{}\"...".format(str_output)) - self.test.log.append("checking for output \"{}\"...".format(str_output)) try: expect(output, timeout=timeout) @@ -490,7 +491,7 @@ def stdout(self, output=None, str_output=None, timeout=1): result += self.child.after raise Error(Mismatch(str_output, result.replace("\r\n", "\n"))) except TIMEOUT: - raise Error("did not find output {}".format(Mismatch.raw(str_output))) + raise Error("did not find {}".format(Mismatch.raw(str_output))) except UnicodeDecodeError: raise Error("output not valid ASCII text") except Exception: From 246cc0688b2ae55ed7bd82ed0674f074bb15ac93 Mon Sep 17 00:00:00 2001 From: Chad Sharp Date: Tue, 19 Sep 2017 23:54:51 -0400 Subject: [PATCH 2/8] Add segfault detection, bugfixes --- check50.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/check50.py b/check50.py index 827da9ed..dd4258c3 100755 --- a/check50.py +++ b/check50.py @@ -14,6 +14,7 @@ import re import requests import shutil +import signal import subprocess import sys import tempfile @@ -55,7 +56,6 @@ def main(): help="run checks completely offline (implies --local)") parser.add_argument("--checkdir", action="store", - nargs=1, default="~/.local/share/check50", help="specify directory containing the checks " "(~/.local/share/check50 by default)") @@ -67,7 +67,7 @@ def main(): help="display the full tracebacks of any errors") config.args = parser.parse_args() - config.args.checkdir = os.path.expanduser(config.args.checkdir) + config.args.checkdir = os.path.abspath(config.args.checkdir) identifier = config.args.identifier[0] files = config.args.files @@ -267,7 +267,6 @@ def import_checks(identifier): if not config.args.offline: if os.path.exists(checks_root): command = ["git", "-C", checks_root, "pull", "origin", "master"] - else: command = ["git", "clone", "https://github.com/{}/{}".format(org, repo), checks_root] @@ -553,6 +552,10 @@ def wait(self, timeout=1): self.output = "".join(self.output).replace("\r\n", "\n").lstrip("\n") self.kill() + + if self.child.signalstatus == signal.SIGSEGV: + raise Error("failed to execute program due to segmentation fault") + self.exitstatus = self.child.exitstatus return self From 8d9182e425fc8a530c17327ab3b8e4c63ba1a3a9 Mon Sep 17 00:00:00 2001 From: Brian Yu Date: Wed, 27 Sep 2017 00:57:09 -0400 Subject: [PATCH 3/8] Update running checks message --- check50.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/check50.py b/check50.py index 55fdfceb..7b1d0fe6 100755 --- a/check50.py +++ b/check50.py @@ -87,7 +87,7 @@ def main(): username, commit_hash = submit50.submit("check50", identifier) # Wait until payload comes back with check data. - print("Running checks...", end="") + print("Checking...", end="") sys.stdout.flush() pings = 0 while True: diff --git a/setup.py b/setup.py index a0a8c3ee..18cc370a 100644 --- a/setup.py +++ b/setup.py @@ -60,5 +60,5 @@ class CustomInstall(install): "console_scripts": ["check50=check50:main"] }, url="https://github.com/cs50/check50", - version="2.0.6" + version="2.0.7" ) From 052d3f864ec33b6abc8f9d01c589174466b79030 Mon Sep 17 00:00:00 2001 From: Brian Yu Date: Thu, 28 Sep 2017 19:41:46 -0400 Subject: [PATCH 4/8] Fix checkdir bug --- check50.py | 2 ++ setup.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/check50.py b/check50.py index 7b1d0fe6..8786a4ca 100755 --- a/check50.py +++ b/check50.py @@ -67,6 +67,8 @@ def main(): help="display the full tracebacks of any errors") config.args = parser.parse_args() + if isinstance(config.args.checkdir, list): + config.args.checkdir = config.args.checkdir[0] config.args.checkdir = os.path.expanduser(config.args.checkdir) identifier = config.args.identifier[0] files = config.args.files diff --git a/setup.py b/setup.py index 18cc370a..01395171 100644 --- a/setup.py +++ b/setup.py @@ -60,5 +60,5 @@ class CustomInstall(install): "console_scripts": ["check50=check50:main"] }, url="https://github.com/cs50/check50", - version="2.0.7" + version="2.0.8" ) From b55734c22a6192a6fa993ab6440c3a7c04f1d070 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Thu, 28 Sep 2017 21:03:45 -0400 Subject: [PATCH 5/8] ups version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 01395171..9d41e75b 100644 --- a/setup.py +++ b/setup.py @@ -60,5 +60,5 @@ class CustomInstall(install): "console_scripts": ["check50=check50:main"] }, url="https://github.com/cs50/check50", - version="2.0.8" + version="2.1.0" ) From a584bb4997bb5ea9364227a20946f78532bb5800 Mon Sep 17 00:00:00 2001 From: Chad Sharp Date: Thu, 28 Sep 2017 21:39:30 -0400 Subject: [PATCH 6/8] Added SIGINT handler --- check50.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/check50.py b/check50.py index a032d555..89b92d35 100755 --- a/check50.py +++ b/check50.py @@ -40,6 +40,7 @@ def main(): + signal.signal(signal.SIGINT, handler) # Parse command line arguments. parser = argparse.ArgumentParser() @@ -200,6 +201,11 @@ def excepthook(cls, exc, tb): sys.excepthook = excepthook +def handler(number, frame): + print() + sys.exit(1) + + def print_results(results, log=False): for result in results: if result["status"] == Checks.PASS: From 4310bd810d322cc7b6d61d43a0cfc0d94c6d5aa0 Mon Sep 17 00:00:00 2001 From: Chad Sharp Date: Thu, 28 Sep 2017 22:21:26 -0400 Subject: [PATCH 7/8] Use submit50 handler when possible --- check50.py | 5 ++++- setup.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/check50.py b/check50.py index 89b92d35..deaaef4c 100755 --- a/check50.py +++ b/check50.py @@ -84,6 +84,9 @@ def main(): raise InternalError( "submit50 is not installed. Install submit50 and run check50 again.") else: + submit50.handler.type = "check" + signal.signal(signal.SIGINT, submit50.handler) + submit50.run.verbose = config.args.verbose username, commit_hash = submit50.submit("check50", identifier) @@ -202,7 +205,7 @@ def excepthook(cls, exc, tb): def handler(number, frame): - print() + termcolor.cprint("Check cancelled.", "red") sys.exit(1) diff --git a/setup.py b/setup.py index 9d41e75b..329ec810 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ class CustomInstall(install): ], description="This is check50, with which you can check solutions to \ problems for CS50.", - install_requires=["argparse", "pexpect", "requests", "backports.shutil_which", "termcolor", "submit50"], + install_requires=["argparse", "pexpect", "requests", "backports.shutil_which", "termcolor", "submit50>=2.4.5"], keywords=["check", "check50"], name="check50", py_modules=["check50", "config"], @@ -60,5 +60,5 @@ class CustomInstall(install): "console_scripts": ["check50=check50:main"] }, url="https://github.com/cs50/check50", - version="2.1.0" + version="2.1.1" ) From 4a9128a66709d771a0ff6706cdd4b417517979e5 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Thu, 28 Sep 2017 22:23:29 -0400 Subject: [PATCH 8/8] corrected version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 329ec810..6f1f6001 100644 --- a/setup.py +++ b/setup.py @@ -60,5 +60,5 @@ class CustomInstall(install): "console_scripts": ["check50=check50:main"] }, url="https://github.com/cs50/check50", - version="2.1.1" + version="2.1.0" )