Skip to content
Extraits de code Groupes Projets
Valider 9ec0e12b rédigé par Anatole Huet's avatar Anatole Huet
Parcourir les fichiers

update - working run file

parent 6beebf00
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -5,6 +5,7 @@ import json ...@@ -5,6 +5,7 @@ import json
from json import JSONDecodeError from json import JSONDecodeError
from distutils.file_util import copy_file from distutils.file_util import copy_file
import os import os
import inginious_container_api.feedback
# Dynamically load modules we need # Dynamically load modules we need
# Credits to https://stackoverflow.com/a/67692/6149867 # Credits to https://stackoverflow.com/a/67692/6149867
...@@ -16,6 +17,7 @@ def dynamically_load_module(module, path): ...@@ -16,6 +17,7 @@ def dynamically_load_module(module, path):
return mod return mod
##################################### #####################################
# Our import for common run file # # Our import for common run file #
##################################### #####################################
...@@ -23,15 +25,16 @@ sys.path.append("/course/common") ...@@ -23,15 +25,16 @@ sys.path.append("/course/common")
runfile = dynamically_load_module("runfile", "/course/common/runfile.py") runfile = dynamically_load_module("runfile", "/course/common/runfile.py")
isExist = os.path.exists("./student/Translations") isExist = os.path.exists("/task/student/Translations")
if not isExist: if not isExist:
os.makedirs("./student/Translations") os.mkdir("/task/student/Translations")
copy_file("/course/common/student/Translations/Translator.java", "./student/Translations/Translator.java") copy_file("/course/common/student/Translations/Translator.java", "/task/student/Translations/Translator.java")
try: try:
task_options = json.load(open('config.json', 'r', encoding="utf-8")) task_options = json.load(open('/task/config.json', 'r', encoding="utf-8"))
except JSONDecodeError as e: except JSONDecodeError as e:
print(_("Impossible de décoder le config.json")) print(_("Impossible de décoder le config.json"))
print(e) print(e)
......
#!/bin/python3
import importlib.util
import sys
import json
from json import JSONDecodeError
from distutils.file_util import copy_file
import os
# Dynamically load modules we need
# Credits to https://stackoverflow.com/a/67692/6149867
# And for the explanation : http://www.blog.pythonlibrary.org/2016/05/27/python-201-an-intro-to-importlib/
def dynamically_load_module(module, path):
spec = importlib.util.spec_from_file_location(module, path)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
return mod
#####################################
# Our import for common run file #
#####################################
sys.path.append("/course/common")
runfile = dynamically_load_module("runfile", "/course/common/runfile.py")
isExist = os.path.exists("./student/Translations")
if not isExist:
os.makedirs("./student/Translations")
copy_file("/course/common/student/Translations/Translator.java", "./student/Translations/Translator.java")
try:
task_options = json.load(open('config.json', 'r', encoding="utf-8"))
except JSONDecodeError as e:
print(_("Impossible de décoder le config.json"))
print(e)
exit()
runfile.run(**task_options)
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter