From cb6122552a930896708070baaeaa1619343fa457 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Fri, 21 Jul 2017 21:50:25 -0400 Subject: [PATCH 01/27] replaced spinner with progress dots --- setup.py | 2 +- submit50.py | 75 ++++++++++++++++++++++++++--------------------------- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/setup.py b/setup.py index b5d7940..8d89e14 100644 --- a/setup.py +++ b/setup.py @@ -61,5 +61,5 @@ class CustomInstall(install): "console_scripts": ["submit50=submit50:main"] }, url="https://github.com/cs50/submit50", - version="2.3.0" + version="2.3.1" ) diff --git a/submit50.py b/submit50.py index 9451867..96c0b58 100644 --- a/submit50.py +++ b/submit50.py @@ -162,12 +162,12 @@ def rlinput(prompt, prefill=""): readline.set_startup_hook() # prompt for credentials - spin(False) # because not using cprint herein + progress(False) # because not using cprint herein if not password: # prompt for username, prefilling if possible while True: - spin(False) + progress(False) username = rlinput("GitHub username: ", username).strip() if username: break @@ -232,8 +232,8 @@ def rlinput(prompt, prefill=""): def cprint(text="", color=None, on_color=None, attrs=None, **kwargs): """Colorizes text (and wraps to terminal's width).""" - # stop spinner (if spinning) - spin(False) + # update progress + progress(False) # assume 80 in case not running in a terminal columns, _ = get_terminal_size() @@ -251,7 +251,7 @@ def cprint(text="", color=None, on_color=None, attrs=None, **kwargs): def excepthook(type, value, tb): """Report an exception.""" excepthook.ignore = False - spin(False) + progress(False) teardown() if type is Error and str(value): cprint(str(value), "yellow") @@ -270,8 +270,8 @@ def excepthook(type, value, tb): def handler(number, frame): """Handle SIGINT.""" os.system("stty sane") # in case signalled from input_with_prefill - if spin.spinning: - spin(False) + if progress.progressing: + progress(False) else: cprint() cprint("Submission cancelled.", "red") @@ -326,39 +326,37 @@ def run(command, cwd=None, env=None, lines=[], password=None, quiet=False): run.verbose = False -def spin(message=""): - """Display a spinning message.""" +def progress(message=""): + """Display a progress bar as dots.""" - # don't spin in verbose mode + # don't show in verbose mode if run.verbose: if message != False: print(message + "...") return - # stop spinning if already spinning - if spin.spinning: - spin.spinning = False - spin.thread.join() + # stop progressing if already progressing + if progress.progressing: + progress.progressing = False + progress.thread.join() + sys.stdout.write("\n") + sys.stdout.flush() - # start spinning if message passed + # display dots if message passed if message != False: - def spin_helper(): # https://stackoverflow.com/a/4995896 - spinner = itertools.cycle(["-", "\\", "|", "/"]) - sys.stdout.write(message + "... ") + def progress_helper(): # https://stackoverflow.com/a/4995896 + sys.stdout.write(message + "...") sys.stdout.flush() - while spin.spinning: - sys.stdout.write(next(spinner)) + while progress.progressing: + sys.stdout.write(".") sys.stdout.flush() - sys.stdout.write("\b") - time.sleep(0.1) - sys.stdout.write("\033[2K\r") - sys.stdout.flush() - spin.spinning = True - spin.thread = Thread(target=spin_helper) - spin.thread.start() + time.sleep(0.5) + progress.progressing = True + progress.thread = Thread(target=progress_helper) + progress.thread.start() -spin.spinning = False +progress.progressing = False def submit(org, problem): @@ -371,10 +369,11 @@ def submit(org, problem): version = subprocess.check_output(["git", "--version"]).decode("utf-8") matches = re.search(r"^git version (\d+\.\d+\.\d+).*$", version) if not matches or StrictVersion(matches.group(1)) < StrictVersion("2.7.0"): - raise Error("You have an old version of git. Install version 2.7 or later, then re-run submit50!") + raise Error("You have an old version of git. Install version 2.7 or later, " + + "then re-run submit50!") - # update spinner - spin("Connecting") + # update progress + progress("Connecting") # compute timestamp global timestamp @@ -427,8 +426,8 @@ def submit(org, problem): cprint(" {}".format(pattern)) raise Error("Ensure you have the required files before submitting.") - # update spinner - spin("Authenticating") + # update progress + progress("Authenticating") # authenticate user via SSH try: @@ -437,7 +436,7 @@ def submit(org, problem): email = "{}@users.noreply.github.com".format(username) repo = "git@github.com:{}/{}.git".format(org, username) with open(os.devnull, "w") as DEVNULL: - spin(False) + progress(False) assert subprocess.call(["ssh", "git@github.com"], stderr=DEVNULL) == 1 # successfully authenticated # authenticate user via HTTPS @@ -445,8 +444,8 @@ def submit(org, problem): username, password, email = authenticate(org) repo = "https://{}@github.com/{}/{}".format(username, org, username) - # update spinner - spin("Preparing") + # update progress + progress("Preparing") # clone repository try: @@ -497,8 +496,8 @@ def submit(org, problem): if not re.match("^\s*(?:y|yes)\s*$", input(), re.I): raise Error("No files were submitted.") - # restart spinner - spin("Submitting") + # update progress + progress("Submitting") # push branch run("git commit --allow-empty --message='{}'".format(timestamp)) From dfe890d02a5cc5b93aca9b7e0a0d1fa539168097 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 02:29:33 -0400 Subject: [PATCH 02/27] added locale/ --- README.md | 84 ++++++++++--------- locale/es/LC_MESSAGES/messages.po | 133 ++++++++++++++++++++++++++++++ setup.py | 2 +- submit50.py | 85 ++++++++++--------- 4 files changed, 223 insertions(+), 81 deletions(-) create mode 100644 locale/es/LC_MESSAGES/messages.po diff --git a/README.md b/README.md index f0a767f..36b208b 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,51 @@ [![Build Status](https://travis-ci.org/cs50/submit50.svg?branch=master)](https://travis-ci.org/cs50/submit50) +# Usage + +## English + +``` +submit50 problem +``` + +### Spanish + +``` +LANGUAGE=es submit50 problem +``` + +# Internationalizing + +## Creating PO for language XX + +``` +xgettext submit50.py +sed -i -e '1,6d' messages.po +sed -i -e '3,10d' messages.po +sed -i 's/CHARSET/UTF-8/' messages.po +vim messages.po # translate strings to XX +msgfmt messages.po +mkdir -p locale/XX/LC_MESSAGES +mv messages.mo messages.po locale/XX/LC_MESSAGES/ +``` + +## Updating PO for language XX + +Source: https://stackoverflow.com/a/7497395 + +``` +echo "" > messages.po +find . -type f -iname "*.py" | xgettext -j -f - +msgmerge -N locale/XX/LC_MESSAGES/messages.po messages.po > new.po +mv new.po messages.po +msgfmt messages.po +mv -f messages.mo messages.po locale/XX/LC_MESSAGES/ +``` + # Contributing ``` pip install -e . ``` -TODO... - -# TODO - -* Client - * Remove tag once handled by server. -* Server - * Tag latest commit. - * Release latest commit. - * Update default branch. - -# CHANGELOG - -* 2.1.4 - * Fix problem with two-factor authentication. - * Avoid printing "Submission cancelled" when it's inappropriate. -* 2.1.3 - * Canonicalizd username after login to allow login via email. - * Generalized finding path to python3. -* 2.1.2 - * Added more error handling to `submit50 --checkout`. - * Updated messages displayed to user to direct them to CS50.me. -* 2.1.1 - * Suppressed student compile flags while installing getch. -* 2.1.0 - * TBD -* 2.0.0 - * Ported to Python. - * Added support for two-factor authentication. - * Added course identifier as prefix to branches and tags. - * Added support for --checkout of specific usernames. - * Hid diagnostic output unless --verbose flag is used. - * Added check for version file. -* 1.1.0 - * Added support for expecting and ignoring files. - * Added support for logging in via email address. - * Added check for whether problem exists. - * Fixed bugs whereby spaces or dollar signs in usernames broke login. - * Fixed bug whereby pushes would fail if email address not yet confirmed. -* 1.0.3 - * Initial commit. +TODO diff --git a/locale/es/LC_MESSAGES/messages.po b/locale/es/LC_MESSAGES/messages.po new file mode 100644 index 0000000..4026826 --- /dev/null +++ b/locale/es/LC_MESSAGES/messages.po @@ -0,0 +1,133 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: submit50.py:46 +msgid "You have an old version of python. Install version 2.7 or higher." +msgstr "" + +#: submit50.py:117 +msgid "show commands being executed" +msgstr "" + +#: submit50.py:118 +msgid "problem to submit" +msgstr "" + +#: submit50.py:179 +msgid "GitHub username: " +msgstr "Nombre de usuario de GitHub: " + +#: submit50.py:185 +msgid "Contraseña de GitHub: " +msgstr "" + +#: submit50.py:219 +msgid "Invalid username and/or password." +msgstr "" + +#: submit50.py:223 +msgid "Could not authenticate user." +msgstr "" + +#: submit50.py:267 +msgid "Could not connect to GitHub." +msgstr "" + +#: submit50.py:271 +msgid "Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!" +msgstr "" + +#: submit50.py:272 submit50.py:285 +msgid "Submission cancelled." +msgstr "" + +#: submit50.py:378 +msgid "You don't have git. Install git, then re-run submit50!." +msgstr "" + +#: submit50.py:382 +msgid "" +"You have an old version of git. Install version 2.7 or later, then re-run " +"submit50!" +msgstr "" + +#: submit50.py:396 +msgid "" +"You have an unknown version of submit50. Email sysadmins@cs50.harvard.edu!" +msgstr "" + +#: submit50.py:400 +msgid "" +"You have an old version of submit50. Run update50, then re-run submit50!" +msgstr "" + +#: submit50.py:417 +msgid "Invalid problem. Did you mean to submit something else?" +msgstr "" + +#: submit50.py:433 +msgid "You seem to be missing these files:" +msgstr "" + +#: submit50.py:436 +msgid "Ensure you have the required files before submitting." +msgstr "" + +#: submit50.py:439 +msgid "Authenticating" +msgstr "" + +#: submit50.py:457 +msgid "Preparing" +msgstr "" + +#: submit50.py:464 +msgid "" +"Looks like submit50 isn't enabled for your account yet. Log into https://" +"cs50.me/ in a browser, click \"Authorize application\", and re-run submit50 " +"here!" +msgstr "" + +#: submit50.py:467 +msgid "" +"Looks like you have the wrong username in ~/.gitconfig or submit50 isn't yet " +"enabled for your account. Double-check ~/.gitconfig and then log into " +"https://cs50.me/ in a browser, click \"Authorize application\" if prompted, " +"and re-run submit50 here." +msgstr "" + +#: submit50.py:491 +msgid "No files in this directory are expected for submission." +msgstr "" + +#: submit50.py:492 +msgid "Files that will be submitted:" +msgstr "" + +#: submit50.py:498 +msgid "Files that won't be submitted:" +msgstr "" + +#: submit50.py:503 +msgid "" +"Keeping in mind the course's policy on academic honesty, are you sure you " +"want to submit these files?" +msgstr "" + +#: submit50.py:506 +msgid "No files were submitted." +msgstr "" + +#: submit50.py:509 +msgid "Submitting" +msgstr "" + +#: submit50.py:516 +msgid "Submitted {}! See https://cs50.me/submissions/{}." +msgstr "" + +#: submit50.py:552 +msgid "Could not complete two-factor authentication." +msgstr "" diff --git a/setup.py b/setup.py index b5d7940..ba9cb47 100644 --- a/setup.py +++ b/setup.py @@ -61,5 +61,5 @@ class CustomInstall(install): "console_scripts": ["submit50=submit50:main"] }, url="https://github.com/cs50/submit50", - version="2.3.0" + version="2.4.0" ) diff --git a/submit50.py b/submit50.py index 9451867..152a455 100644 --- a/submit50.py +++ b/submit50.py @@ -4,8 +4,10 @@ import atexit import datetime import distutils +import gettext import itertools import json +import locale import os import pexpect import pipes @@ -32,15 +34,20 @@ from six.moves import urllib from threading import Thread +# internationalization +gettext.bindtextdomain("messages", os.path.join(sys.path[0], "locale")) +gettext.textdomain("messages") +_ = gettext.gettext + +# globals # require python 2.7+ if sys.version_info < (2, 7): - sys.exit("You have an old version of python. Install version 2.7 or higher.") + sys.exit(_("You have an old version of python. Install version 2.7 or higher.")) if sys.version_info < (3, 0): input = raw_input if not hasattr(shlex, "quote"): shlex.quote = pipes.quote -# globals ORG = "submit50" timestamp = None @@ -106,8 +113,8 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument("-v", "--verbose", action="store_true", - help="show commands being executed") - parser.add_argument("problem", help="problem to submit") + help=_("show commands being executed")) + parser.add_argument("problem", help=_("problem to submit")) args = vars(parser.parse_args()) # submit50 -v @@ -168,13 +175,13 @@ def rlinput(prompt, prefill=""): # prompt for username, prefilling if possible while True: spin(False) - username = rlinput("GitHub username: ", username).strip() + username = rlinput(_("GitHub username: "), username).strip() if username: break # prompt for password while True: - print("GitHub password: ", end="", flush=True) + print(_("GitHub password: "), end="", flush=True) password = str() while True: ch = getch() @@ -208,11 +215,11 @@ def rlinput(prompt, prefill=""): # check if incorrect password if res.status_code == 401: - raise Error("Invalid username and/or password.") + raise Error(_("Invalid username and/or password.")) # check for other error elif res.status_code != 200: - raise Error("Could not authenticate user.") + raise Error(_("Could not authenticate user.")) # canonicalize (capitalization of) username, # especially if user logged in via email address @@ -256,12 +263,12 @@ def excepthook(type, value, tb): if type is Error and str(value): cprint(str(value), "yellow") elif type is requests.exceptions.ConnectionError: - cprint("Could not connect to GitHub.", "yellow") + cprint(_("Could not connect to GitHub."), "yellow") else: if run.verbose: traceback.print_exception(type, value, tb) - cprint("Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!", "yellow") - cprint("Submission cancelled.", "red") + cprint(_("Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!"), "yellow") + cprint(_("Submission cancelled."), "red") sys.excepthook = excepthook @@ -274,7 +281,7 @@ def handler(number, frame): spin(False) else: cprint() - cprint("Submission cancelled.", "red") + cprint(_("Submission cancelled."), "red") os._exit(0) @@ -367,11 +374,11 @@ def submit(org, problem): # require git 2.7+, so that credential-cache--daemon ignores SIGHUP # https://github.com/git/git/blob/v2.7.0/credential-cache--daemon.c if not which("git"): - raise Error("You don't have git. Install git, then re-run submit50!.") + raise Error(_("You don't have git. Install git, then re-run submit50!.")) version = subprocess.check_output(["git", "--version"]).decode("utf-8") matches = re.search(r"^git version (\d+\.\d+\.\d+).*$", version) if not matches or StrictVersion(matches.group(1)) < StrictVersion("2.7.0"): - raise Error("You have an old version of git. Install version 2.7 or later, then re-run submit50!") + raise Error(_("You have an old version of git. Install version 2.7 or later, then re-run submit50!")) # update spinner spin("Connecting") @@ -385,12 +392,12 @@ def submit(org, problem): # check version res = requests.get("https://cs50.me/versions/submit50") if res.status_code != 200: - raise Error("You have an unknown version of submit50. " + - "Email sysadmins@cs50.harvard.edu!") + raise Error(_("You have an unknown version of submit50. " + "Email sysadmins@cs50.harvard.edu!")) version_required = res.text.strip() if parse_version(version_required) > parse_version(get_distribution("submit50").version): - raise Error("You have an old version of submit50. " + - "Run update50, then re-run submit50!") + raise Error(_("You have an old version of submit50. " + "Run update50, then re-run submit50!")) # assume cs50/ problem if problem name begins with a year branch = problem @@ -398,7 +405,7 @@ def submit(org, problem): branch = os.path.join("cs50", problem) # ensure problem exists - _, submit.EXCLUDE = tempfile.mkstemp() + TODO, submit.EXCLUDE = tempfile.mkstemp() url = "https://cs50.me/excludes/{}/".format(branch) try: urllib.request.urlretrieve(url, filename=submit.EXCLUDE) @@ -406,7 +413,7 @@ def submit(org, problem): except Exception as e: if run.verbose: cprint(str(e)) - e = Error("Invalid problem. Did you mean to submit something else?") + e = Error(_("Invalid problem. Did you mean to submit something else?")) e.__cause__ = None raise e @@ -422,13 +429,13 @@ def submit(org, problem): elif not os.path.isfile(pattern): missing.append(pattern) if missing: - cprint("You seem to be missing these files:") + cprint(_("You seem to be missing these files:")) for pattern in missing: cprint(" {}".format(pattern)) - raise Error("Ensure you have the required files before submitting.") + raise Error(_("Ensure you have the required files before submitting.")) # update spinner - spin("Authenticating") + spin(_("Authenticating")) # authenticate user via SSH try: @@ -446,19 +453,19 @@ def submit(org, problem): repo = "https://{}@github.com/{}/{}".format(username, org, username) # update spinner - spin("Preparing") + spin(_("Preparing")) # clone repository try: run("git clone --bare {} {}".format(shlex.quote(repo), shlex.quote(run.GIT_DIR)), password=password) except: if password: - e = Error("Looks like submit50 isn't enabled for your account yet. " + - "Log into https://cs50.me/ in a browser, click \"Authorize application\", and re-run submit50 here!") + e = Error(_("Looks like submit50 isn't enabled for your account yet. " + "Log into https://cs50.me/ in a browser, click \"Authorize application\", and re-run submit50 here!")) else: - e = Error("Looks like you have the wrong username in ~/.gitconfig or submit50 isn't yet enabled for your account. " + - "Double-check ~/.gitconfig and then log into https://cs50.me/ in a browser, " + - "click \"Authorize application\" if prompted, and re-run submit50 here.") + e = Error(_("Looks like you have the wrong username in ~/.gitconfig or submit50 isn't yet enabled for your account. " + "Double-check ~/.gitconfig and then log into https://cs50.me/ in a browser, " + "click \"Authorize application\" if prompted, and re-run submit50 here.")) e.__cause__ = None raise e @@ -480,33 +487,33 @@ def submit(org, problem): # files that will be submitted if len(files) == 0: - raise Error("No files in this directory are expected for submission.") - cprint("Files that will be submitted:", "green") + raise Error(_("No files in this directory are expected for submission.")) + cprint(_("Files that will be submitted:"), "green") for f in files: cprint("./{}".format(f), "green") # files that won't be submitted if len(other) != 0: - cprint("Files that won't be submitted:", "yellow") + cprint(_("Files that won't be submitted:"), "yellow") for f in other: cprint("./{}".format(f), "yellow") # prompt for academic honesty - cprint("Keeping in mind the course's policy on academic honesty, " + - "are you sure you want to submit these files?", end=" ") + cprint(_("Keeping in mind the course's policy on academic honesty, " + "are you sure you want to submit these files?"), end=" ") if not re.match("^\s*(?:y|yes)\s*$", input(), re.I): - raise Error("No files were submitted.") + raise Error(_("No files were submitted.")) # restart spinner - spin("Submitting") + spin(_("Submitting")) # push branch run("git commit --allow-empty --message='{}'".format(timestamp)) run("git push origin 'refs/heads/{}'".format(branch), password=password) # successful submission - cprint("Submitted {}! ".format(problem) + - "See https://cs50.me/submissions/{}.".format(branch), + cprint(_("Submitted {}! " + "See https://cs50.me/submissions/{}.").format(problem, branch), "green") @@ -541,7 +548,7 @@ def two_factor(org, username, password): if res.status_code == 201 and "token" in res.json(): return res.json()["token"] else: - raise Error("Could not complete two-factor authentication.") + raise Error(_("Could not complete two-factor authentication.")) if __name__ == "__main__": From b758b86ea35d162c82629572cf8eb82cc0298816 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 02:29:47 -0400 Subject: [PATCH 03/27] blacklisting machine objects --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c77caf0..5c9af13 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ __pycache__ build/ *.egg-info/ dist/ +locale/*/LC_MESSAGES/*.mo From 757a4b07e7a10acee6e49bc86da00540a3d7edf9 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 02:32:58 -0400 Subject: [PATCH 04/27] added references --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 36b208b..f8c723c 100644 --- a/README.md +++ b/README.md @@ -49,3 +49,8 @@ pip install -e . ``` TODO + +# References + +- https://books.google.com/books?id=kQom0WiUbZQC&pg=PA215&lpg=PA215&dq=python+gettext+class&source=bl&ots=mttyXZyZan&sig=OENd8tbqVpxWIpRIWrE84hQY8jo&hl=en&sa=X&ved=0ahUKEwjTnY3WmJzVAhWJMj4KHR_PBR8Q6AEIWTAH#v=onepage&q=python%20gettext%20class&f=false +- https://stackoverflow.com/questions/7496156/gettext-how-to-update-po-and-pot-files-after-the-source-is-modified From 12c686b53986a19ac820a464d552fa69247ad99d Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 02:35:19 -0400 Subject: [PATCH 05/27] fixed password str --- locale/es/LC_MESSAGES/messages.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/es/LC_MESSAGES/messages.po b/locale/es/LC_MESSAGES/messages.po index 4026826..e043c91 100644 --- a/locale/es/LC_MESSAGES/messages.po +++ b/locale/es/LC_MESSAGES/messages.po @@ -20,8 +20,8 @@ msgid "GitHub username: " msgstr "Nombre de usuario de GitHub: " #: submit50.py:185 -msgid "Contraseña de GitHub: " -msgstr "" +msgid "GitHub password: " +msgstr "Contraseña de GitHub: " #: submit50.py:219 msgid "Invalid username and/or password." From 43dcd036325556e5aa49e156aedd84258432972d Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 02:38:46 -0400 Subject: [PATCH 06/27] removed locale --- submit50.py | 1 - 1 file changed, 1 deletion(-) diff --git a/submit50.py b/submit50.py index 152a455..1c9a6fb 100644 --- a/submit50.py +++ b/submit50.py @@ -7,7 +7,6 @@ import gettext import itertools import json -import locale import os import pexpect import pipes From 338a6f021b5626a1e11e12cc8208dd4c25429138 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 12:58:38 -0400 Subject: [PATCH 07/27] fixed capitalization, naming --- submit50.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/submit50.py b/submit50.py index 1c9a6fb..1df12ac 100644 --- a/submit50.py +++ b/submit50.py @@ -33,7 +33,7 @@ from six.moves import urllib from threading import Thread -# internationalization +# Internationalization gettext.bindtextdomain("messages", os.path.join(sys.path[0], "locale")) gettext.textdomain("messages") _ = gettext.gettext @@ -242,7 +242,7 @@ def cprint(text="", color=None, on_color=None, attrs=None, **kwargs): spin(False) # assume 80 in case not running in a terminal - columns, _ = get_terminal_size() + columns, lines = get_terminal_size() if columns == 0: columns = 80 # because get_terminal_size's default fallback doesn't work in pipes # only python3 supports "flush" keyword argument From 5d37c76f1e72770e13518fef838f84198466c693 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 13:13:12 -0400 Subject: [PATCH 08/27] removed Spanish file --- locale/es/LC_MESSAGES/messages.po | 133 ------------------------------ submit50.py | 2 +- 2 files changed, 1 insertion(+), 134 deletions(-) delete mode 100644 locale/es/LC_MESSAGES/messages.po diff --git a/locale/es/LC_MESSAGES/messages.po b/locale/es/LC_MESSAGES/messages.po deleted file mode 100644 index e043c91..0000000 --- a/locale/es/LC_MESSAGES/messages.po +++ /dev/null @@ -1,133 +0,0 @@ -msgid "" -msgstr "" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: submit50.py:46 -msgid "You have an old version of python. Install version 2.7 or higher." -msgstr "" - -#: submit50.py:117 -msgid "show commands being executed" -msgstr "" - -#: submit50.py:118 -msgid "problem to submit" -msgstr "" - -#: submit50.py:179 -msgid "GitHub username: " -msgstr "Nombre de usuario de GitHub: " - -#: submit50.py:185 -msgid "GitHub password: " -msgstr "Contraseña de GitHub: " - -#: submit50.py:219 -msgid "Invalid username and/or password." -msgstr "" - -#: submit50.py:223 -msgid "Could not authenticate user." -msgstr "" - -#: submit50.py:267 -msgid "Could not connect to GitHub." -msgstr "" - -#: submit50.py:271 -msgid "Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!" -msgstr "" - -#: submit50.py:272 submit50.py:285 -msgid "Submission cancelled." -msgstr "" - -#: submit50.py:378 -msgid "You don't have git. Install git, then re-run submit50!." -msgstr "" - -#: submit50.py:382 -msgid "" -"You have an old version of git. Install version 2.7 or later, then re-run " -"submit50!" -msgstr "" - -#: submit50.py:396 -msgid "" -"You have an unknown version of submit50. Email sysadmins@cs50.harvard.edu!" -msgstr "" - -#: submit50.py:400 -msgid "" -"You have an old version of submit50. Run update50, then re-run submit50!" -msgstr "" - -#: submit50.py:417 -msgid "Invalid problem. Did you mean to submit something else?" -msgstr "" - -#: submit50.py:433 -msgid "You seem to be missing these files:" -msgstr "" - -#: submit50.py:436 -msgid "Ensure you have the required files before submitting." -msgstr "" - -#: submit50.py:439 -msgid "Authenticating" -msgstr "" - -#: submit50.py:457 -msgid "Preparing" -msgstr "" - -#: submit50.py:464 -msgid "" -"Looks like submit50 isn't enabled for your account yet. Log into https://" -"cs50.me/ in a browser, click \"Authorize application\", and re-run submit50 " -"here!" -msgstr "" - -#: submit50.py:467 -msgid "" -"Looks like you have the wrong username in ~/.gitconfig or submit50 isn't yet " -"enabled for your account. Double-check ~/.gitconfig and then log into " -"https://cs50.me/ in a browser, click \"Authorize application\" if prompted, " -"and re-run submit50 here." -msgstr "" - -#: submit50.py:491 -msgid "No files in this directory are expected for submission." -msgstr "" - -#: submit50.py:492 -msgid "Files that will be submitted:" -msgstr "" - -#: submit50.py:498 -msgid "Files that won't be submitted:" -msgstr "" - -#: submit50.py:503 -msgid "" -"Keeping in mind the course's policy on academic honesty, are you sure you " -"want to submit these files?" -msgstr "" - -#: submit50.py:506 -msgid "No files were submitted." -msgstr "" - -#: submit50.py:509 -msgid "Submitting" -msgstr "" - -#: submit50.py:516 -msgid "Submitted {}! See https://cs50.me/submissions/{}." -msgstr "" - -#: submit50.py:552 -msgid "Could not complete two-factor authentication." -msgstr "" diff --git a/submit50.py b/submit50.py index 1df12ac..fa1a810 100644 --- a/submit50.py +++ b/submit50.py @@ -404,7 +404,7 @@ def submit(org, problem): branch = os.path.join("cs50", problem) # ensure problem exists - TODO, submit.EXCLUDE = tempfile.mkstemp() + file, submit.EXCLUDE = tempfile.mkstemp() url = "https://cs50.me/excludes/{}/".format(branch) try: urllib.request.urlretrieve(url, filename=submit.EXCLUDE) From 5bd750e11a0454aaf355e6f0a2dd756205ac0c66 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 13:13:29 -0400 Subject: [PATCH 09/27] added Spanish file --- locale/es/LC_MESSAGES/messages.mo | Bin 0 -> 202 bytes locale/es/LC_MESSAGES/messages.po | 133 ++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 locale/es/LC_MESSAGES/messages.mo create mode 100644 locale/es/LC_MESSAGES/messages.po diff --git a/locale/es/LC_MESSAGES/messages.mo b/locale/es/LC_MESSAGES/messages.mo new file mode 100644 index 0000000000000000000000000000000000000000..3f8244dccbe78783717f02796c862cbae07b08a7 GIT binary patch literal 202 zcmX}lO$x#=5Cz~Wy6H~W3ORtqZK=8vwJTAm2T0RV19no-e0kP}Sc3^^E>!v_Ws5_bC>tmIv(x|Tfanlcq_9SgA}#j8Op^ps`u z(3V%q+_i5>HkV?bq;WszHMdvt$&QVyEZ;JfmR92E=<3pwstDIR?X3&t{~zA`01MMC A-2eap literal 0 HcmV?d00001 diff --git a/locale/es/LC_MESSAGES/messages.po b/locale/es/LC_MESSAGES/messages.po new file mode 100644 index 0000000..e043c91 --- /dev/null +++ b/locale/es/LC_MESSAGES/messages.po @@ -0,0 +1,133 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: submit50.py:46 +msgid "You have an old version of python. Install version 2.7 or higher." +msgstr "" + +#: submit50.py:117 +msgid "show commands being executed" +msgstr "" + +#: submit50.py:118 +msgid "problem to submit" +msgstr "" + +#: submit50.py:179 +msgid "GitHub username: " +msgstr "Nombre de usuario de GitHub: " + +#: submit50.py:185 +msgid "GitHub password: " +msgstr "Contraseña de GitHub: " + +#: submit50.py:219 +msgid "Invalid username and/or password." +msgstr "" + +#: submit50.py:223 +msgid "Could not authenticate user." +msgstr "" + +#: submit50.py:267 +msgid "Could not connect to GitHub." +msgstr "" + +#: submit50.py:271 +msgid "Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!" +msgstr "" + +#: submit50.py:272 submit50.py:285 +msgid "Submission cancelled." +msgstr "" + +#: submit50.py:378 +msgid "You don't have git. Install git, then re-run submit50!." +msgstr "" + +#: submit50.py:382 +msgid "" +"You have an old version of git. Install version 2.7 or later, then re-run " +"submit50!" +msgstr "" + +#: submit50.py:396 +msgid "" +"You have an unknown version of submit50. Email sysadmins@cs50.harvard.edu!" +msgstr "" + +#: submit50.py:400 +msgid "" +"You have an old version of submit50. Run update50, then re-run submit50!" +msgstr "" + +#: submit50.py:417 +msgid "Invalid problem. Did you mean to submit something else?" +msgstr "" + +#: submit50.py:433 +msgid "You seem to be missing these files:" +msgstr "" + +#: submit50.py:436 +msgid "Ensure you have the required files before submitting." +msgstr "" + +#: submit50.py:439 +msgid "Authenticating" +msgstr "" + +#: submit50.py:457 +msgid "Preparing" +msgstr "" + +#: submit50.py:464 +msgid "" +"Looks like submit50 isn't enabled for your account yet. Log into https://" +"cs50.me/ in a browser, click \"Authorize application\", and re-run submit50 " +"here!" +msgstr "" + +#: submit50.py:467 +msgid "" +"Looks like you have the wrong username in ~/.gitconfig or submit50 isn't yet " +"enabled for your account. Double-check ~/.gitconfig and then log into " +"https://cs50.me/ in a browser, click \"Authorize application\" if prompted, " +"and re-run submit50 here." +msgstr "" + +#: submit50.py:491 +msgid "No files in this directory are expected for submission." +msgstr "" + +#: submit50.py:492 +msgid "Files that will be submitted:" +msgstr "" + +#: submit50.py:498 +msgid "Files that won't be submitted:" +msgstr "" + +#: submit50.py:503 +msgid "" +"Keeping in mind the course's policy on academic honesty, are you sure you " +"want to submit these files?" +msgstr "" + +#: submit50.py:506 +msgid "No files were submitted." +msgstr "" + +#: submit50.py:509 +msgid "Submitting" +msgstr "" + +#: submit50.py:516 +msgid "Submitted {}! See https://cs50.me/submissions/{}." +msgstr "" + +#: submit50.py:552 +msgid "Could not complete two-factor authentication." +msgstr "" From 008c7b74e92410f30b43e9f4ff06f9612f465670 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 13:13:53 -0400 Subject: [PATCH 10/27] removed MO --- locale/es/LC_MESSAGES/messages.mo | Bin 202 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 locale/es/LC_MESSAGES/messages.mo diff --git a/locale/es/LC_MESSAGES/messages.mo b/locale/es/LC_MESSAGES/messages.mo deleted file mode 100644 index 3f8244dccbe78783717f02796c862cbae07b08a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 202 zcmX}lO$x#=5Cz~Wy6H~W3ORtqZK=8vwJTAm2T0RV19no-e0kP}Sc3^^E>!v_Ws5_bC>tmIv(x|Tfanlcq_9SgA}#j8Op^ps`u z(3V%q+_i5>HkV?bq;WszHMdvt$&QVyEZ;JfmR92E=<3pwstDIR?X3&t{~zA`01MMC A-2eap From 2414a67a55563be3da79a4bd096abb3434071823 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 13:14:24 -0400 Subject: [PATCH 11/27] removed Spanish file --- locale/es/LC_MESSAGES/messages.po | 133 ------------------------------ 1 file changed, 133 deletions(-) delete mode 100644 locale/es/LC_MESSAGES/messages.po diff --git a/locale/es/LC_MESSAGES/messages.po b/locale/es/LC_MESSAGES/messages.po deleted file mode 100644 index e043c91..0000000 --- a/locale/es/LC_MESSAGES/messages.po +++ /dev/null @@ -1,133 +0,0 @@ -msgid "" -msgstr "" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: submit50.py:46 -msgid "You have an old version of python. Install version 2.7 or higher." -msgstr "" - -#: submit50.py:117 -msgid "show commands being executed" -msgstr "" - -#: submit50.py:118 -msgid "problem to submit" -msgstr "" - -#: submit50.py:179 -msgid "GitHub username: " -msgstr "Nombre de usuario de GitHub: " - -#: submit50.py:185 -msgid "GitHub password: " -msgstr "Contraseña de GitHub: " - -#: submit50.py:219 -msgid "Invalid username and/or password." -msgstr "" - -#: submit50.py:223 -msgid "Could not authenticate user." -msgstr "" - -#: submit50.py:267 -msgid "Could not connect to GitHub." -msgstr "" - -#: submit50.py:271 -msgid "Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!" -msgstr "" - -#: submit50.py:272 submit50.py:285 -msgid "Submission cancelled." -msgstr "" - -#: submit50.py:378 -msgid "You don't have git. Install git, then re-run submit50!." -msgstr "" - -#: submit50.py:382 -msgid "" -"You have an old version of git. Install version 2.7 or later, then re-run " -"submit50!" -msgstr "" - -#: submit50.py:396 -msgid "" -"You have an unknown version of submit50. Email sysadmins@cs50.harvard.edu!" -msgstr "" - -#: submit50.py:400 -msgid "" -"You have an old version of submit50. Run update50, then re-run submit50!" -msgstr "" - -#: submit50.py:417 -msgid "Invalid problem. Did you mean to submit something else?" -msgstr "" - -#: submit50.py:433 -msgid "You seem to be missing these files:" -msgstr "" - -#: submit50.py:436 -msgid "Ensure you have the required files before submitting." -msgstr "" - -#: submit50.py:439 -msgid "Authenticating" -msgstr "" - -#: submit50.py:457 -msgid "Preparing" -msgstr "" - -#: submit50.py:464 -msgid "" -"Looks like submit50 isn't enabled for your account yet. Log into https://" -"cs50.me/ in a browser, click \"Authorize application\", and re-run submit50 " -"here!" -msgstr "" - -#: submit50.py:467 -msgid "" -"Looks like you have the wrong username in ~/.gitconfig or submit50 isn't yet " -"enabled for your account. Double-check ~/.gitconfig and then log into " -"https://cs50.me/ in a browser, click \"Authorize application\" if prompted, " -"and re-run submit50 here." -msgstr "" - -#: submit50.py:491 -msgid "No files in this directory are expected for submission." -msgstr "" - -#: submit50.py:492 -msgid "Files that will be submitted:" -msgstr "" - -#: submit50.py:498 -msgid "Files that won't be submitted:" -msgstr "" - -#: submit50.py:503 -msgid "" -"Keeping in mind the course's policy on academic honesty, are you sure you " -"want to submit these files?" -msgstr "" - -#: submit50.py:506 -msgid "No files were submitted." -msgstr "" - -#: submit50.py:509 -msgid "Submitting" -msgstr "" - -#: submit50.py:516 -msgid "Submitted {}! See https://cs50.me/submissions/{}." -msgstr "" - -#: submit50.py:552 -msgid "Could not complete two-factor authentication." -msgstr "" From b3298878463e82c82d37ce5e3b5575f873ac875c Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 13:14:39 -0400 Subject: [PATCH 12/27] added Spanish file --- locale/es/LC_MESSAGES/messages.po | 133 ++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 locale/es/LC_MESSAGES/messages.po diff --git a/locale/es/LC_MESSAGES/messages.po b/locale/es/LC_MESSAGES/messages.po new file mode 100644 index 0000000..e043c91 --- /dev/null +++ b/locale/es/LC_MESSAGES/messages.po @@ -0,0 +1,133 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: submit50.py:46 +msgid "You have an old version of python. Install version 2.7 or higher." +msgstr "" + +#: submit50.py:117 +msgid "show commands being executed" +msgstr "" + +#: submit50.py:118 +msgid "problem to submit" +msgstr "" + +#: submit50.py:179 +msgid "GitHub username: " +msgstr "Nombre de usuario de GitHub: " + +#: submit50.py:185 +msgid "GitHub password: " +msgstr "Contraseña de GitHub: " + +#: submit50.py:219 +msgid "Invalid username and/or password." +msgstr "" + +#: submit50.py:223 +msgid "Could not authenticate user." +msgstr "" + +#: submit50.py:267 +msgid "Could not connect to GitHub." +msgstr "" + +#: submit50.py:271 +msgid "Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!" +msgstr "" + +#: submit50.py:272 submit50.py:285 +msgid "Submission cancelled." +msgstr "" + +#: submit50.py:378 +msgid "You don't have git. Install git, then re-run submit50!." +msgstr "" + +#: submit50.py:382 +msgid "" +"You have an old version of git. Install version 2.7 or later, then re-run " +"submit50!" +msgstr "" + +#: submit50.py:396 +msgid "" +"You have an unknown version of submit50. Email sysadmins@cs50.harvard.edu!" +msgstr "" + +#: submit50.py:400 +msgid "" +"You have an old version of submit50. Run update50, then re-run submit50!" +msgstr "" + +#: submit50.py:417 +msgid "Invalid problem. Did you mean to submit something else?" +msgstr "" + +#: submit50.py:433 +msgid "You seem to be missing these files:" +msgstr "" + +#: submit50.py:436 +msgid "Ensure you have the required files before submitting." +msgstr "" + +#: submit50.py:439 +msgid "Authenticating" +msgstr "" + +#: submit50.py:457 +msgid "Preparing" +msgstr "" + +#: submit50.py:464 +msgid "" +"Looks like submit50 isn't enabled for your account yet. Log into https://" +"cs50.me/ in a browser, click \"Authorize application\", and re-run submit50 " +"here!" +msgstr "" + +#: submit50.py:467 +msgid "" +"Looks like you have the wrong username in ~/.gitconfig or submit50 isn't yet " +"enabled for your account. Double-check ~/.gitconfig and then log into " +"https://cs50.me/ in a browser, click \"Authorize application\" if prompted, " +"and re-run submit50 here." +msgstr "" + +#: submit50.py:491 +msgid "No files in this directory are expected for submission." +msgstr "" + +#: submit50.py:492 +msgid "Files that will be submitted:" +msgstr "" + +#: submit50.py:498 +msgid "Files that won't be submitted:" +msgstr "" + +#: submit50.py:503 +msgid "" +"Keeping in mind the course's policy on academic honesty, are you sure you " +"want to submit these files?" +msgstr "" + +#: submit50.py:506 +msgid "No files were submitted." +msgstr "" + +#: submit50.py:509 +msgid "Submitting" +msgstr "" + +#: submit50.py:516 +msgid "Submitted {}! See https://cs50.me/submissions/{}." +msgstr "" + +#: submit50.py:552 +msgid "Could not complete two-factor authentication." +msgstr "" From 8ac25695cb25c55474858c975a64b2e53a85adc7 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 18:58:03 -0400 Subject: [PATCH 13/27] added support for git-lfs but still needs to check out .gitattributes --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b5d7940..ba9cb47 100644 --- a/setup.py +++ b/setup.py @@ -61,5 +61,5 @@ class CustomInstall(install): "console_scripts": ["submit50=submit50:main"] }, url="https://github.com/cs50/submit50", - version="2.3.0" + version="2.4.0" ) From b5f83615b71671e754d8614aa56cb057770e573b Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 19:15:00 -0400 Subject: [PATCH 14/27] checking out .gitattributes now, but need to avoid overwriting existing --- submit50.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/submit50.py b/submit50.py index 9451867..15676da 100644 --- a/submit50.py +++ b/submit50.py @@ -367,7 +367,7 @@ def submit(org, problem): # require git 2.7+, so that credential-cache--daemon ignores SIGHUP # https://github.com/git/git/blob/v2.7.0/credential-cache--daemon.c if not which("git"): - raise Error("You don't have git. Install git, then re-run submit50!.") + raise Error("You don't have git. Install git, then re-run submit50!") version = subprocess.check_output(["git", "--version"]).decode("utf-8") matches = re.search(r"^git version (\d+\.\d+\.\d+).*$", version) if not matches or StrictVersion(matches.group(1)) < StrictVersion("2.7.0"): @@ -451,6 +451,10 @@ def submit(org, problem): # clone repository try: run("git clone --bare {} {}".format(shlex.quote(repo), shlex.quote(run.GIT_DIR)), password=password) + try: + run("git checkout {} .gitattributes".format(branch)) + except Error: + pass except: if password: e = Error("Looks like submit50 isn't enabled for your account yet. " + @@ -471,6 +475,12 @@ def submit(org, problem): # patterns of file names to exclude run("git config core.excludesFile {}".format(shlex.quote(submit.EXCLUDE))) + # blocklist for git-lfs + # https://github.com/git-lfs/git-lfs/blob/master/commands/command_track.go + with open("{}/info/exclude".format(run.GIT_DIR), "w") as file: + file.write(".git*\n") + file.write(".lfs*\n") + # adds, modifies, and removes index entries to match the working tree run("git add --all") @@ -478,6 +488,31 @@ def submit(org, problem): files = run("git ls-files").split() other = run("git ls-files --other").split() + # check for large files > 100 MB (and huge files > 2 GB) + # https://help.github.com/articles/conditions-for-large-files/ + # https://help.github.com/articles/about-git-large-file-storage/ + large, huge = [], [] + for file in files: + size = os.path.getsize(file) + if size > (100 * 1024 * 1024): + large.append(file) + elif size > (2 * 1024 * 1024 * 1024): + huge.append(file) + if len(huge) > 0: + raise Error("These files are too large to be submitted:\n{}\n" + "Remove these files from your directory " + "and then re-run submit50!".format("\n".join(huge))) + elif len(large) > 0: + if not which("git-lfs"): + raise Error("These files are too large to be submitted:\n{}\n" + "Install git-lfs (or remove these files from your directory) " + "and then re-run submit50!".format("\n".join(large))) + run("git lfs install --local") + run("git config credential.helper cache") # for pre-push hook + for file in large: + run("git lfs track {}".format(file)) + run("git add --force .gitattributes") + # files that will be submitted if len(files) == 0: raise Error("No files in this directory are expected for submission.") From 89910b9fb786049dc47f877e40f5ba45b10d9c11 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 20:21:45 -0400 Subject: [PATCH 15/27] preserving any existing .gitattributes now --- submit50.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/submit50.py b/submit50.py index 15676da..0b82162 100644 --- a/submit50.py +++ b/submit50.py @@ -274,6 +274,7 @@ def handler(number, frame): spin(False) else: cprint() + teardown() cprint("Submission cancelled.", "red") os._exit(0) @@ -451,10 +452,6 @@ def submit(org, problem): # clone repository try: run("git clone --bare {} {}".format(shlex.quote(repo), shlex.quote(run.GIT_DIR)), password=password) - try: - run("git checkout {} .gitattributes".format(branch)) - except Error: - pass except: if password: e = Error("Looks like submit50 isn't enabled for your account yet. " + @@ -466,6 +463,12 @@ def submit(org, problem): e.__cause__ = None raise e + # check out .gitattributes, if any + if os.path.isfile(".gitattributes"): + submit.ATTRIBUTES = ".gitattributes.{}".format(round(time.time())) + os.rename(".gitattributes", submit.ATTRIBUTES) + run("git checkout --force {} .gitattributes".format(branch)) + # set options tag = "{}@{}".format(branch, timestamp) run("git config user.email {}".format(shlex.quote(email))) @@ -486,7 +489,7 @@ def submit(org, problem): # get file lists files = run("git ls-files").split() - other = run("git ls-files --other").split() + other = run("git ls-files --exclude-standard --other").split() # check for large files > 100 MB (and huge files > 2 GB) # https://help.github.com/articles/conditions-for-large-files/ @@ -545,11 +548,22 @@ def submit(org, problem): "green") +submit.ATTRIBUTES = None submit.EXCLUDE = None def teardown(): - """Delete temporary directory and temporary file.""" + """Delete temporary directory and temporary file, restore any attributes.""" + if os.path.isfile(".gitattributes"): + try: + os.remove(".gitattributes") + except Exception: + pass + if submit.ATTRIBUTES: + try: + os.rename(submit.ATTRIBUTES, ".gitattributes") + except Exception: + pass shutil.rmtree(run.GIT_DIR, ignore_errors=True) if submit.EXCLUDE: try: From 4c0618ca179799fce9c24a98c745aea0e21a43e2 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 20:29:42 -0400 Subject: [PATCH 16/27] expiring credential cache on exception or SIGINT --- setup.py | 2 +- submit50.py | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index b5d7940..ba9cb47 100644 --- a/setup.py +++ b/setup.py @@ -61,5 +61,5 @@ class CustomInstall(install): "console_scripts": ["submit50=submit50:main"] }, url="https://github.com/cs50/submit50", - version="2.3.0" + version="2.4.0" ) diff --git a/submit50.py b/submit50.py index 9451867..74361b7 100644 --- a/submit50.py +++ b/submit50.py @@ -125,19 +125,19 @@ def main(): def authenticate(org): """Authenticate user.""" - # cache credentials in ~/.git-credential-cache/submit50 + # cache credentials in ~/.git-credential-cache/:org cache = os.path.expanduser("~/.git-credential-cache") try: os.mkdir(cache, 0o700) except: pass - socket = os.path.join(cache, ORG) + authenticate.SOCKET = os.path.join(cache, ORG) # check cache, then config for credentials - credentials = run("git -c credential.helper='cache --socket {}' credential fill".format(socket), + credentials = run("git -c credential.helper='cache --socket {}' credential fill".format(authenticate.SOCKET), lines=[""]*3, quiet=True) - run("git credential-cache --socket {} exit".format(socket)) + run("git credential-cache --socket {} exit".format(authenticate.SOCKET)) matches = re.search("^username=([^\r]+)\r\npassword=([^\r]+)\r?$", credentials, re.MULTILINE) if matches: username = matches.group(1) @@ -221,7 +221,7 @@ def rlinput(prompt, prefill=""): # cache credentials for 1 week timeout = int(datetime.timedelta(weeks=1).total_seconds()) run("git -c credential.helper='cache --socket {} --timeout {}' " - "-c credentialcache.ignoresighup=true credential approve".format(socket, timeout), + "-c credentialcache.ignoresighup=true credential approve".format(authenticate.SOCKET, timeout), lines=["username={}".format(username), "password={}".format(password), "", ""], quiet=True) @@ -229,6 +229,9 @@ def rlinput(prompt, prefill=""): return (username, password, email) +authenticate.SOCKET = None + + def cprint(text="", color=None, on_color=None, attrs=None, **kwargs): """Colorizes text (and wraps to terminal's width).""" @@ -261,6 +264,10 @@ def excepthook(type, value, tb): if run.verbose: traceback.print_exception(type, value, tb) cprint("Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!", "yellow") + try: + run("git credential-cache --socket {} exit".format(authenticate.SOCKET)) + except Exception: + pass cprint("Submission cancelled.", "red") @@ -274,6 +281,10 @@ def handler(number, frame): spin(False) else: cprint() + try: + run("git credential-cache --socket {} exit".format(authenticate.SOCKET)) + except Exception: + pass cprint("Submission cancelled.", "red") os._exit(0) From dca31d145998e855d32627d64f3613354ebc98f9 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 20:39:56 -0400 Subject: [PATCH 17/27] elaborated in comments --- submit50.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submit50.py b/submit50.py index 0b82162..2459d94 100644 --- a/submit50.py +++ b/submit50.py @@ -463,7 +463,7 @@ def submit(org, problem): e.__cause__ = None raise e - # check out .gitattributes, if any + # check out .gitattributes, if any, temporarily shadowing student's, if any if os.path.isfile(".gitattributes"): submit.ATTRIBUTES = ".gitattributes.{}".format(round(time.time())) os.rename(".gitattributes", submit.ATTRIBUTES) From 9031f9ea48aef204b90d6750ac0320a2783eca3b Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 22 Jul 2017 22:52:36 -0400 Subject: [PATCH 18/27] fixed honesty prompt --- setup.py | 2 +- submit50.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index b5d7940..8d89e14 100644 --- a/setup.py +++ b/setup.py @@ -61,5 +61,5 @@ class CustomInstall(install): "console_scripts": ["submit50=submit50:main"] }, url="https://github.com/cs50/submit50", - version="2.3.0" + version="2.3.1" ) diff --git a/submit50.py b/submit50.py index 9451867..0ef4596 100644 --- a/submit50.py +++ b/submit50.py @@ -492,9 +492,9 @@ def submit(org, problem): cprint("./{}".format(f), "yellow") # prompt for academic honesty - cprint("Keeping in mind the course's policy on academic honesty, " + - "are you sure you want to submit these files?", end=" ") - if not re.match("^\s*(?:y|yes)\s*$", input(), re.I): + answer = input("Keeping in mind the course's policy on academic honesty, " + + "are you sure you want to submit these files? ") + if not re.match("^\s*(?:y|yes)\s*$", answer, re.I): raise Error("No files were submitted.") # restart spinner From 7367437419a6291d325779323f0bc1c8b29e1b90 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sun, 23 Jul 2017 03:03:59 +0000 Subject: [PATCH 19/27] updated PO --- locale/es/LC_MESSAGES/messages.po | 62 +++++++++++++++---------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/locale/es/LC_MESSAGES/messages.po b/locale/es/LC_MESSAGES/messages.po index e043c91..96dd92b 100644 --- a/locale/es/LC_MESSAGES/messages.po +++ b/locale/es/LC_MESSAGES/messages.po @@ -3,94 +3,94 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: submit50.py:46 +#: submit50.py:44 msgid "You have an old version of python. Install version 2.7 or higher." msgstr "" -#: submit50.py:117 +#: submit50.py:115 msgid "show commands being executed" msgstr "" -#: submit50.py:118 +#: submit50.py:116 msgid "problem to submit" msgstr "" -#: submit50.py:179 +#: submit50.py:177 msgid "GitHub username: " msgstr "Nombre de usuario de GitHub: " -#: submit50.py:185 +#: submit50.py:183 msgid "GitHub password: " msgstr "Contraseña de GitHub: " -#: submit50.py:219 +#: submit50.py:217 msgid "Invalid username and/or password." msgstr "" -#: submit50.py:223 +#: submit50.py:221 msgid "Could not authenticate user." msgstr "" -#: submit50.py:267 +#: submit50.py:265 msgid "Could not connect to GitHub." msgstr "" -#: submit50.py:271 +#: submit50.py:269 msgid "Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!" msgstr "" -#: submit50.py:272 submit50.py:285 +#: submit50.py:270 submit50.py:283 msgid "Submission cancelled." msgstr "" -#: submit50.py:378 +#: submit50.py:376 msgid "You don't have git. Install git, then re-run submit50!." msgstr "" -#: submit50.py:382 +#: submit50.py:380 msgid "" "You have an old version of git. Install version 2.7 or later, then re-run " "submit50!" msgstr "" -#: submit50.py:396 +#: submit50.py:394 msgid "" "You have an unknown version of submit50. Email sysadmins@cs50.harvard.edu!" msgstr "" -#: submit50.py:400 +#: submit50.py:398 msgid "" "You have an old version of submit50. Run update50, then re-run submit50!" msgstr "" -#: submit50.py:417 +#: submit50.py:415 msgid "Invalid problem. Did you mean to submit something else?" msgstr "" -#: submit50.py:433 +#: submit50.py:431 msgid "You seem to be missing these files:" msgstr "" -#: submit50.py:436 +#: submit50.py:434 msgid "Ensure you have the required files before submitting." msgstr "" -#: submit50.py:439 +#: submit50.py:437 msgid "Authenticating" msgstr "" -#: submit50.py:457 +#: submit50.py:455 msgid "Preparing" msgstr "" -#: submit50.py:464 +#: submit50.py:462 msgid "" "Looks like submit50 isn't enabled for your account yet. Log into https://" "cs50.me/ in a browser, click \"Authorize application\", and re-run submit50 " "here!" msgstr "" -#: submit50.py:467 +#: submit50.py:465 msgid "" "Looks like you have the wrong username in ~/.gitconfig or submit50 isn't yet " "enabled for your account. Double-check ~/.gitconfig and then log into " @@ -98,36 +98,32 @@ msgid "" "and re-run submit50 here." msgstr "" -#: submit50.py:491 +#: submit50.py:489 msgid "No files in this directory are expected for submission." msgstr "" -#: submit50.py:492 +#: submit50.py:490 msgid "Files that will be submitted:" msgstr "" -#: submit50.py:498 +#: submit50.py:496 msgid "Files that won't be submitted:" msgstr "" -#: submit50.py:503 +#: submit50.py:501 msgid "" "Keeping in mind the course's policy on academic honesty, are you sure you " -"want to submit these files?" +"want to submit these files? " msgstr "" -#: submit50.py:506 -msgid "No files were submitted." -msgstr "" - -#: submit50.py:509 +#: submit50.py:507 msgid "Submitting" msgstr "" -#: submit50.py:516 +#: submit50.py:514 msgid "Submitted {}! See https://cs50.me/submissions/{}." msgstr "" -#: submit50.py:552 +#: submit50.py:550 msgid "Could not complete two-factor authentication." msgstr "" From fb6eecb19986c297b252f5594ff170185459bece Mon Sep 17 00:00:00 2001 From: Christian Saravia Date: Mon, 24 Jul 2017 16:36:47 -0400 Subject: [PATCH 20/27] translated to spanish --- locale/es/LC_MESSAGES/messages.po | 53 +++++++++++++++++++------------ 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/locale/es/LC_MESSAGES/messages.po b/locale/es/LC_MESSAGES/messages.po index 96dd92b..4afe850 100644 --- a/locale/es/LC_MESSAGES/messages.po +++ b/locale/es/LC_MESSAGES/messages.po @@ -5,15 +5,15 @@ msgstr "" #: submit50.py:44 msgid "You have an old version of python. Install version 2.7 or higher." -msgstr "" +msgstr "Tienes una versión antigua de python. Instala la versión 2.7 o superior." #: submit50.py:115 msgid "show commands being executed" -msgstr "" +msgstr "mostrar comandos que se están ejecutando" #: submit50.py:116 msgid "problem to submit" -msgstr "" +msgstr "problema para entregar" #: submit50.py:177 msgid "GitHub username: " @@ -25,63 +25,67 @@ msgstr "Contraseña de GitHub: " #: submit50.py:217 msgid "Invalid username and/or password." -msgstr "" +msgstr "Nombre de usuario y / o contraseña es inválido." #: submit50.py:221 msgid "Could not authenticate user." -msgstr "" +msgstr "No se pudo autenticar usuario." #: submit50.py:265 msgid "Could not connect to GitHub." -msgstr "" +msgstr "No se pudo conectar a GitHub" #: submit50.py:269 msgid "Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!" -msgstr "" +msgstr "¡Lo siento, algo está mal! ¡Déjale saber a sysadmins@cs50.harvard.edu!" #: submit50.py:270 submit50.py:283 msgid "Submission cancelled." -msgstr "" +msgstr "La entrega se canceló." #: submit50.py:376 msgid "You don't have git. Install git, then re-run submit50!." -msgstr "" +msgstr "No tienes git. ¡Instala git, y luego vuelve a ejecutar submit50!" #: submit50.py:380 msgid "" "You have an old version of git. Install version 2.7 or later, then re-run " "submit50!" msgstr "" +"Tienes una versión antigua de git. ¡Instala la versión 2.7 o superior, y vuelve a ejecutar +"submit50!" #: submit50.py:394 msgid "" "You have an unknown version of submit50. Email sysadmins@cs50.harvard.edu!" msgstr "" +"Tienes una versión desconocida de submit50. ¡Escríbele a sysadmins@cs50.harvard.edu!" #: submit50.py:398 msgid "" "You have an old version of submit50. Run update50, then re-run submit50!" msgstr "" +"Tienes una versión antigua de submit50. ¡Ejecuta update50, y luego vuelve a ejecutar submit50!" #: submit50.py:415 msgid "Invalid problem. Did you mean to submit something else?" -msgstr "" +msgstr "El problema no es válido. ¿Quisiste entregar algo más?" #: submit50.py:431 msgid "You seem to be missing these files:" -msgstr "" +msgstr "Parece que faltan estos archivos:" #: submit50.py:434 msgid "Ensure you have the required files before submitting." -msgstr "" +msgstr "Asegúrate de tener los archivos necesarios antes de entregar." #: submit50.py:437 msgid "Authenticating" -msgstr "" +msgstr "Autenticando" #: submit50.py:455 msgid "Preparing" -msgstr "" +msgstr "Preparando" #: submit50.py:462 msgid "" @@ -89,6 +93,9 @@ msgid "" "cs50.me/ in a browser, click \"Authorize application\", and re-run submit50 " "here!" msgstr "" +"Parece que submit50 todavía no está habilitado para tu cuenta. Inicie sesión en https://" +"cs50.me/ en un navegador, haga clic en \"Autorizar la aplicación\", y vuelva a ejecutar submit50 " +"¡aquí!" #: submit50.py:465 msgid "" @@ -97,33 +104,39 @@ msgid "" "https://cs50.me/ in a browser, click \"Authorize application\" if prompted, " "and re-run submit50 here." msgstr "" +"Parece que tienes el nombre de usuario incorrecto en ~ /.gitconfig o submit50 aún no está " +"habilitado para tu cuenta. Vuelve a chequear ~/.gitconfig y luego ingresa en " +"https://cs50.me/ en un navegador, haga clic en \"Autorizar aplicación\" si se te solicita, " +"y vuelve a ejecutar submit50 aquí." #: submit50.py:489 msgid "No files in this directory are expected for submission." -msgstr "" +msgstr "Ningún archivo en este directorio se espera para la entrega." #: submit50.py:490 msgid "Files that will be submitted:" -msgstr "" +msgstr "Archivos que se van a entregar:" #: submit50.py:496 msgid "Files that won't be submitted:" -msgstr "" +msgstr "Archivos que no se van a entregar:" #: submit50.py:501 msgid "" "Keeping in mind the course's policy on academic honesty, are you sure you " "want to submit these files? " msgstr "" +"Teniendo en cuenta la política de honestidad académica del curso, ¿estás seguro que " +"quieres enviar estos archivos? " #: submit50.py:507 msgid "Submitting" -msgstr "" +msgstr "Entregando" #: submit50.py:514 msgid "Submitted {}! See https://cs50.me/submissions/{}." -msgstr "" +msgstr "¡Se entregó {}! Puedes ver https://cs50.me/submissions/{}." #: submit50.py:550 msgid "Could not complete two-factor authentication." -msgstr "" +msgstr "No se pudo completar la autenticación de dos factores." From 91d7d021ce12818fb66ccd2ead54bd72406f6599 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Thu, 27 Jul 2017 22:08:28 -0400 Subject: [PATCH 21/27] removed stale comment --- submit50.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submit50.py b/submit50.py index 96c0b58..408a4bb 100644 --- a/submit50.py +++ b/submit50.py @@ -344,7 +344,7 @@ def progress(message=""): # display dots if message passed if message != False: - def progress_helper(): # https://stackoverflow.com/a/4995896 + def progress_helper(): sys.stdout.write(message + "...") sys.stdout.flush() while progress.progressing: From 4e6de93392b2883fade7f17fc981745bc36793b9 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Thu, 27 Jul 2017 22:14:56 -0400 Subject: [PATCH 22/27] added missing _ --- submit50.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submit50.py b/submit50.py index 9dd5254..06e0218 100644 --- a/submit50.py +++ b/submit50.py @@ -501,7 +501,7 @@ def submit(org, problem): answer = input(_("Keeping in mind the course's policy on academic honesty, " "are you sure you want to submit these files? ")) if not re.match("^\s*(?:y|yes)\s*$", answer, re.I): - raise Error("No files were submitted.") + raise Error(_("No files were submitted.")) # restart spinner spin(_("Submitting")) From 5a72ea93073586122f4e8cb4b46c0b301c9bc07a Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Thu, 27 Jul 2017 22:35:27 -0400 Subject: [PATCH 23/27] updated Spanish --- locale/es/LC_MESSAGES/messages.po | 80 +++++++++++++++++-------------- submit50.py | 4 +- 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/locale/es/LC_MESSAGES/messages.po b/locale/es/LC_MESSAGES/messages.po index 4afe850..2b521a8 100644 --- a/locale/es/LC_MESSAGES/messages.po +++ b/locale/es/LC_MESSAGES/messages.po @@ -5,7 +5,8 @@ msgstr "" #: submit50.py:44 msgid "You have an old version of python. Install version 2.7 or higher." -msgstr "Tienes una versión antigua de python. Instala la versión 2.7 o superior." +msgstr "" +"Tienes una versión antigua de python. Instala la versión 2.7 o superior." #: submit50.py:115 msgid "show commands being executed" @@ -31,112 +32,119 @@ msgstr "Nombre de usuario y / o contraseña es inválido." msgid "Could not authenticate user." msgstr "No se pudo autenticar usuario." -#: submit50.py:265 +#: submit50.py:268 msgid "Could not connect to GitHub." msgstr "No se pudo conectar a GitHub" -#: submit50.py:269 +#: submit50.py:272 msgid "Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!" msgstr "¡Lo siento, algo está mal! ¡Déjale saber a sysadmins@cs50.harvard.edu!" -#: submit50.py:270 submit50.py:283 +#: submit50.py:277 submit50.py:295 msgid "Submission cancelled." msgstr "La entrega se canceló." -#: submit50.py:376 -msgid "You don't have git. Install git, then re-run submit50!." +#: submit50.py:386 +msgid "You don't have git. Install git, then re-run submit50!" msgstr "No tienes git. ¡Instala git, y luego vuelve a ejecutar submit50!" -#: submit50.py:380 +#: submit50.py:390 msgid "" "You have an old version of git. Install version 2.7 or later, then re-run " "submit50!" msgstr "" -"Tienes una versión antigua de git. ¡Instala la versión 2.7 o superior, y vuelve a ejecutar -"submit50!" +"Tienes una versión antigua de git. ¡Instala la versión 2.7 o superior, y " +"vuelve a ejecutar submit50!" -#: submit50.py:394 +#: submit50.py:404 msgid "" "You have an unknown version of submit50. Email sysadmins@cs50.harvard.edu!" msgstr "" -"Tienes una versión desconocida de submit50. ¡Escríbele a sysadmins@cs50.harvard.edu!" +"Tienes una versión desconocida de submit50. ¡Escríbele a sysadmins@cs50." +"harvard.edu!" -#: submit50.py:398 +#: submit50.py:408 msgid "" "You have an old version of submit50. Run update50, then re-run submit50!" msgstr "" -"Tienes una versión antigua de submit50. ¡Ejecuta update50, y luego vuelve a ejecutar submit50!" +"Tienes una versión antigua de submit50. ¡Ejecuta update50, y luego vuelve a " +"ejecutar submit50!" -#: submit50.py:415 +#: submit50.py:425 msgid "Invalid problem. Did you mean to submit something else?" msgstr "El problema no es válido. ¿Quisiste entregar algo más?" -#: submit50.py:431 +#: submit50.py:441 msgid "You seem to be missing these files:" msgstr "Parece que faltan estos archivos:" -#: submit50.py:434 +#: submit50.py:444 msgid "Ensure you have the required files before submitting." msgstr "Asegúrate de tener los archivos necesarios antes de entregar." -#: submit50.py:437 +#: submit50.py:447 msgid "Authenticating" msgstr "Autenticando" -#: submit50.py:455 +#: submit50.py:465 msgid "Preparing" msgstr "Preparando" -#: submit50.py:462 +#: submit50.py:472 msgid "" "Looks like submit50 isn't enabled for your account yet. Log into https://" "cs50.me/ in a browser, click \"Authorize application\", and re-run submit50 " "here!" msgstr "" -"Parece que submit50 todavía no está habilitado para tu cuenta. Inicie sesión en https://" -"cs50.me/ en un navegador, haga clic en \"Autorizar la aplicación\", y vuelva a ejecutar submit50 " -"¡aquí!" +"Parece que submit50 todavía no está habilitado para tu cuenta. Inicie sesión " +"en https://cs50.me/ en un navegador, haga clic en \"Autorizar la aplicación" +"\", y vuelva a ejecutar submit50 ¡aquí!" -#: submit50.py:465 +#: submit50.py:475 msgid "" "Looks like you have the wrong username in ~/.gitconfig or submit50 isn't yet " "enabled for your account. Double-check ~/.gitconfig and then log into " "https://cs50.me/ in a browser, click \"Authorize application\" if prompted, " "and re-run submit50 here." msgstr "" -"Parece que tienes el nombre de usuario incorrecto en ~ /.gitconfig o submit50 aún no está " -"habilitado para tu cuenta. Vuelve a chequear ~/.gitconfig y luego ingresa en " -"https://cs50.me/ en un navegador, haga clic en \"Autorizar aplicación\" si se te solicita, " -"y vuelve a ejecutar submit50 aquí." +"Parece que tienes el nombre de usuario incorrecto en ~ /.gitconfig o " +"submit50 aún no está habilitado para tu cuenta. Vuelve a chequear ~/." +"gitconfig y luego ingresa en https://cs50.me/ en un navegador, haga clic en " +"\"Autorizar aplicación\" si se te solicita, y vuelve a ejecutar submit50 " +"aquí." -#: submit50.py:489 +#: submit50.py:536 msgid "No files in this directory are expected for submission." msgstr "Ningún archivo en este directorio se espera para la entrega." -#: submit50.py:490 +#: submit50.py:537 msgid "Files that will be submitted:" msgstr "Archivos que se van a entregar:" -#: submit50.py:496 +#: submit50.py:543 msgid "Files that won't be submitted:" msgstr "Archivos que no se van a entregar:" -#: submit50.py:501 +#: submit50.py:548 msgid "" "Keeping in mind the course's policy on academic honesty, are you sure you " "want to submit these files? " msgstr "" -"Teniendo en cuenta la política de honestidad académica del curso, ¿estás seguro que " -"quieres enviar estos archivos? " +"Teniendo en cuenta la política de honestidad académica del curso, ¿estás " +"seguro que quieres enviar estos archivos? " + +#: submit50.py:551 +msgid "No files were submitted." +msgstr "" -#: submit50.py:507 +#: submit50.py:554 msgid "Submitting" msgstr "Entregando" -#: submit50.py:514 +#: submit50.py:561 msgid "Submitted {}! See https://cs50.me/submissions/{}." msgstr "¡Se entregó {}! Puedes ver https://cs50.me/submissions/{}." -#: submit50.py:550 +#: submit50.py:608 msgid "Could not complete two-factor authentication." msgstr "No se pudo completar la autenticación de dos factores." diff --git a/submit50.py b/submit50.py index 29d53dd..b848e29 100644 --- a/submit50.py +++ b/submit50.py @@ -174,7 +174,7 @@ def rlinput(prompt, prefill=""): # prompt for username, prefilling if possible while True: progress(False) - username = rlinput("GitHub username: ", username).strip() + username = rlinput(_("GitHub username: "), username).strip() if username: break @@ -444,7 +444,7 @@ def submit(org, problem): raise Error(_("Ensure you have the required files before submitting.")) # update progress - progress("Authenticating") + progress(_("Authenticating")) # authenticate user via SSH try: From c3631774e8fc8146e5718e52e688b2f9efe5a12e Mon Sep 17 00:00:00 2001 From: Brian Yu Date: Sat, 29 Jul 2017 19:30:31 -0400 Subject: [PATCH 24/27] Add check for announcements --- submit50.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/submit50.py b/submit50.py index b848e29..569d2c1 100644 --- a/submit50.py +++ b/submit50.py @@ -380,6 +380,11 @@ def progress_helper(): def submit(org, problem): """Submit problem.""" + # check announcements + res = requests.get("https://cs50.me/status/submit50") + if res.status_code == 200 and res.text: + raise Error(res.text) + # require git 2.7+, so that credential-cache--daemon ignores SIGHUP # https://github.com/git/git/blob/v2.7.0/credential-cache--daemon.c if not which("git"): From 61b2958bfa1c15f5ad6f6e58b2e1e60cf14932ff Mon Sep 17 00:00:00 2001 From: Brian Yu Date: Sat, 29 Jul 2017 21:51:49 -0400 Subject: [PATCH 25/27] Strip newlines from announcement --- submit50.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/submit50.py b/submit50.py index 569d2c1..026cbd2 100644 --- a/submit50.py +++ b/submit50.py @@ -382,8 +382,8 @@ def submit(org, problem): # check announcements res = requests.get("https://cs50.me/status/submit50") - if res.status_code == 200 and res.text: - raise Error(res.text) + if res.status_code == 200 and res.text.strip(): + raise Error(res.text.strip()) # require git 2.7+, so that credential-cache--daemon ignores SIGHUP # https://github.com/git/git/blob/v2.7.0/credential-cache--daemon.c From d3e2b18c8b66d800b92be77bff8727a31a072d02 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sun, 30 Jul 2017 02:31:39 +0000 Subject: [PATCH 26/27] fixed bug whereby checkout failed if no .gitattributes exists --- setup.py | 2 +- submit50.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ba9cb47..27bb0fc 100644 --- a/setup.py +++ b/setup.py @@ -61,5 +61,5 @@ class CustomInstall(install): "console_scripts": ["submit50=submit50:main"] }, url="https://github.com/cs50/submit50", - version="2.4.0" + version="2.4.1" ) diff --git a/submit50.py b/submit50.py index 026cbd2..999688b 100644 --- a/submit50.py +++ b/submit50.py @@ -487,7 +487,10 @@ def submit(org, problem): if os.path.isfile(".gitattributes"): submit.ATTRIBUTES = ".gitattributes.{}".format(round(time.time())) os.rename(".gitattributes", submit.ATTRIBUTES) - run("git checkout --force {} .gitattributes".format(branch)) + try: + run("git checkout --force {} .gitattributes".format(branch)) + except Exception: + pass # set options tag = "{}@{}".format(branch, timestamp) From 3571627ce9cae0f6537d4841242bc14465c6d601 Mon Sep 17 00:00:00 2001 From: Brian Yu Date: Sat, 29 Jul 2017 23:36:27 -0400 Subject: [PATCH 27/27] Update version number to 2.3.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 27bb0fc..8d89e14 100644 --- a/setup.py +++ b/setup.py @@ -61,5 +61,5 @@ class CustomInstall(install): "console_scripts": ["submit50=submit50:main"] }, url="https://github.com/cs50/submit50", - version="2.4.1" + version="2.3.1" )