Skip to content
Snippets Groups Projects
Commit c62f13fd authored by vlorentz's avatar vlorentz
Browse files

swh-identify: Hide tracebacks if Click or Dulwich is not installed

And show nice human-readable errors instead
parent eeedac7a
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,15 @@ from typing import Dict, List, Optional
# WARNING: do not import unnecessary things here to keep cli startup time under
# control
import click
try:
import click
except ImportError:
print(
"Cannot run swh-identify; the Click package is not installed."
"Please install 'swh.model[cli]' for full functionality.",
file=sys.stderr,
)
exit(1)
try:
from swh.core.cli import swh as swh_cli_group
......@@ -101,7 +109,13 @@ def swhid_of_origin(url):
def swhid_of_git_repo(path) -> CoreSWHID:
import dulwich.repo
try:
import dulwich.repo
except ImportError:
raise click.ClickException(
"Cannot compute snapshot identifier; the Dulwich package is not installed. "
"Please install 'swh.model[cli]' for full functionality.",
)
from swh.model import hashutil
from swh.model.identifiers import snapshot_identifier
......
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