diff --git a/PKG-INFO b/PKG-INFO index 980527a7..4e229c89 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,34 +1,34 @@ Metadata-Version: 2.1 Name: swh.deposit -Version: 0.0.66 +Version: 0.0.67 Summary: Software Heritage Deposit Server Home-page: https://forge.softwareheritage.org/source/swh-deposit/ Author: Software Heritage developers Author-email: swh-devel@inria.fr License: UNKNOWN +Project-URL: Bug Reports, https://forge.softwareheritage.org/maniphest Project-URL: Funding, https://www.softwareheritage.org/donate Project-URL: Source, https://forge.softwareheritage.org/source/swh-deposit -Project-URL: Bug Reports, https://forge.softwareheritage.org/maniphest Description: # swh-deposit This is [Software Heritage](https://www.softwareheritage.org)'s [SWORD 2.0](http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html) Server implementation. **S.W.O.R.D** (**S**imple **W**eb-Service **O**ffering **R**epository **D**eposit) is an interoperability standard for digital file deposit. This implementation will permit interaction between a client (a repository) and a server (SWH repository) to permit deposits of software source code archives and associated metadata. The documentation is at ./docs/README-specification.md Platform: UNKNOWN Classifier: Programming Language :: Python :: 3 Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) Classifier: Operating System :: OS Independent Classifier: Development Status :: 5 - Production/Stable Description-Content-Type: text/markdown Provides-Extra: testing diff --git a/requirements-swh.txt b/requirements-swh.txt index dc3f43fe..ae6f63e2 100644 --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -1,5 +1,5 @@ swh.core >= 0.0.36 -swh.loader.tar >= 0.0.37 +swh.loader.tar >= 0.0.39 swh.loader.core >= 0.0.32 swh.scheduler >= 0.0.39 swh.model >= 0.0.26 diff --git a/swh.deposit.egg-info/PKG-INFO b/swh.deposit.egg-info/PKG-INFO index 980527a7..4e229c89 100644 --- a/swh.deposit.egg-info/PKG-INFO +++ b/swh.deposit.egg-info/PKG-INFO @@ -1,34 +1,34 @@ Metadata-Version: 2.1 Name: swh.deposit -Version: 0.0.66 +Version: 0.0.67 Summary: Software Heritage Deposit Server Home-page: https://forge.softwareheritage.org/source/swh-deposit/ Author: Software Heritage developers Author-email: swh-devel@inria.fr License: UNKNOWN +Project-URL: Bug Reports, https://forge.softwareheritage.org/maniphest Project-URL: Funding, https://www.softwareheritage.org/donate Project-URL: Source, https://forge.softwareheritage.org/source/swh-deposit -Project-URL: Bug Reports, https://forge.softwareheritage.org/maniphest Description: # swh-deposit This is [Software Heritage](https://www.softwareheritage.org)'s [SWORD 2.0](http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html) Server implementation. **S.W.O.R.D** (**S**imple **W**eb-Service **O**ffering **R**epository **D**eposit) is an interoperability standard for digital file deposit. This implementation will permit interaction between a client (a repository) and a server (SWH repository) to permit deposits of software source code archives and associated metadata. The documentation is at ./docs/README-specification.md Platform: UNKNOWN Classifier: Programming Language :: Python :: 3 Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) Classifier: Operating System :: OS Independent Classifier: Development Status :: 5 - Production/Stable Description-Content-Type: text/markdown Provides-Extra: testing diff --git a/swh.deposit.egg-info/requires.txt b/swh.deposit.egg-info/requires.txt index 3a09e20b..748cff14 100644 --- a/swh.deposit.egg-info/requires.txt +++ b/swh.deposit.egg-info/requires.txt @@ -1,15 +1,15 @@ vcversioner click Django<2.0 djangorestframework xmltodict swh.core>=0.0.36 -swh.loader.tar>=0.0.37 +swh.loader.tar>=0.0.39 swh.loader.core>=0.0.32 swh.scheduler>=0.0.39 swh.model>=0.0.26 [testing] pytest<4 pytest-django swh.scheduler[testing] diff --git a/swh/deposit/config.py b/swh/deposit/config.py index 2e6b35e1..1800d67c 100644 --- a/swh/deposit/config.py +++ b/swh/deposit/config.py @@ -1,101 +1,101 @@ # Copyright (C) 2017-2018 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import os import logging from swh.core.config import SWHConfig from swh.scheduler import get_scheduler # IRIs (Internationalized Resource identifier) sword 2.0 specified EDIT_SE_IRI = 'edit_se_iri' EM_IRI = 'em_iri' CONT_FILE_IRI = 'cont_file_iri' SD_IRI = 'servicedocument' COL_IRI = 'upload' STATE_IRI = 'state_iri' PRIVATE_GET_RAW_CONTENT = 'private-download' PRIVATE_CHECK_DEPOSIT = 'check-deposit' PRIVATE_PUT_DEPOSIT = 'private-update' PRIVATE_GET_DEPOSIT_METADATA = 'private-read' PRIVATE_LIST_DEPOSITS = 'private-deposit-list' ARCHIVE_KEY = 'archive' METADATA_KEY = 'metadata' RAW_METADATA_KEY = 'raw-metadata' ARCHIVE_TYPE = 'archive' METADATA_TYPE = 'metadata' AUTHORIZED_PLATFORMS = ['development', 'production', 'testing'] DEPOSIT_STATUS_REJECTED = 'rejected' DEPOSIT_STATUS_PARTIAL = 'partial' DEPOSIT_STATUS_DEPOSITED = 'deposited' DEPOSIT_STATUS_VERIFIED = 'verified' DEPOSIT_STATUS_LOAD_SUCCESS = 'done' DEPOSIT_STATUS_LOAD_FAILURE = 'failed' # Revision author for deposit SWH_PERSON = { 'name': 'Software Heritage', 'fullname': 'Software Heritage', 'email': 'robot@softwareheritage.org' } def setup_django_for(platform): - """Setup function for command line tools (swh.deposit.create_user, - swh.deposit.scheduler.cli) to initialize the needed db access. + """Setup function for command line tools (swh.deposit.create_user) to + initialize the needed db access. Note: Do not import any django related module prior to this function call. Otherwise, this will raise an django.core.exceptions.ImproperlyConfigured error message. Args: platform (str): the platform the scheduling is running Raises: ValueError in case of wrong platform inputs. """ if platform not in AUTHORIZED_PLATFORMS: raise ValueError('Platform should be one of %s' % AUTHORIZED_PLATFORMS) os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'swh.deposit.settings.%s' % platform) import django django.setup() class SWHDefaultConfig(SWHConfig): """Mixin intended to enrich views with SWH configuration. """ CONFIG_BASE_FILENAME = 'deposit/server' DEFAULT_CONFIG = { 'max_upload_size': ('int', 209715200), 'checks': ('bool', True), 'scheduler': ('dict', { 'cls': 'remote', 'args': { 'url': 'http://localhost:5008/' } }) } ADDITIONAL_CONFIG = {} def __init__(self, **config): super().__init__() self.config = self.parse_config_file( additional_configs=[self.ADDITIONAL_CONFIG]) self.config.update(config) self.log = logging.getLogger('swh.deposit') if self.config['checks']: self.scheduler = get_scheduler(**self.config['scheduler']) diff --git a/swh/deposit/settings/production.py b/swh/deposit/settings/production.py index e8a99bee..bf848528 100644 --- a/swh/deposit/settings/production.py +++ b/swh/deposit/settings/production.py @@ -1,91 +1,107 @@ -# Copyright (C) 2017 The Software Heritage developers +# Copyright (C) 2017-2019 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +import os + from .common import * # noqa from .common import ALLOWED_HOSTS from swh.core import config ALLOWED_HOSTS += ['deposit.softwareheritage.org'] # Setup support for proxy headers USE_X_FORWARDED_HOST = True SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') DEBUG = False # Database # https://docs.djangoproject.com/en/1.10/ref/settings/#databases # https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-DATABASES # https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/#databases -DEFAULT_PATH = 'deposit/private' - -private_conf = config.load_named_config(DEFAULT_PATH) - -if not private_conf: - raise ValueError('Cannot run in production, missing private data file.') - -SECRET_KEY = private_conf.get('secret_key', 'change me') +# Retrieve the deposit's configuration file +# and check the required setup is ok +# If not raise an error explaining the errors +config_file = os.environ.get('SWH_CONFIG_FILENAME') +if not os.path.exists(config_file): + raise ValueError('Production: configuration file %s does not exist!' % ( + config_file, )) + +conf = config.load_named_config(config_file) +if not conf: + raise ValueError( + 'Production: configuration %s does not exist.' % ( + config_file, )) + +for key in ('scheduler', 'private'): + if not conf.get(key): + raise ValueError( + "Production: invalid configuration; missing %s config entry." % ( + key, )) + +private_conf = conf['private'] +SECRET_KEY = private_conf['secret_key'] # https://docs.djangoproject.com/en/1.10/ref/settings/#logging LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s", # noqa 'datefmt': "%d/%b/%Y %H:%M:%S" }, }, 'handlers': { 'console': { 'level': 'INFO', 'class': 'logging.StreamHandler', 'formatter': 'standard' }, }, 'loggers': { 'django': { 'handlers': ['console'], 'level': 'INFO', 'propagate': True, }, }, } # database db_conf = private_conf.get('db', {'name': 'unset'}) db = { 'ENGINE': 'django.db.backends.postgresql', 'NAME': db_conf['name'], } db_user = db_conf.get('user') if db_user: db['USER'] = db_user db_pass = db_conf.get('password') if db_pass: db['PASSWORD'] = db_pass db_host = db_conf.get('host') if db_host: db['HOST'] = db_host db_port = db_conf.get('port') if db_port: db['PORT'] = db_port # https://docs.djangoproject.com/en/1.10/ref/settings/#databases DATABASES = { 'default': db, } # Upload user directory # https://docs.djangoproject.com/en/1.11/ref/settings/#std:setting-MEDIA_ROOT MEDIA_ROOT = private_conf.get('media_root') diff --git a/swh/deposit/wsgi.py b/swh/deposit/wsgi.py index a9dbb418..d39bdfca 100644 --- a/swh/deposit/wsgi.py +++ b/swh/deposit/wsgi.py @@ -1,24 +1,17 @@ -# Copyright (C) 2017 The Software Heritage developers +# Copyright (C) 2017-2019 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information """ WSGI config for swh.deposit project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ """ -import os -import sys - from django.core.wsgi import get_wsgi_application -sys.path.append('/etc/softwareheritage') -os.environ.setdefault("DJANGO_SETTINGS_MODULE", - "swh.deposit.settings.production") - application = get_wsgi_application() diff --git a/version.txt b/version.txt index d989cbe6..606ff0c4 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v0.0.66-0-gbe7aeb9 \ No newline at end of file +v0.0.67-0-g822ab1d \ No newline at end of file