Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7066186
D1481.id4866.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D1481.id4866.diff
View Options
diff --git a/requirements-swh.txt b/requirements-swh.txt
--- a/requirements-swh.txt
+++ b/requirements-swh.txt
@@ -1,4 +1,4 @@
-swh.core[db,http] >= 0.0.60
+swh.core[db,http] >= 0.0.61
swh.model >= 0.0.27
swh.objstorage >= 0.0.17
swh.scheduler >= 0.0.39
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
--- a/setup.py
+++ b/setup.py
@@ -54,7 +54,9 @@
[console_scripts]
swh-vault=swh.vault.cli:main
[swh.cli.subcommands]
- vault=swh.vault.cli:cli
+ vault=swh.vault.cli:vault
+ [swh.workers]
+ vault.worker=swh.vault:register
''',
classifiers=[
"Programming Language :: Python :: 3",
diff --git a/swh/vault/__init__.py b/swh/vault/__init__.py
--- a/swh/vault/__init__.py
+++ b/swh/vault/__init__.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2018 The Software Heritage developers
+# Copyright (C) 2018-2019 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
@@ -38,3 +38,7 @@
raise ValueError('Unknown storage class `%s`' % cls)
logger.debug('Instantiating %s with %s' % (Vault, args))
return Vault(**args)
+
+
+def register():
+ return {'tasks': '%s.cooking_tasks' % __name__}
diff --git a/swh/vault/api/server.py b/swh/vault/api/server.py
--- a/swh/vault/api/server.py
+++ b/swh/vault/api/server.py
@@ -224,7 +224,9 @@
return get_vault('local', args)
-def make_app_from_configfile(config_file=DEFAULT_CONFIG_PATH, **kwargs):
+def make_app_from_configfile(config_file=None, **kwargs):
+ if config_file is None:
+ config_file = DEFAULT_CONFIG_PATH
config_file = os.environ.get('SWH_CONFIG_FILENAME', config_file)
if os.path.isfile(config_file):
cfg = config.read(config_file, DEFAULT_CONFIG)
diff --git a/swh/vault/cli.py b/swh/vault/cli.py
--- a/swh/vault/cli.py
+++ b/swh/vault/cli.py
@@ -1,15 +1,32 @@
+import os
import logging
import click
-import aiohttp
-from swh.vault.api.server import make_app_from_configfile
+from swh.core.config import SWH_CONFIG_DIRECTORIES, SWH_CONFIG_EXTENSIONS
+from swh.core.cli import CONTEXT_SETTINGS, AliasedGroup
+from swh.vault.api.server import make_app_from_configfile, DEFAULT_CONFIG_PATH
-CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
+CFG_HELP = """Software Heritage Vault RPC server.
+If the configuration file is not set, the default config file search will
+be used; first the SWH_CONFIG_FILENAME environment variable will be
+checked, then the config file will be searched in:
-@click.command(name='vault', context_settings=CONTEXT_SETTINGS)
+%s""" % ('\n\n'.join('- %s(%s)' % (
+ os.path.join(d, DEFAULT_CONFIG_PATH), '|'.join(SWH_CONFIG_EXTENSIONS))
+ for d in SWH_CONFIG_DIRECTORIES))
+
+@click.group(name='vault', context_settings=CONTEXT_SETTINGS,
+ cls=AliasedGroup)
+@click.pass_context
+def vault(ctx):
+ '''Software Heritage Vault tools.'''
+ pass
+
+
+@vault.command(name='rpc-serve', help=CFG_HELP)
@click.option('--config-file', '-C', default=None,
type=click.Path(exists=True, dir_okay=False,),
help="Configuration file.")
@@ -21,10 +38,8 @@
@click.option('--debug/--no-debug', default=True,
help="Indicates if the server should run in debug mode")
@click.pass_context
-def cli(ctx, config_file, no_stdout, host, port, debug):
- """Software Heritage Vault API server
-
- """
+def serve(ctx, config_file, no_stdout, host, port, debug):
+ import aiohttp
from swh.scheduler.celery_backend.config import setup_log_handler
ctx.ensure_object(dict)
@@ -42,9 +57,12 @@
aiohttp.web.run_app(app, host=host, port=int(port))
+vault.add_alias(serve, 'serve')
+
+
def main():
logging.basicConfig()
- return cli(auto_envvar_prefix='SWH_VAULT')
+ return serve(auto_envvar_prefix='SWH_VAULT')
if __name__ == '__main__':
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Nov 4 2024, 10:29 PM (9 w, 1 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3229405
Attached To
D1481: cli: replace the 'vault' cmd with cli group with a 'rpc-serve' subcmd
Event Timeline
Log In to Comment