Loading circe/__init__.py +13 −18 Original line number Diff line number Diff line Loading @@ -4,10 +4,6 @@ import uuid import tarfile import zipfile from time import sleep version = "0.0.40" try: from uuid import uuid4 import sanic.request import sanic.response Loading @@ -15,7 +11,7 @@ try: from sanic import Sanic from .config import CONFIG from . import tasks from subprocess import call, Popen from subprocess import call from multiprocessing import Process import asyncio import sqlite3 Loading @@ -34,16 +30,9 @@ try: from pathlib import Path import re import aiofiles import logging import tempfile from pythonjsonlogger import jsonlogger except ModuleNotFoundError as e: sys.exit("Import error: {}. Please refer to the documentation.".format(e)) import argh try: assert sys.version_info >= (3, 6) except AssertionError: sys.exit("Please update your python (>= 3.6)") version = "0.0.43" AUTH_DB_PATH = "{}/auth.db".format(CONFIG["CIRCE_WORKING_DIR"]) Loading Loading @@ -201,7 +190,7 @@ async def index(request: sanic.request): @server.get("/version/") async def index(request: sanic.request): async def server_version(request: sanic.request): return sanic.response.text(version) Loading Loading @@ -473,10 +462,16 @@ def remove_api_access(app_uuid: str): conn.commit() @argh.arg( "--app_uuid", help="specify app uuid to change existing access. Ignore to create new access.", ) @argh.arg("--title", help="Title of access (name of app).") @argh.arg("--out", help="output credentials in json format to given file") def make_api_access( app_uuid: "specify app uuid to change existing access. Ignore to create new access." = None, title: "Title of access (name of app)." = None, out: "output credentials in json format to given file" = None, app_uuid: str = None, title: str = None, out: str = None, ): """ Create new app uuid / secret couple for api access. Loading circe/config.py +9 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ CONFIG = { "CIRCE_WEB_UI_REMOVE_USER_FILES_DELAY": 7200, "CIRCE_TRANSFORMATIONS_MODULE": None, "CIRCE_UPDATE_NOTIFY_ROUTE": False, "CIRCE_TEMP_DIR": None, "ALLOWED_WEBHOOK_HOSTS": [], } for key in CONFIG.keys(): Loading @@ -37,6 +39,9 @@ for key in CONFIG.keys(): CONFIG[key] = True if val == "1" else False elif key in ["CIRCE_PORT"]: CONFIG[key] = int(val) elif key == "ALLOWED_WEBHOOK_HOSTS": CONFIG[key] = val.split(",") pass else: CONFIG[key] = val except KeyError: Loading @@ -54,10 +59,14 @@ if ( if CONFIG["CIRCE_IMMEDIATE_MODE"]: CONFIG["CIRCE_WORKERS"] = 1 if not CONFIG["CIRCE_TEMP_DIR"]: CONFIG["CIRCE_TEMP_DIR"] = "{}/tmp/".format(CONFIG["CIRCE_WORKING_DIR"]) paths = [ CONFIG["CIRCE_WORKING_DIR"], "{}/queue/".format(CONFIG["CIRCE_WORKING_DIR"]), "{}/done/".format(CONFIG["CIRCE_WORKING_DIR"]), CONFIG["CIRCE_TEMP_DIR"], ] for path in paths: os.makedirs(path, exist_ok=True) Loading circe/tasks.py +4 −5 Original line number Diff line number Diff line Loading @@ -8,9 +8,7 @@ from uuid import uuid4 import json import requests from requests.exceptions import ConnectionError, HTTPError import logging from inspect import getmembers, isfunction, isclass, signature import sys from pythonjsonlogger import jsonlogger import datetime import logging Loading Loading @@ -95,8 +93,7 @@ def remove_file(file_path): @huey.task() def do_transformations(uuid: uuid4, job_archive_path: str): with tempfile.TemporaryDirectory() as tmp_dir: with tempfile.TemporaryDirectory(dir=CONFIG["CIRCE_TEMP_DIR"]) as tmp_dir: handler: logging.FileHandler = logging.FileHandler("{}/out.log".format(tmp_dir)) handler.setFormatter( CustomJsonFormatter("%(timestamp)s %(level)s %(name)s %(message)s") Loading Loading @@ -137,7 +134,9 @@ def do_transformations(uuid: uuid4, job_archive_path: str): "time": _stamp(), } ) _, temp_zip_path = tempfile.mkstemp(suffix=".tar.gz") _, temp_zip_path = tempfile.mkstemp( suffix=".tar.gz", dir=CONFIG["CIRCE_TEMP_DIR"] ) with tarfile.open(temp_zip_path, "w:gz") as destination_archive: destination_archive.add(tmp_dir, recursive=True, arcname="") final_archive_path = "{}/done/{}.tar.gz".format( Loading poetry.lock +162 −199 File changed.Preview size limit exceeded, changes collapsed. Show changes pyproject.toml +15 −13 Original line number Diff line number Diff line [tool.poetry] name = "circe-CERTIC" readme = "README.md" version = "0.0.40" version = "0.0.43" description = "Circe Server" authors = ["Mickaël Desfrênes <mickael.desfrenes@unicaen.fr>"] license = "CeCILL-B" Loading @@ -10,20 +10,22 @@ packages = [ ] [tool.poetry.dependencies] python = "^3.9" requests = "^2.28.0" argh = "^0.26.2" sanic = "^22.3.2" huey = "^2.4.3" asyncio = "^3.4.3" itsdangerous = "^2.1.2" aiofiles = "^0.8.0" markdown2 = "^2.4.3" python-json-logger = "^2.0.2" python-dotenv = "^0.20.0" python = ">=3.9,<4" requests = ">=2.28.0" argh = ">=0.28.1" sanic = ">=22.3.2" huey = ">=2.4.3" asyncio = ">=3.4.3" itsdangerous = ">=2.1.2" aiofiles = ">=23.1.0" markdown2 = ">=2.4.3" python-json-logger = ">=2.0.2" python-dotenv = ">=1.0.0" [tool.poetry.dev-dependencies] black = "^22.3.0" black = "*" circe-client-CERTIC = "*" pytest = "*" [tool.poetry.scripts] circe = "circe.__main__:run_cli" Loading Loading
circe/__init__.py +13 −18 Original line number Diff line number Diff line Loading @@ -4,10 +4,6 @@ import uuid import tarfile import zipfile from time import sleep version = "0.0.40" try: from uuid import uuid4 import sanic.request import sanic.response Loading @@ -15,7 +11,7 @@ try: from sanic import Sanic from .config import CONFIG from . import tasks from subprocess import call, Popen from subprocess import call from multiprocessing import Process import asyncio import sqlite3 Loading @@ -34,16 +30,9 @@ try: from pathlib import Path import re import aiofiles import logging import tempfile from pythonjsonlogger import jsonlogger except ModuleNotFoundError as e: sys.exit("Import error: {}. Please refer to the documentation.".format(e)) import argh try: assert sys.version_info >= (3, 6) except AssertionError: sys.exit("Please update your python (>= 3.6)") version = "0.0.43" AUTH_DB_PATH = "{}/auth.db".format(CONFIG["CIRCE_WORKING_DIR"]) Loading Loading @@ -201,7 +190,7 @@ async def index(request: sanic.request): @server.get("/version/") async def index(request: sanic.request): async def server_version(request: sanic.request): return sanic.response.text(version) Loading Loading @@ -473,10 +462,16 @@ def remove_api_access(app_uuid: str): conn.commit() @argh.arg( "--app_uuid", help="specify app uuid to change existing access. Ignore to create new access.", ) @argh.arg("--title", help="Title of access (name of app).") @argh.arg("--out", help="output credentials in json format to given file") def make_api_access( app_uuid: "specify app uuid to change existing access. Ignore to create new access." = None, title: "Title of access (name of app)." = None, out: "output credentials in json format to given file" = None, app_uuid: str = None, title: str = None, out: str = None, ): """ Create new app uuid / secret couple for api access. Loading
circe/config.py +9 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ CONFIG = { "CIRCE_WEB_UI_REMOVE_USER_FILES_DELAY": 7200, "CIRCE_TRANSFORMATIONS_MODULE": None, "CIRCE_UPDATE_NOTIFY_ROUTE": False, "CIRCE_TEMP_DIR": None, "ALLOWED_WEBHOOK_HOSTS": [], } for key in CONFIG.keys(): Loading @@ -37,6 +39,9 @@ for key in CONFIG.keys(): CONFIG[key] = True if val == "1" else False elif key in ["CIRCE_PORT"]: CONFIG[key] = int(val) elif key == "ALLOWED_WEBHOOK_HOSTS": CONFIG[key] = val.split(",") pass else: CONFIG[key] = val except KeyError: Loading @@ -54,10 +59,14 @@ if ( if CONFIG["CIRCE_IMMEDIATE_MODE"]: CONFIG["CIRCE_WORKERS"] = 1 if not CONFIG["CIRCE_TEMP_DIR"]: CONFIG["CIRCE_TEMP_DIR"] = "{}/tmp/".format(CONFIG["CIRCE_WORKING_DIR"]) paths = [ CONFIG["CIRCE_WORKING_DIR"], "{}/queue/".format(CONFIG["CIRCE_WORKING_DIR"]), "{}/done/".format(CONFIG["CIRCE_WORKING_DIR"]), CONFIG["CIRCE_TEMP_DIR"], ] for path in paths: os.makedirs(path, exist_ok=True) Loading
circe/tasks.py +4 −5 Original line number Diff line number Diff line Loading @@ -8,9 +8,7 @@ from uuid import uuid4 import json import requests from requests.exceptions import ConnectionError, HTTPError import logging from inspect import getmembers, isfunction, isclass, signature import sys from pythonjsonlogger import jsonlogger import datetime import logging Loading Loading @@ -95,8 +93,7 @@ def remove_file(file_path): @huey.task() def do_transformations(uuid: uuid4, job_archive_path: str): with tempfile.TemporaryDirectory() as tmp_dir: with tempfile.TemporaryDirectory(dir=CONFIG["CIRCE_TEMP_DIR"]) as tmp_dir: handler: logging.FileHandler = logging.FileHandler("{}/out.log".format(tmp_dir)) handler.setFormatter( CustomJsonFormatter("%(timestamp)s %(level)s %(name)s %(message)s") Loading Loading @@ -137,7 +134,9 @@ def do_transformations(uuid: uuid4, job_archive_path: str): "time": _stamp(), } ) _, temp_zip_path = tempfile.mkstemp(suffix=".tar.gz") _, temp_zip_path = tempfile.mkstemp( suffix=".tar.gz", dir=CONFIG["CIRCE_TEMP_DIR"] ) with tarfile.open(temp_zip_path, "w:gz") as destination_archive: destination_archive.add(tmp_dir, recursive=True, arcname="") final_archive_path = "{}/done/{}.tar.gz".format( Loading
pyproject.toml +15 −13 Original line number Diff line number Diff line [tool.poetry] name = "circe-CERTIC" readme = "README.md" version = "0.0.40" version = "0.0.43" description = "Circe Server" authors = ["Mickaël Desfrênes <mickael.desfrenes@unicaen.fr>"] license = "CeCILL-B" Loading @@ -10,20 +10,22 @@ packages = [ ] [tool.poetry.dependencies] python = "^3.9" requests = "^2.28.0" argh = "^0.26.2" sanic = "^22.3.2" huey = "^2.4.3" asyncio = "^3.4.3" itsdangerous = "^2.1.2" aiofiles = "^0.8.0" markdown2 = "^2.4.3" python-json-logger = "^2.0.2" python-dotenv = "^0.20.0" python = ">=3.9,<4" requests = ">=2.28.0" argh = ">=0.28.1" sanic = ">=22.3.2" huey = ">=2.4.3" asyncio = ">=3.4.3" itsdangerous = ">=2.1.2" aiofiles = ">=23.1.0" markdown2 = ">=2.4.3" python-json-logger = ">=2.0.2" python-dotenv = ">=1.0.0" [tool.poetry.dev-dependencies] black = "^22.3.0" black = "*" circe-client-CERTIC = "*" pytest = "*" [tool.poetry.scripts] circe = "circe.__main__:run_cli" Loading