Skip to content

Commit

Permalink
Merge pull request #74 from cs50/develop
Browse files Browse the repository at this point in the history
adds .data, fixes --checkdir
  • Loading branch information
Kareem Zidane authored Sep 29, 2017
2 parents b3bff14 + 4a9128a commit bd2ed81
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
31 changes: 22 additions & 9 deletions check50.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import re
import requests
import shutil
import signal
import subprocess
import sys
import tempfile
Expand All @@ -39,6 +40,7 @@


def main():
signal.signal(signal.SIGINT, handler)

# Parse command line arguments.
parser = argparse.ArgumentParser()
Expand All @@ -55,7 +57,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)")
Expand All @@ -67,7 +68,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

Expand All @@ -83,11 +84,14 @@ 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)

# Wait until payload comes back with check data.
print("Running checks...", end="")
print("Checking...", end="")
sys.stdout.flush()
pings = 0
while True:
Expand Down Expand Up @@ -200,6 +204,11 @@ def excepthook(cls, exc, tb):
sys.excepthook = excepthook


def handler(number, frame):
termcolor.cprint("Check cancelled.", "red")
sys.exit(1)


def print_results(results, log=False):
for result in results:
if result["status"] == Checks.PASS:
Expand Down Expand Up @@ -268,7 +277,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]

Expand Down Expand Up @@ -474,14 +482,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)
Expand All @@ -491,7 +500,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:
Expand Down Expand Up @@ -556,6 +565,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

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -60,5 +60,5 @@ class CustomInstall(install):
"console_scripts": ["check50=check50:main"]
},
url="https://github.com/cs50/check50",
version="2.0.6"
version="2.1.0"
)

0 comments on commit bd2ed81

Please sign in to comment.