Skip to content

Commit

Permalink
Merge pull request #116 from cs50/develop
Browse files Browse the repository at this point in the history
Deploy submit50 v2.4.0
  • Loading branch information
brianyu28 authored Jul 31, 2017
2 parents a8ace98 + 96d7764 commit 26cbd25
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 83 deletions.
108 changes: 65 additions & 43 deletions locale/es/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -44,107 +44,129 @@ msgstr "¡Lo siento, algo está mal! ¡Déjale saber a sysadmins@cs50.harvard.ed
msgid "Submission cancelled."
msgstr "La entrega se canceló."

#: 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:391
msgid "You don't have git. Install git, then re-run {}!"
msgstr "No tienes git. ¡Instala git, y luego vuelve a ejecutar {}!"

#: submit50.py:390
#: submit50.py:395
msgid ""
"You have an old version of git. Install version 2.7 or later, then re-run "
"submit50!"
"You have an old version of git. Install version 2.7 or later, then re-run {}!"
msgstr ""
"Tienes una versión antigua de git. ¡Instala la versión 2.7 o superior, y "
"vuelve a ejecutar submit50!"

#: submit50.py:404
#: submit50.py:409
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:408
msgid ""
"You have an old version of submit50. Run update50, then re-run submit50!"
#: submit50.py:413
msgid "You have an old version of submit50. Run update50, then re-run {}!"
msgstr ""
"Tienes una versión antigua de submit50. ¡Ejecuta update50, y luego vuelve a "
"ejecutar submit50!"
"ejecutar {}!"

#: submit50.py:425
#: submit50.py:430
msgid "Invalid problem. Did you mean to submit something else?"
msgstr "El problema no es válido. ¿Quisiste entregar algo más?"

#: submit50.py:441
#: submit50.py:446
msgid "You seem to be missing these files:"
msgstr "Parece que faltan estos archivos:"

#: submit50.py:444
#: submit50.py:449
msgid "Ensure you have the required files before submitting."
msgstr "Asegúrate de tener los archivos necesarios antes de entregar."

#: submit50.py:447
#: submit50.py:452
msgid "Authenticating"
msgstr "Autenticando"

#: submit50.py:465
#: submit50.py:470
msgid "Preparing"
msgstr "Preparando"

#: submit50.py:472
#: submit50.py:477
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!"
"Looks like {} isn't enabled for your account yet. Log into https://cs50.me/ "
"in a browser, click \"Authorize application\", and re-run {} 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:475
#: submit50.py:480
msgid ""
"Looks like you have the wrong username in ~/.gitconfig or submit50 isn't yet "
"Looks like you have the wrong username in ~/.gitconfig or {} 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."
"and re-run {} here."
msgstr ""
"Parece que tienes el nombre de usuario incorrecto en ~ /.gitconfig o {} 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 {} aquí."

#: submit50.py:525
msgid ""
"These files are too large to be submitted:\n"
"{}\n"
"Remove these files from your directory and then re-run {}!"
msgstr ""

#: submit50.py:530
msgid ""
"These files are too large to be submitted:\n"
"{}\n"
"Install git-lfs (or remove these files from your directory) and then re-run "
"{}!"
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:536
#: submit50.py:541
msgid "No files in this directory are expected for submission."
msgstr "Ningún archivo en este directorio se espera para la entrega."

#: submit50.py:537
#: submit50.py:544
msgid "Files that will be submitted:"
msgstr "Archivos que se van a entregar:"

#: submit50.py:543
#: submit50.py:550
msgid "Files that won't be submitted:"
msgstr "Archivos que no se van a entregar:"

#: submit50.py:548
#: submit50.py:554
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:551
#: submit50.py:557
msgid "No files were submitted."
msgstr ""

#: submit50.py:554
#: submit50.py:560
msgid "Submitting"
msgstr "Entregando"

#: submit50.py:561
msgid "Submitted {}! See https://cs50.me/submissions/{}."
msgstr "¡Se entregó {}! Puedes ver https://cs50.me/submissions/{}."
#: submit50.py:568
msgid "Submitted {}! See https://cs50.me/submissions."
msgstr "¡Se entregó {}! Puedes ver https://cs50.me/submissions."

#: submit50.py:608
#: submit50.py:615
msgid "Could not complete two-factor authentication."
msgstr "No se pudo completar la autenticación de dos factores."

#~ 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!"

#~ msgid ""
#~ "Looks like {} 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 {} 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í!"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ class CustomInstall(install):
"console_scripts": ["submit50=submit50:main"]
},
url="https://github.com/cs50/submit50",
version="2.3.1"
version="2.4.0"
)
87 changes: 48 additions & 39 deletions submit50.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def progress_helper():
progress.progressing = False


def submit(org, problem):
def submit(org, branch):
"""Submit problem."""

# check announcements
Expand All @@ -388,11 +388,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 {}!".format(org)))
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 {}!".format(org)))

# update progress
progress("Connecting")
Expand All @@ -411,16 +411,20 @@ def submit(org, problem):
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!"))
"Run update50, then re-run {}!".format(org)))

# assume cs50/ problem if problem name begins with a year
branch = problem
if problem.split("/")[0].isdigit():
branch = os.path.join("cs50", problem)
file, submit.EXCLUDE = tempfile.mkstemp()

# separate branch into problem slug and source repo
check_repo = "@cs50/checks"
branch = branch if not branch.endswith(check_repo) else branch[:-len(check_repo)]
try:
slug, src = branch.split("@")
except ValueError:
slug, src = branch, "cs50/checks"

# ensure problem exists
file, submit.EXCLUDE = tempfile.mkstemp()
url = "https://cs50.me/excludes/{}/".format(branch)
url = "https://raw.githubusercontent.com/{}/master/{}/submit50/exclude".format(src, slug)
try:
urllib.request.urlretrieve(url, filename=submit.EXCLUDE)
lines = open(submit.EXCLUDE)
Expand Down Expand Up @@ -474,12 +478,12 @@ def submit(org, problem):
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 {} isn't enabled for your account yet. "
"Log into https://cs50.me/ in a browser, click \"Authorize application\", and re-run {} here!".format(org, org)))
else:
e = Error(_("Looks like you have the wrong username in ~/.gitconfig or submit50 isn't yet enabled for your account. "
e = Error(_("Looks like you have the wrong username in ~/.gitconfig or {} 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."))
"click \"Authorize application\" if prompted, and re-run {} here.".format(org, org)))
e.__cause__ = None
raise e

Expand Down Expand Up @@ -525,14 +529,14 @@ def submit(org, problem):
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)))
raise Error(_("These files are too large to be submitted:\n{}\n"
"Remove these files from your directory "
"and then re-run {}!").format("\n".join(huge), org))
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)))
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 {}!").format("\n".join(large), org))
run("git lfs install --local")
run("git config credential.helper cache") # for pre-push hook
for file in large:
Expand All @@ -542,33 +546,38 @@ 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")
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")
for f in other:
cprint("./{}".format(f), "yellow")

# prompt for academic honesty
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."))

if org == "submit50":
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")
for f in other:
cprint("./{}".format(f), "yellow")

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."))

# update progress
progress(_("Submitting"))
progress(_("Submitting" if org == "submit50" else "Uploading"))

# push branch
run("git commit --allow-empty --message='{}'".format(timestamp))
commit_hash = run("git rev-parse HEAD")
run("git push origin 'refs/heads/{}'".format(branch), password=password)

# successful submission
cprint(_("Submitted {}! "
"See https://cs50.me/submissions/{}.").format(problem, branch),
"green")
if org == "submit50":
cprint(_("Submitted {}! See https://cs50.me/submissions.").format(branch),
"green")

progress(False)
return username, commit_hash


submit.ATTRIBUTES = None
Expand Down

0 comments on commit 26cbd25

Please sign in to comment.