Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-model
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Dandrimont
swh-model
Commits
c62f13fd
Commit
c62f13fd
authored
3 years ago
by
vlorentz
Browse files
Options
Downloads
Patches
Plain Diff
swh-identify: Hide tracebacks if Click or Dulwich is not installed
And show nice human-readable errors instead
parent
eeedac7a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/model/cli.py
+16
-2
16 additions, 2 deletions
swh/model/cli.py
with
16 additions
and
2 deletions
swh/model/cli.py
+
16
−
2
View file @
c62f13fd
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment