Skip to content

Commit d12ba11

Browse files
authored
Merge branch 'cms-dev:main' into add-counter
2 parents 4b0bd83 + 4c7f69c commit d12ba11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1444
-465
lines changed

.codacy.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ Dockerfile
44
codecov/
55
.dev/
66
.venv/
7+
.git/
8+
.jj/

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ Homepage: <http://cms-dev.github.io/>
66
[![Build Status](https://github.com/cms-dev/cms/actions/workflows/main.yml/badge.svg)](https://github.com/cms-dev/cms/actions)
77
[![Codecov](https://codecov.io/gh/cms-dev/cms/branch/main/graph/badge.svg)](https://codecov.io/gh/cms-dev/cms)
88
[![Get support on Telegram](https://img.shields.io/badge/Questions%3F-Join%20the%20Telegram%20group!-%2326A5E4?style=flat&logo=telegram)](https://t.me/contestms)
9+
[![Translation status](https://hosted.weblate.org/widget/cms/svg-badge.svg)](https://hosted.weblate.org/engage/cms/)
910

10-
[🌍 Help translate CMS in your language!](https://cms-dev.oneskyapp.com/collaboration/project?id=392655)
11+
[🌍 Help translate CMS in your language using Weblate!](https://hosted.weblate.org/engage/cms/)
1112

1213
Introduction
1314
------------

cms/db/contest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ def phase(self, timestamp: datetime) -> int:
309309
310310
timestamp: the time we are iterested in.
311311
"""
312+
# NOTE: this logic is duplicated in aws_utils.js.
312313
if timestamp < self.start:
313314
return -1
314315
if timestamp <= self.stop:

cms/grading/Sandbox.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def __init__(
217217
# TODO: move all other common properties here.
218218
self.box_id: int = 0
219219
self.fsize: int | None = None
220-
self.dirs: list[tuple[str, str, str | None]] = []
220+
self.dirs: list[tuple[str | None, str, str | None]] = []
221221
self.preserve_env: bool = False
222222
self.inherit_env: list[str] = []
223223
self.set_env: dict[str, str] = {}
@@ -966,6 +966,10 @@ def __init__(self, file_cacher, name=None, temp_dir=None):
966966
self.add_mapped_directory(
967967
self._home, dest=self._home_dest, options="rw")
968968

969+
# Create temporary directory on /dev/shm to prevent communication
970+
# between sandboxes.
971+
self.dirs.append((None, "/dev/shm", "tmp"))
972+
969973
# Set common environment variables.
970974
# Specifically needed by Python, that searches the home for
971975
# packages.
@@ -1132,7 +1136,9 @@ def build_box_options(self) -> list[str]:
11321136
if self.chdir is not None:
11331137
res += ["--chdir=%s" % self.chdir]
11341138
for src, dest, options in self.dirs:
1135-
s = dest + "=" + src
1139+
s = dest
1140+
if src is not None:
1141+
s += "=" + src
11361142
if options is not None:
11371143
s += ":" + options
11381144
res += ["--dir=%s" % s]

cms/grading/languagemanager.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,20 @@
1818

1919
"""Provide utilities to work with programming language classes."""
2020

21+
import logging
2122
from cms import plugin_list
2223
from cms.grading.language import Language
2324

24-
2525
__all__ = [
2626
"LANGUAGES",
2727
"HEADER_EXTS", "SOURCE_EXTS", "OBJECT_EXTS",
2828
"get_language", "filename_to_language"
2929
]
3030

3131

32+
logger = logging.getLogger(__name__)
33+
34+
3235
LANGUAGES: list[Language] = list()
3336
_BY_NAME: dict[str, Language] = dict()
3437
HEADER_EXTS: set[str] = set()
@@ -50,6 +53,25 @@ def get_language(name: str) -> Language:
5053
return _BY_NAME[name]
5154

5255

56+
def safe_get_lang_filename(lang: str | None, filename: str) -> str:
57+
"""Get the filename of a file in a specific programming language,
58+
avoiding errors if the language isn't recognized.
59+
60+
lang: name of the programming language
61+
filename: filename template (containing .%l)
62+
return: filename with the template replaced.
63+
"""
64+
if lang is None:
65+
return filename
66+
try:
67+
language = get_language(lang)
68+
source_ext = language.source_extension
69+
except KeyError:
70+
logger.warning(f"Found invalid language {lang}!")
71+
source_ext = ".invalid_language"
72+
return filename.replace(".%l", source_ext)
73+
74+
5375
def filename_to_language(filename: str, available_languages: list[Language] | None=None) -> Language | None:
5476
"""Return one of the languages inferred from the given filename.
5577

cms/locale/ar/LC_MESSAGES/cms.po

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
21
msgid ""
32
msgstr ""
4-
"Project-Id-Version: VERSION\n"
3+
"Project-Id-Version: VERSION\n"
54
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
65
"POT-Creation-Date: 2025-08-16 14:52+0300\n"
7-
"PO-Revision-Date: 2025-08-16 12:04+0000\n"
8-
"Last-Translator: Pasit Sangprachathanarak <[email protected]>\n"
9-
"Language: ar\n"
6+
"PO-Revision-Date: 2025-08-20 09:02+0000\n"
7+
"Last-Translator: Muaath Alqarni <[email protected]>\n"
108
"Language-Team: Arabic <https://hosted.weblate.org/projects/cms/main/ar/>\n"
11-
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n"
9+
"Language: ar\n"
1210
"MIME-Version: 1.0\n"
1311
"Content-Type: text/plain; charset=utf-8\n"
1412
"Content-Transfer-Encoding: 8bit\n"
13+
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n"
14+
"X-Generator: Weblate 5.13\n"
1515
"Generated-By: Babel 2.12.1\n"
1616

1717
msgid "N/A"
@@ -42,7 +42,7 @@ msgid "Memory used"
4242
msgstr "الذاكرة المستعملة"
4343

4444
msgid "Score details temporarily unavailable."
45-
msgstr ""
45+
msgstr "تفاصيل الدرجة غير متوفرة مؤقتًا."
4646

4747
#, python-format
4848
msgid "Subtask %(index)s"
@@ -52,24 +52,23 @@ msgid "Compilation succeeded"
5252
msgstr "نجح التحويل"
5353

5454
msgid "Your submission successfully compiled to an executable."
55-
msgstr ""
55+
msgstr "تسليمك حوِّل بنجاح إلى برنامج."
5656

5757
msgid "Compilation failed"
5858
msgstr "فشل التحويل"
5959

60-
#, fuzzy
6160
msgid "Your submission did not compile correctly."
62-
msgstr "تسليمك استغرق من وقت المعالج أكثر من الحد"
61+
msgstr "تسليمك لم يحول بشكل صحيح."
6362

6463
msgid "Compilation timed out"
6564
msgstr "التحويل تجاوز حد الوقت"
6665

6766
msgid "Your submission exceeded the time limit while compiling. This might be caused by an excessive use of C++ templates, for example."
68-
msgstr ""
67+
msgstr "استغرق تسليمك أكثر من حد الوقت للتحويل. قد يكون بسبب C++ templates على سبيل المثال."
6968

70-
#, fuzzy, python-format
69+
#, python-format
7170
msgid "Compilation killed with signal %s (could be triggered by violating memory limits)"
72-
msgstr "أوقف التنفيذ (قد يكون بسبب الوصول لذاكرة غير مصرح بها)"
71+
msgstr "أوقفت عملية التحويل بإشارة %s (قد يكون بسبب الوصول لذاكرة غير مصرح بها)"
7372

7473
msgid "Your submission was killed with the specified signal. Among other things, this might be caused by exceeding the memory limit for the compilation, and in turn by an excessive use of C++ templates, for example."
7574
msgstr ""
@@ -78,7 +77,7 @@ msgid "Output is correct"
7877
msgstr "المخرجات صحيحة"
7978

8079
msgid "Your submission ran and gave the correct answer"
81-
msgstr ""
80+
msgstr "شغّل تسليمك وأعطى إجابة صحيحة"
8281

8382
msgid "Output is partially correct"
8483
msgstr "المخرجات صحيحة جزئيًا"
@@ -1106,4 +1105,3 @@ msgstr ""
11061105

11071106
#~ msgid "Standard Template Library"
11081107
#~ msgstr "المكتبة الأساسية"
1109-

cms/locale/et/LC_MESSAGES/cms.po

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
21
msgid ""
32
msgstr ""
4-
"Project-Id-Version: VERSION\n"
3+
"Project-Id-Version: VERSION\n"
54
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
65
"POT-Creation-Date: 2025-08-16 14:52+0300\n"
7-
"PO-Revision-Date: 2025-06-06 09:35+0000\n"
8-
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9-
"Language: et_EE\n"
10-
"Language-Team: et_EE TEAM <EMAIL@ADDRESS>\n"
11-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
6+
"PO-Revision-Date: 2025-08-17 17:02+0000\n"
7+
"Last-Translator: \"p. randla\" <[email protected]>\n"
8+
"Language-Team: Estonian <https://hosted.weblate.org/projects/cms/main/et/>\n"
9+
"Language: et\n"
1210
"MIME-Version: 1.0\n"
1311
"Content-Type: text/plain; charset=utf-8\n"
1412
"Content-Transfer-Encoding: 8bit\n"
13+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
14+
"X-Generator: Weblate 5.13\n"
1515
"Generated-By: Babel 2.12.1\n"
1616

1717
msgid "N/A"
@@ -27,7 +27,7 @@ msgid "Partially correct"
2727
msgstr "Osaliselt õige vastus"
2828

2929
msgid "#"
30-
msgstr ""
30+
msgstr "#"
3131

3232
msgid "Outcome"
3333
msgstr "Tulemus"
@@ -110,20 +110,17 @@ msgstr "Programmi tööaja limiit ületatud"
110110
msgid "Your submission used too much total time. This might be triggered by undefined code, or buffer overflow, for example. Note that in this case the CPU time visible in the submission details might be much smaller than the time limit."
111111
msgstr "Programmi tööaeg ületas lubatud piiri. Selle kõige tõenäolisem põhjus on katse lugeda rohkem sisendit, kui seda on. Aga mõnikord võivad seda põhjustada ka mitmesugused määramatused programmis, sealhulgas ka massiivide piiridest väljumine. Kuna lahendus jääb ootele, võib selle kasutatud protsessoriaeg olla protsessori ajalimiidist märksa väiksem."
112112

113-
#, fuzzy
114113
msgid "Memory limit exceeded"
115-
msgstr "Mälulimiit"
114+
msgstr "Mälulimiit ületatud"
116115

117-
#, fuzzy
118116
msgid "Your submission used too much memory."
119-
msgstr "Lahenduse jooksmiseks kulus liiga palju protsessori aega."
117+
msgstr "Lahendus kasutas liiga palju mälu."
120118

121-
#, fuzzy
122119
msgid "Execution killed by signal"
123-
msgstr "Programmi protsessori ajalimiit ületatud"
120+
msgstr "Programmi täitmine katkes signaali tagajärjel"
124121

125122
msgid "The evaluation was killed by a signal."
126-
msgstr ""
123+
msgstr "Lahenduse täitmine katkes signaali tagajärjel."
127124

128125
msgid "Execution failed because the return code was nonzero"
129126
msgstr "Programmi täitmine ebaõnnestus, nullist erinev veakood"
@@ -349,7 +346,7 @@ msgstr "Iga lähteteksti fail võib olla ülimalt %d baiti pikk."
349346

350347
#, python-format
351348
msgid "The submission should contain at most %d files."
352-
msgstr ""
349+
msgstr "Lahendus võib sisaldada ülimalt %d faili."
353350

354351
msgid "Invalid archive format!"
355352
msgstr "Vigases vormingus arhiiv!"
@@ -417,7 +414,7 @@ msgid "Subject"
417414
msgstr "Teema"
418415

419416
msgid "Text"
420-
msgstr "Tekst"
417+
msgstr "Sisu"
421418

422419
msgid "Ask question"
423420
msgstr "Esita küsimus"
@@ -519,7 +516,7 @@ msgid "Contest Management System"
519516
msgstr "Contest Management System"
520517

521518
msgid "is released under the"
522-
msgstr "kasutamine on lubatud vastavalt "
519+
msgstr "kasutamine on lubatud vastavalt"
523520

524521
msgid "GNU Affero General Public License"
525522
msgstr "GNU Affero General Public License tingimustele"
@@ -553,7 +550,7 @@ msgid "An error occured while the server was handling your request."
553550
msgstr "Päringu töötlemise käigus esines viga."
554551

555552
msgid "Note that attempts to tamper with Contest Management System (such as probing the server with customized URLs) may be considered cheating and may lead to disqualification."
556-
msgstr "Pange tähele, et Contest Management System'i ebaotstarbeline kasutus (nagu näiteks moonutatud URL-ide katsetamine) võib olla interpreteeritud kui sohitegemise katse, ning kaasa tuua diskvalifikatsiooni."
553+
msgstr "Pange tähele, et Contest Management System'i ebasihipärast kasutamist (näiteks moonutatud URL-ide katsetamine) võidakse tõlgendada sohitegemise katsena, mis võib põhjustada diskvalifitseerimise."
557554

558555
msgid "If you encountered this error during normal usage, please notify the contest administrators."
559556
msgstr "Kui te avastasite selle vea normaalse kasutuse käigus, palun teavitage võistluse administraatoreid."
@@ -570,19 +567,17 @@ msgstr "Punktid"
570567
msgid "Token"
571568
msgstr "Pilet"
572569

573-
#, fuzzy
574570
msgid "no submissions"
575-
msgstr "Esitatud lahendused"
571+
msgstr "pole ühtegi esitust"
576572

577573
msgid "Played"
578-
msgstr ""
574+
msgstr "Kasutatud"
579575

580576
msgid "Play!"
581-
msgstr ""
577+
msgstr "Kasuta!"
582578

583-
#, fuzzy
584579
msgid "No tokens"
585-
msgstr "Piletid"
580+
msgstr "Pileteid pole"
586581

587582
msgid "General information"
588583
msgstr "Üldinfo"
@@ -696,7 +691,7 @@ msgid "Start!"
696691
msgstr "Alusta!"
697692

698693
msgid "Task overview"
699-
msgstr "Ülesande info"
694+
msgstr "Ülesannete ülevaade"
700695

701696
msgid "Task"
702697
msgstr "Ülesanne"
@@ -888,9 +883,9 @@ msgstr "Üksikasjad"
888883
msgid "Compilation commands"
889884
msgstr "Kompileerimise käsurida"
890885

891-
#, fuzzy, python-format
886+
#, python-format
892887
msgid "You can find the rules for the %(type_pl)s on the <a href=\"%(contest_root)s\">contest overview page</a>."
893-
msgstr "Te saate iga ülesande kirjelduse lehel teada, milliste reeglite järgi %(type_pl)seid kasutada saab."
888+
msgstr "<a href=\"%(contest_root)s\">Võistluse ülevaate lehel</a> leiate reeglid, mille järgi saab kasutada %(type_pl)seid."
894889

895890
msgid "Remember that to see the detailed result of a submission you need to use both a contest-token and a task-token."
896891
msgstr "Pane tähele, et esitatud lahenduse tulemuste detailvaate nägemiseks pead kasutama nii ühe võistluspileti kui ka ühe ülesandepileti."
@@ -1025,16 +1020,14 @@ msgstr "Päring on tühistatud, kuna Teil pole ühtegi piletit."
10251020
msgid "Your request has been discarded because you already used a token on that submission."
10261021
msgstr "Päring on tühistatud, kuna selle jaoks on juba piletit kasutatud."
10271022

1028-
#, fuzzy
10291023
msgid "Invalid file"
1030-
msgstr "Vigane vorming!"
1024+
msgstr "Vigane fail"
10311025

1032-
#, fuzzy
10331026
msgid "Print job has too many pages"
1034-
msgstr "Printimistöö salvestamine ebaõnnestus!"
1027+
msgstr "Prinditaval dokumendil on liiga mitu lehekülge"
10351028

10361029
msgid "Sent to printer"
1037-
msgstr ""
1030+
msgstr "Printerile saadetud"
10381031

10391032
#~ msgid "Execution killed (could be triggered by violating memory limits)"
10401033
#~ msgstr "Programmi täitmine katkes signaali tagajärjel (võib olla tingitud mälupiirangute ületamisest)"
@@ -1044,4 +1037,3 @@ msgstr ""
10441037

10451038
#~ msgid "Standard Template Library"
10461039
#~ msgstr "Standard Template Library"
1047-

0 commit comments

Comments
 (0)