Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/config.py
| # Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-2020 The Software Heritage developers | ||||
| # See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
| # License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
| # See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
| import os | import os | ||||
| from typing import Any, Dict | from typing import Any, Dict | ||||
| from swh.core import config | from swh.core import config | ||||
| from swh.deposit import __version__ | |||||
| from swh.scheduler import get_scheduler | from swh.scheduler import get_scheduler | ||||
| from swh.scheduler.interface import SchedulerInterface | from swh.scheduler.interface import SchedulerInterface | ||||
| # IRIs (Internationalized Resource identifier) sword 2.0 specified | # IRIs (Internationalized Resource identifier) sword 2.0 specified | ||||
| EDIT_SE_IRI = "edit_se_iri" | EDIT_SE_IRI = "edit_se_iri" | ||||
| EM_IRI = "em_iri" | EM_IRI = "em_iri" | ||||
| CONT_FILE_IRI = "cont_file_iri" | CONT_FILE_IRI = "cont_file_iri" | ||||
| SD_IRI = "servicedocument" | SD_IRI = "servicedocument" | ||||
| Show All 33 Lines | |||||
| DEFAULT_CONFIG = { | DEFAULT_CONFIG = { | ||||
| "max_upload_size": 209715200, | "max_upload_size": 209715200, | ||||
| "checks": True, | "checks": True, | ||||
| } | } | ||||
| def setup_django_for(platform=None, config_file=None): | def setup_django_for(platform=None, config_file=None): | ||||
| """Setup function for command line tools (swh.deposit.create_user) to | """Setup function for command line tools (swh.deposit.create_user) to | ||||
| initialize the needed db access. | initialize the needed db access. | ||||
ardumont: a priori irrelevant, so can go away. | |||||
| Note: | Note: | ||||
| Do not import any django related module prior to this function | Do not import any django related module prior to this function | ||||
| call. Otherwise, this will raise an | call. Otherwise, this will raise an | ||||
| django.core.exceptions.ImproperlyConfigured error message. | django.core.exceptions.ImproperlyConfigured error message. | ||||
| Args: | Args: | ||||
| platform (str): the platform the scheduling is running | platform (str): the platform the scheduling is running | ||||
| Show All 24 Lines | class APIConfig: | ||||
| """ | """ | ||||
| def __init__(self): | def __init__(self): | ||||
| config_file = os.environ["SWH_CONFIG_FILENAME"] | config_file = os.environ["SWH_CONFIG_FILENAME"] | ||||
| conf = config.read_raw_config(config.config_basepath(config_file)) | conf = config.read_raw_config(config.config_basepath(config_file)) | ||||
| self.config: Dict[str, Any] = config.merge_configs(DEFAULT_CONFIG, conf) | self.config: Dict[str, Any] = config.merge_configs(DEFAULT_CONFIG, conf) | ||||
| self.scheduler: SchedulerInterface = get_scheduler(**self.config["scheduler"]) | self.scheduler: SchedulerInterface = get_scheduler(**self.config["scheduler"]) | ||||
| self.provider = self.config["provider"] | |||||
| self.tool = { | |||||
| "name": "swh-deposit", | |||||
| "version": __version__, | |||||
| "configuration": {"sword_version": "2"}, | |||||
Done Inline Actions@moranegg here is the tool also passed along to the loader through the private deposit_read api (used as the fetcher thing). ardumont: @moranegg here is the tool also passed along to the loader through the private deposit_read api… | |||||
Done Inline Actionsthanks for the comment. self.fetcher = {
...moranegg: thanks for the comment.
Maybe renaming `tool` to `fetcher` can give less headache later?
```… | |||||
Done Inline Actionsyes, possibly, in another diff though (as it is currently used elsewhere already for the same use). ardumont: yes, possibly, in another diff though (as it is currently used elsewhere already for the same… | |||||
| } | |||||
a priori irrelevant, so can go away.