How to use the submit50.__main__.Error function in submit50

To help you get started, we’ve selected a few submit50 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cs50 / submit50 / submit50 / __main__.py View on Github external
def excepthook(type, value, tb):
    """Report an exception."""
    if (issubclass(type, Error) or issubclass(type, lib50.Error)) and str(value):
        for line in str(value).split("\n"):
            cprint(str(line), "yellow")
    elif not isinstance(value, KeyboardInterrupt):
        cprint(_("Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!"), "yellow")

    if excepthook.verbose:
        traceback.print_exception(type, value, tb)

    cprint(_("Submission cancelled."), "red")
github cs50 / submit50 / submit50 / __main__.py View on Github external
def __call__(self, parser, namespace, values, option_string=None):
        try:
            lib50.logout()
        except lib50.Error:
            raise Error(_("failed to logout"))
        else:
            cprint(_("logged out successfully"), "green")
        parser.exit()
github cs50 / submit50 / submit50 / __main__.py View on Github external
def check_version():
    """Check that submit50 is the latest version according to submit50.io."""
    # Retrieve version info
    res = requests.get(f"{SUBMIT_URL}/versions/submit50")
    if res.status_code != 200:
        raise Error(_("You have an unknown version of submit50. "
                      "Email sysadmins@cs50.harvard.edu!"))

    # Check that latest version == version installed
    required_version = pkg_resources.parse_version(res.text.strip())
    local_version = pkg_resources.parse_version(__version__)

    if required_version > local_version:
       raise Error(_("You have an outdated version of submit50. "
                     "Please upgrade."))
github cs50 / submit50 / submit50 / __main__.py View on Github external
def check_announcements():
    """Check for any announcements from submit.cs50.io, raise Error if so."""
    res = requests.get(f"{SUBMIT_URL}/status/submit50")
    if res.status_code == 200 and res.text.strip():
        raise Error(res.text.strip())
github cs50 / submit50 / submit50 / __main__.py View on Github external
def prompt(included, excluded):
    if included:
        cprint(_("Files that will be submitted:"), "green")
        for file in included:
            cprint("./{}".format(file), "green")
    else:
        raise Error(_("No files in this directory are expected for submission."))

    # Files that won't be submitted
    if excluded:
        cprint(_("Files that won't be submitted:"), "yellow")
        for other in excluded:
            cprint("./{}".format(other), "yellow")

    # Prompt for honesty
    readline.clear_history()
    try:
        answer = input(_("Keeping in mind the course's policy on academic honesty, "
                         "are you sure you want to submit these files (yes/no)? "))
    except EOFError:
        answer = None
        print()
    if not answer or not re.match(f"^\s*(?:{_('y|yes')})\s*$", answer, re.I):

submit50

This is submit50, with which you can submit solutions to problems for CS50.

GPL-3.0
Latest version published 4 months ago

Package Health Score

60 / 100
Full package analysis

Similar packages