Page MenuHomeSoftware Heritage

D1236.diff
No OneTemporary

D1236.diff

diff --git a/docs/sys-info.rst b/docs/sys-info.rst
--- a/docs/sys-info.rst
+++ b/docs/sys-info.rst
@@ -41,8 +41,9 @@
.. code:: shell
- SWH_CONFIG_FILENAME=/etc/softwareheritage/deposit/server.yml \
- swh-deposit --platform production \
+ swh-deposit \
+ --config-file /etc/softwareheritage/deposit/server.yml \
+ --platform production \
user create \
--collection <collection-name> \
--username <client-name> \
@@ -53,8 +54,9 @@
access to the deposit api.
Note:
- - If the collection does not exist, it is created alongside.
+ - If the collection does not exist, it is created alongside
- The password is plain text but stored encrypted (so yes, for now
we know the user's password)
- - A production requirement for the cli to work is to set the
- SWH_CONFIG_FILENAME environment variable
+ - For production platform, you must either set an
+ SWH_CONFIG_FILENAME environment variable or pass alongside the
+ `--config-file` parameter
diff --git a/swh/deposit/cli.py b/swh/deposit/cli.py
--- a/swh/deposit/cli.py
+++ b/swh/deposit/cli.py
@@ -12,12 +12,15 @@
@click.group(context_settings=CONTEXT_SETTINGS)
+@click.option('--config-file', '-C', default=None,
+ type=click.Path(exists=True, dir_okay=False,),
+ help="Optional extra configuration file.")
@click.option('--platform', default='development',
type=click.Choice(['development', 'production']),
help='development or production platform')
@click.pass_context
-def cli(ctx, platform):
- setup_django_for(platform)
+def cli(ctx, config_file, platform):
+ setup_django_for(platform, config_file=config_file)
@cli.group('user')
diff --git a/swh/deposit/config.py b/swh/deposit/config.py
--- a/swh/deposit/config.py
+++ b/swh/deposit/config.py
@@ -46,7 +46,7 @@
}
-def setup_django_for(platform):
+def setup_django_for(platform, config_file=None):
"""Setup function for command line tools (swh.deposit.create_user) to
initialize the needed db access.
@@ -57,6 +57,8 @@
Args:
platform (str): the platform the scheduling is running
+ config_file (str): Extra configuration file (typically for the
+ production platform)
Raises:
ValueError in case of wrong platform inputs.
@@ -68,6 +70,9 @@
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'swh.deposit.settings.%s' % platform)
+ if config_file:
+ os.environ.setdefault('SWH_CONFIG_FILENAME', config_file)
+
import django
django.setup()

File Metadata

Mime Type
text/plain
Expires
Sun, Aug 17, 7:35 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3217620

Event Timeline