Loading circe/__init__.py +24 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ import tarfile import zipfile from time import sleep version = "0.0.29" version = "0.0.34" try: from uuid import uuid4 Loading @@ -31,6 +31,7 @@ try: from itsdangerous.exc import BadSignature from shutil import rmtree, make_archive from unicodedata import normalize from pathlib import Path import re import aiofiles import logging Loading Loading @@ -146,7 +147,9 @@ def _check_port(host, port): def _make_homepage(): tpl = ( "<!DOCTYPE html>" '<html lang="fr"><head><meta charset="UTF-8"/><title>Circe - Transformations de documents</title>' '<html lang="fr"><head><meta charset="UTF-8"/><title>Circe ' + version + " - Transformations de documents</title>" "<style>" "body{{font-family: sans-serif;color:#495057;}}" "pre{{color:#c5c8c6; background-color:#1d1f21;padding:10px;line-height:0.8em;border-radius:5px;}}" Loading Loading @@ -196,6 +199,11 @@ async def index(request: sanic.request): return sanic.response.html(STATIC_HOMEPAGE_HTML) @server.get("/version/") async def index(request: sanic.request): return sanic.response.text(version) @server.get("/transformations/") async def transformations(request: sanic.request): return sanic.response.HTTPResponse( Loading @@ -214,7 +222,12 @@ async def job_get(request: sanic.request, job_id: str): result_file_path = "{}/done/{}.tar.gz".format(CONFIG["CIRCE_WORKING_DIR"], job_id) if os.path.isfile(result_file_path): if request.args.get("zip", None): pass # convert tar.gz to zip and return zip result_zip_path = "{}done/{}.zip".format( CONFIG["CIRCE_WORKING_DIR"], job_id ) if not os.path.isfile(result_zip_path): _convert_targz_to_zip(result_file_path, result_zip_path) return await sanic.response.file(result_file_path) return await sanic.response.file(result_file_path) # file_stream is slow ? bad chunk size ? # return await sanic.response.file_stream(result_file_path, chunked=False) Loading @@ -241,6 +254,14 @@ async def job_post(request: sanic.request): return sanic.response.text(uuid.hex) if CONFIG["CIRCE_UPDATE_NOTIFY_ROUTE"]: @server.route("/hook/", methods=["POST", "GET"]) async def notify_update(request: sanic.request): Path("{}/upgrade_me".format(CONFIG["CIRCE_WORKING_DIR"])).touch() return sanic.response.text("ok") if CONFIG["CIRCE_ENABLE_WEB_UI"]: cookie_signer = Signer(CONFIG["CIRCE_WEB_UI_CRYPT_KEY"]) Loading circe/config.py +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ CONFIG = { "CIRCE_WEB_UI_CRYPT_KEY": "you should really change this", "CIRCE_WEB_UI_REMOVE_USER_FILES_DELAY": 7200, "CIRCE_TRANSFORMATIONS_MODULE": None, "CIRCE_UPDATE_NOTIFY_ROUTE": False, } for key in CONFIG.keys(): Loading @@ -31,6 +32,7 @@ for key in CONFIG.keys(): "CIRCE_ACCESS_LOG", "CIRCE_IMMEDIATE_MODE", "CIRCE_ENABLE_WEB_UI", "CIRCE_UPDATE_NOTIFY_ROUTE", ]: CONFIG[key] = True if val == "1" else False elif key in ["CIRCE_PORT"]: Loading setup.py +2 −1 Original line number Diff line number Diff line import setuptools from circe import version with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="circe-CERTIC", version="0.0.33", version=version, author="Mickaël Desfrênes", author_email="mickael.desfrenes@unicaen.fr", description="Circe server", Loading Loading
circe/__init__.py +24 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ import tarfile import zipfile from time import sleep version = "0.0.29" version = "0.0.34" try: from uuid import uuid4 Loading @@ -31,6 +31,7 @@ try: from itsdangerous.exc import BadSignature from shutil import rmtree, make_archive from unicodedata import normalize from pathlib import Path import re import aiofiles import logging Loading Loading @@ -146,7 +147,9 @@ def _check_port(host, port): def _make_homepage(): tpl = ( "<!DOCTYPE html>" '<html lang="fr"><head><meta charset="UTF-8"/><title>Circe - Transformations de documents</title>' '<html lang="fr"><head><meta charset="UTF-8"/><title>Circe ' + version + " - Transformations de documents</title>" "<style>" "body{{font-family: sans-serif;color:#495057;}}" "pre{{color:#c5c8c6; background-color:#1d1f21;padding:10px;line-height:0.8em;border-radius:5px;}}" Loading Loading @@ -196,6 +199,11 @@ async def index(request: sanic.request): return sanic.response.html(STATIC_HOMEPAGE_HTML) @server.get("/version/") async def index(request: sanic.request): return sanic.response.text(version) @server.get("/transformations/") async def transformations(request: sanic.request): return sanic.response.HTTPResponse( Loading @@ -214,7 +222,12 @@ async def job_get(request: sanic.request, job_id: str): result_file_path = "{}/done/{}.tar.gz".format(CONFIG["CIRCE_WORKING_DIR"], job_id) if os.path.isfile(result_file_path): if request.args.get("zip", None): pass # convert tar.gz to zip and return zip result_zip_path = "{}done/{}.zip".format( CONFIG["CIRCE_WORKING_DIR"], job_id ) if not os.path.isfile(result_zip_path): _convert_targz_to_zip(result_file_path, result_zip_path) return await sanic.response.file(result_file_path) return await sanic.response.file(result_file_path) # file_stream is slow ? bad chunk size ? # return await sanic.response.file_stream(result_file_path, chunked=False) Loading @@ -241,6 +254,14 @@ async def job_post(request: sanic.request): return sanic.response.text(uuid.hex) if CONFIG["CIRCE_UPDATE_NOTIFY_ROUTE"]: @server.route("/hook/", methods=["POST", "GET"]) async def notify_update(request: sanic.request): Path("{}/upgrade_me".format(CONFIG["CIRCE_WORKING_DIR"])).touch() return sanic.response.text("ok") if CONFIG["CIRCE_ENABLE_WEB_UI"]: cookie_signer = Signer(CONFIG["CIRCE_WEB_UI_CRYPT_KEY"]) Loading
circe/config.py +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ CONFIG = { "CIRCE_WEB_UI_CRYPT_KEY": "you should really change this", "CIRCE_WEB_UI_REMOVE_USER_FILES_DELAY": 7200, "CIRCE_TRANSFORMATIONS_MODULE": None, "CIRCE_UPDATE_NOTIFY_ROUTE": False, } for key in CONFIG.keys(): Loading @@ -31,6 +32,7 @@ for key in CONFIG.keys(): "CIRCE_ACCESS_LOG", "CIRCE_IMMEDIATE_MODE", "CIRCE_ENABLE_WEB_UI", "CIRCE_UPDATE_NOTIFY_ROUTE", ]: CONFIG[key] = True if val == "1" else False elif key in ["CIRCE_PORT"]: Loading
setup.py +2 −1 Original line number Diff line number Diff line import setuptools from circe import version with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="circe-CERTIC", version="0.0.33", version=version, author="Mickaël Desfrênes", author_email="mickael.desfrenes@unicaen.fr", description="Circe server", Loading