Skip to content
Snippets Groups Projects
Commit bbdfd780 authored by Nicolas Dandrimont's avatar Nicolas Dandrimont
Browse files

cli: Don't crash when subcommands fail importing

This is an issue when swh.model is installed but not dulwich: swh.model.cli
imports dulwich unconditionally, so /usr/bin/swh fails for all subcommands
instead of just ignoring the issue.
parent 9f3e2337
No related branches found
No related tags found
1 merge request!95cli: Don't crash when subcommands fail importing
......@@ -50,8 +50,12 @@ def main():
logging.basicConfig()
# load plugins that define cli sub commands
for entry_point in pkg_resources.iter_entry_points('swh.cli.subcommands'):
cmd = entry_point.load()
swh.add_command(cmd, name=entry_point.name)
try:
cmd = entry_point.load()
swh.add_command(cmd, name=entry_point.name)
except Exception as e:
logger.warning('Could not load subcommand %s: %s',
entry_point.name, str(e))
return swh(auto_envvar_prefix='SWH')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment