Loading circe/__init__.py +20 −24 Original line number Diff line number Diff line import os import sys import uuid from time import sleep try: Loading Loading @@ -283,32 +284,27 @@ if CONFIG["CIRCE_ENABLE_WEB_UI"]: CONFIG["CIRCE_WORKING_DIR"], session_id ) if os.path.isdir(session_dir): handler: logging.FileHandler = logging.FileHandler( "{}/out.log".format(session_dir) job_conf = {"transformations": json.loads(request.body)} with open("{}/job.json".format(session_dir), "w") as f: json.dump(job_conf, f) archive_destination_path = "{}/queue/{}.tar.gz".format( CONFIG["CIRCE_WORKING_DIR"], session_id ) handler.setFormatter( tasks.CustomJsonFormatter( "%(timestamp)s %(level)s %(name)s %(message)s" make_archive( "{}/queue/{}".format(CONFIG["CIRCE_WORKING_DIR"], session_id), "gztar", session_dir, ) job = tasks.do_transformations( uuid.UUID(session_id), archive_destination_path ) logger: logging.Logger = logging.Logger("job_logger_{}".format(session_id)) logger.setLevel(logging.DEBUG) logger.addHandler(handler) transfos = json.loads(request.body) for transfo in transfos: if transfo["name"] in tasks.registered_transfos.keys(): tasks.registered_transfos[transfo["name"]]( session_dir, logger, transfo["options"] ) zip_path = "{}web_ui_sessions/{}".format( job_done_archive = "{}/done/{}.tar.gz".format( CONFIG["CIRCE_WORKING_DIR"], session_id ) make_archive(zip_path, "zip", session_dir) tasks.remove_file.schedule( (zip_path + ".zip",), delay=CONFIG["CIRCE_WEB_UI_REMOVE_USER_FILES_DELAY"], ) while True: if os.path.isfile(job_done_archive): break await asyncio.sleep(1) rmtree(session_dir, ignore_errors=True) return sanic.response.HTTPResponse("ok", status=200) return sanic.response.HTTPResponse("Bad Request", status=400) Loading @@ -317,12 +313,12 @@ if CONFIG["CIRCE_ENABLE_WEB_UI"]: async def fetch_job(request: sanic.request): session_id = _check_request_session(request) job_id = session_id result_file_path = "{}web_ui_sessions/{}.zip".format( result_file_path = "{}done/{}.tar.gz".format( CONFIG["CIRCE_WORKING_DIR"], job_id ) if os.path.isfile(result_file_path): return await sanic.response.file( result_file_path, filename="{}.zip".format(job_id) result_file_path, filename="{}.tar.gz".format(job_id) ) return sanic.response.HTTPResponse("Not Found", status=404) Loading setup.py +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ with open("README.md", "r") as fh: setuptools.setup( name="circe-CERTIC", version="0.0.26", version="0.0.27", author="Mickaël Desfrênes", author_email="mickael.desfrenes@unicaen.fr", description="Circe server", Loading Loading
circe/__init__.py +20 −24 Original line number Diff line number Diff line import os import sys import uuid from time import sleep try: Loading Loading @@ -283,32 +284,27 @@ if CONFIG["CIRCE_ENABLE_WEB_UI"]: CONFIG["CIRCE_WORKING_DIR"], session_id ) if os.path.isdir(session_dir): handler: logging.FileHandler = logging.FileHandler( "{}/out.log".format(session_dir) job_conf = {"transformations": json.loads(request.body)} with open("{}/job.json".format(session_dir), "w") as f: json.dump(job_conf, f) archive_destination_path = "{}/queue/{}.tar.gz".format( CONFIG["CIRCE_WORKING_DIR"], session_id ) handler.setFormatter( tasks.CustomJsonFormatter( "%(timestamp)s %(level)s %(name)s %(message)s" make_archive( "{}/queue/{}".format(CONFIG["CIRCE_WORKING_DIR"], session_id), "gztar", session_dir, ) job = tasks.do_transformations( uuid.UUID(session_id), archive_destination_path ) logger: logging.Logger = logging.Logger("job_logger_{}".format(session_id)) logger.setLevel(logging.DEBUG) logger.addHandler(handler) transfos = json.loads(request.body) for transfo in transfos: if transfo["name"] in tasks.registered_transfos.keys(): tasks.registered_transfos[transfo["name"]]( session_dir, logger, transfo["options"] ) zip_path = "{}web_ui_sessions/{}".format( job_done_archive = "{}/done/{}.tar.gz".format( CONFIG["CIRCE_WORKING_DIR"], session_id ) make_archive(zip_path, "zip", session_dir) tasks.remove_file.schedule( (zip_path + ".zip",), delay=CONFIG["CIRCE_WEB_UI_REMOVE_USER_FILES_DELAY"], ) while True: if os.path.isfile(job_done_archive): break await asyncio.sleep(1) rmtree(session_dir, ignore_errors=True) return sanic.response.HTTPResponse("ok", status=200) return sanic.response.HTTPResponse("Bad Request", status=400) Loading @@ -317,12 +313,12 @@ if CONFIG["CIRCE_ENABLE_WEB_UI"]: async def fetch_job(request: sanic.request): session_id = _check_request_session(request) job_id = session_id result_file_path = "{}web_ui_sessions/{}.zip".format( result_file_path = "{}done/{}.tar.gz".format( CONFIG["CIRCE_WORKING_DIR"], job_id ) if os.path.isfile(result_file_path): return await sanic.response.file( result_file_path, filename="{}.zip".format(job_id) result_file_path, filename="{}.tar.gz".format(job_id) ) return sanic.response.HTTPResponse("Not Found", status=404) Loading
setup.py +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ with open("README.md", "r") as fh: setuptools.setup( name="circe-CERTIC", version="0.0.26", version="0.0.27", author="Mickaël Desfrênes", author_email="mickael.desfrenes@unicaen.fr", description="Circe server", Loading