EOX GitLab Instance
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESA
PRISM
VS
Commits
f09aba2b
Commit
f09aba2b
authored
4 years ago
by
Fabian Schindler
Browse files
Options
Downloads
Patches
Plain Diff
Adding possibility to configure error handlers
parent
d4416c9d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!49
Production release 1.1.1
,
!48
Registrar fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/registrar/registrar.py
+24
-15
24 additions, 15 deletions
core/registrar/registrar.py
with
24 additions
and
15 deletions
core/registrar/registrar.py
+
24
−
15
View file @
f09aba2b
import
re
import
logging
import
importlib
from
.source
import
get_source
from
.scheme
import
get_scheme
from
.backend
import
get_backends
from
.exceptions
import
RegistrationError
from
.utils
import
import_by_path
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -22,22 +22,27 @@ def register_file(config: dict, path: str, replace: bool=False):
for
pre_handler
in
get_pre_handlers
(
config
):
pre_handler
(
config
,
path
,
context
)
for
backend
in
get_backends
(
config
,
path
):
if
backend
.
exists
(
source
,
context
):
if
replace
:
logger
.
info
(
f
"
Replacing
'
{
path
}
'
.
"
)
backend
.
register
(
source
,
context
,
replace
=
True
)
try
:
for
backend
in
get_backends
(
config
,
path
):
if
backend
.
exists
(
source
,
context
):
if
replace
:
logger
.
info
(
f
"
Replacing
'
{
path
}
'
.
"
)
backend
.
register
(
source
,
context
,
replace
=
True
)
else
:
raise
RegistrationError
(
f
'
Object
{
context
}
is already registered
'
)
else
:
raise
RegistrationError
(
f
'
Object
{
context
}
is already registered
'
)
else
:
logger
.
info
(
f
"
Registering
'
{
path
}
'
.
"
)
backend
.
register
(
source
,
context
,
replace
=
False
)
logger
.
info
(
f
"
Registering
'
{
path
}
'
.
"
)
backend
.
register
(
source
,
context
,
replace
=
False
)
except
Exception
as
e
:
for
error_handler
in
get_error_handlers
(
config
):
error_handler
(
config
,
path
,
context
,
e
)
raise
else
:
for
post_handler
in
get_post_handlers
(
config
):
post_handler
(
config
,
path
,
context
)
for
post_handler
in
get_post_handlers
(
config
):
post_handler
(
config
,
path
,
context
)
logger
.
info
(
f
"
Successfully
{
'
replaced
'
if
replace
else
'
registered
'
}
'
{
path
}
'"
)
return
context
logger
.
info
(
f
"
Successfully
{
'
replaced
'
if
replace
else
'
registered
'
}
'
{
path
}
'"
)
return
context
def
_get_handlers
(
config
,
name
):
...
...
@@ -61,3 +66,7 @@ def get_pre_handlers(config):
def
get_post_handlers
(
config
):
return
_get_handlers
(
config
,
'
post_handlers
'
)
def
get_error_handlers
(
config
):
return
_get_handlers
(
config
,
'
error_handlers
'
)
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