-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa88598
commit 5db11b1
Showing
6 changed files
with
114 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/env python3 | ||
from __future__ import annotations | ||
|
||
import argparse | ||
from pathlib import Path | ||
|
||
TIN_ROOT = Path(__file__).parent.parent / "tin" | ||
|
||
PYTHON_WRAPPER = """ | ||
import subprocess | ||
import sys | ||
submission = "{submission_path}" | ||
subprocess.run([sys.executable, submission]) | ||
""" | ||
|
||
# TODO | ||
JAVA_WRAPPER = """""" | ||
|
||
|
||
def create_wrappers(file_name: str, wrapper_text: str) -> None: | ||
"""Create sample Tin wrapper scripts. | ||
These are supposed to be used for sandboxing, but | ||
for debug purposes we can just do nothing! | ||
""" | ||
wrappers = TIN_ROOT / "sandboxing" / "wrappers" | ||
# we need both because in some cases bwrap exists on the parent system | ||
for dir in ["sandboxed", "testing"]: | ||
wrapper = wrappers / dir | ||
wrapper.mkdir(parents=True, exist_ok=True) | ||
|
||
path = wrapper.joinpath(f"{file_name}.txt") | ||
# prevent possible overwriting | ||
if path.exists() and not args.force: | ||
print(f"Skipping file {path}") | ||
else: | ||
if args.force: | ||
print(f"Overwriting file {path}") | ||
path.write_text(wrapper_text) | ||
|
||
|
||
def cli() -> argparse.Namespace: | ||
parser = argparse.ArgumentParser( | ||
description="Create sample wrapper scripts to run Tin submissions." | ||
) | ||
parser.add_argument("--force", action="store_true", help="overwrite existing wrapper files.") | ||
return parser.parse_args() | ||
|
||
|
||
if __name__ == "__main__": | ||
args = cli() | ||
create_wrappers("P", PYTHON_WRAPPER) | ||
create_wrappers("J", JAVA_WRAPPER) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""The (second) simplest grader. | ||
This runs the student submission, and without checking the output | ||
gives them a 100%. It also errors if the student submission crashes. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import subprocess | ||
import sys | ||
|
||
# this will error if the student submission errors | ||
process = subprocess.run( | ||
[sys.executable, sys.argv[1]], | ||
check=True, | ||
) | ||
|
||
print("Score: 100%") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters