From 9ec0e12bf0ecdccbb4b8b720feffaeeebcdcefde Mon Sep 17 00:00:00 2001 From: anaHue <anatole.huet@student.uclouvain.be> Date: Fri, 11 Mar 2022 09:31:14 +0100 Subject: [PATCH] update - working run file --- javaCommon/run | 11 +++-- .../student/Translations/translations_run/run | 40 ------------------- 2 files changed, 7 insertions(+), 44 deletions(-) delete mode 100644 javaCommon/student/Translations/translations_run/run diff --git a/javaCommon/run b/javaCommon/run index 4e42a5f..d56c51f 100755 --- a/javaCommon/run +++ b/javaCommon/run @@ -5,6 +5,7 @@ import json from json import JSONDecodeError from distutils.file_util import copy_file import os +import inginious_container_api.feedback # Dynamically load modules we need # Credits to https://stackoverflow.com/a/67692/6149867 @@ -16,6 +17,7 @@ def dynamically_load_module(module, path): return mod + ##################################### # Our import for common run file # ##################################### @@ -23,15 +25,16 @@ sys.path.append("/course/common") 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: - 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: - 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: print(_("Impossible de décoder le config.json")) print(e) diff --git a/javaCommon/student/Translations/translations_run/run b/javaCommon/student/Translations/translations_run/run deleted file mode 100644 index da2508d..0000000 --- a/javaCommon/student/Translations/translations_run/run +++ /dev/null @@ -1,40 +0,0 @@ -#!/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 -- GitLab