Changeset View
Changeset View
Standalone View
Standalone View
swh/journal/cli.py
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
@cli.command() | @cli.command() | ||||
@click.pass_context | @click.pass_context | ||||
def publisher(ctx): | def publisher(ctx): | ||||
"""Manipulate publisher | """Manipulate publisher | ||||
""" | """ | ||||
mandatory_keys = [ | |||||
'brokers', 'temporary_prefix', 'final_prefix', 'consumer_id', | |||||
'publisher_id', 'object_types', 'storage' | |||||
] | |||||
conf = ctx.obj['config'] | conf = ctx.obj['config'] | ||||
missing_keys = [] | |||||
for key in mandatory_keys: | |||||
if not conf.get(key): | |||||
missing_keys.append(key) | |||||
if missing_keys: | |||||
raise click.ClickException( | |||||
'Configuration error: The following keys must be' | |||||
' provided: %s' % (','.join(missing_keys), )) | |||||
publisher = JournalPublisher(conf) | publisher = JournalPublisher(conf) | ||||
try: | try: | ||||
while True: | while True: | ||||
publisher.poll() | publisher.poll() | ||||
except KeyboardInterrupt: | except KeyboardInterrupt: | ||||
ctx.exit(0) | ctx.exit(0) | ||||
def main(): | def main(): | ||||
return cli(auto_envvar_prefix='SWH_JOURNAL') | return cli(auto_envvar_prefix='SWH_JOURNAL') | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
main() | main() |