Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
force-bdss
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Adham Hashibon
force-bdss
Commits
0a98a47d
Commit
0a98a47d
authored
7 years ago
by
Stefano Borini
Browse files
Options
Downloads
Patches
Plain Diff
Introduced logging in case of plugin load error
parent
eb21f149
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!50
Introduced logging in case of plugin load error
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
force_bdss/bdss_application.py
+25
-9
25 additions, 9 deletions
force_bdss/bdss_application.py
force_bdss/tests/test_bdss_application.py
+34
-0
34 additions, 0 deletions
force_bdss/tests/test_bdss_application.py
requirements/dev_requirements.txt
+1
-0
1 addition, 0 deletions
requirements/dev_requirements.txt
with
60 additions
and
9 deletions
force_bdss/bdss_application.py
+
25
−
9
View file @
0a98a47d
from
stevedore
import
extension
import
functools
import
logging
from
stevedore.extension
import
ExtensionManager
from
stevedore.exception
import
NoMatches
from
stevedore.exception
import
NoMatches
from
envisage.api
import
Application
from
envisage.api
import
Application
...
@@ -34,18 +37,31 @@ class BDSSApplication(Application):
...
@@ -34,18 +37,31 @@ class BDSSApplication(Application):
else
:
else
:
plugins
.
append
(
CoreMCODriver
())
plugins
.
append
(
CoreMCODriver
())
mgr
=
extension
.
ExtensionManager
(
mgr
=
ExtensionManager
(
namespace
=
'
force.bdss.extensions
'
,
namespace
=
'
force.bdss.extensions
'
,
invoke_on_load
=
True
invoke_on_load
=
True
,
on_load_failure_callback
=
functools
.
partial
(
_load_failure_callback
)
)
)
def
import_extensions
(
ext
):
print
(
"
Found extension {}
"
.
format
(
ext
.
name
))
plugins
.
append
(
ext
.
obj
)
try
:
try
:
mgr
.
map
(
import_extensions
)
mgr
.
map
(
functools
.
partial
(
_
import_extensions
,
plugins
)
)
except
NoMatches
:
except
NoMatches
:
print
(
"
No extensions found
"
)
logging
.
info
(
"
No extensions found
"
)
super
(
BDSSApplication
,
self
).
__init__
(
plugins
=
plugins
)
super
(
BDSSApplication
,
self
).
__init__
(
plugins
=
plugins
)
def
_import_extensions
(
plugins
,
ext
):
logging
.
info
(
"
Found extension {}
"
.
format
(
ext
.
obj
))
plugins
.
append
(
ext
.
obj
)
def
_load_failure_callback
(
plugins
,
manager
,
entry_point
,
exception
):
"""
Reports failure to load a module through stevedore.
"""
logging
.
error
(
"
Unable to load plugin {}. Exception: {}. Message: {}
"
.
format
(
entry_point
,
exception
.
__class__
.
__name__
,
exception
)
)
This diff is collapsed.
Click to expand it.
force_bdss/tests/test_bdss_application.py
0 → 100644
+
34
−
0
View file @
0a98a47d
import
unittest
import
testfixtures
from
force_bdss.bdss_application
import
(
BDSSApplication
,
_load_failure_callback
,
_import_extensions
)
try
:
import
mock
except
ImportError
:
from
unittest
import
mock
class
TestBDSSApplication
(
unittest
.
TestCase
):
def
test_initialization
(
self
):
app
=
BDSSApplication
(
False
,
"
foo/bar
"
)
self
.
assertFalse
(
app
.
evaluate
)
self
.
assertEqual
(
app
.
workflow_filepath
,
"
foo/bar
"
)
def
test_extension_load_failure
(
self
):
plugins
=
[]
with
testfixtures
.
LogCapture
()
as
log
:
_load_failure_callback
(
plugins
,
mock
.
Mock
(),
"
foo
"
,
Exception
(
"
hello
"
))
log
.
check
(
(
'
root
'
,
'
ERROR
'
,
"
Unable to load plugin foo. Exception:
"
"
Exception. Message: hello
"
)
)
self
.
assertEqual
(
plugins
,
[])
This diff is collapsed.
Click to expand it.
requirements/dev_requirements.txt
+
1
−
0
View file @
0a98a47d
flake8
flake8
coverage
coverage
mock
mock
testfixtures
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