Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bliss
bliss
Commits
3cf1a486
Commit
3cf1a486
authored
Jun 23, 2021
by
Perceval Guillou
Browse files
fix linting
parent
9d540d63
Changes
7
Hide whitespace changes
Inline
Side-by-side
bliss/config/plugins/bliss_controller.py
View file @
3cf1a486
...
...
@@ -5,7 +5,6 @@
# Copyright (c) 2015-2020 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
from
unittest.mock
import
Base
from
bliss.config.plugins.utils
import
find_top_class_and_node
from
bliss.controllers.bliss_controller
import
BlissController
...
...
bliss/config/plugins/utils.py
View file @
3cf1a486
...
...
@@ -5,7 +5,6 @@
# Copyright (c) 2015-2020 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
from
os
import
error
import
re
from
importlib.util
import
find_spec
from
importlib
import
import_module
...
...
bliss/controllers/bliss_controller.py
View file @
3cf1a486
...
...
@@ -62,7 +62,7 @@ def find_sub_names_config(config, selection=None, level=0, parent_key=None):
def
from_config_dict
(
ctrl_class
,
cfg_dict
):
""" Helper to instanciate a BlissController object from a configuration dictionary """
if
not
BlissController
in
ctrl_class
.
mro
():
if
BlissController
not
in
ctrl_class
.
mro
():
raise
TypeError
(
f
"
{
ctrl_class
}
is not a BlissController class"
)
bctrl
=
ctrl_class
(
cfg_dict
)
bctrl
.
_controller_init
()
...
...
@@ -241,7 +241,7 @@ class BlissController(CounterContainer):
msg
+=
f
" class:
{
item_class
}
\n
"
msg
+=
f
" parent_key: '
{
pkey
}
'
\n
"
msg
+=
f
" config:
{
cfg
}
\n
"
msg
+=
f
"Check item config is supported by this controller"
msg
+=
"Check item config is supported by this controller"
raise
RuntimeError
(
msg
)
self
.
_subitems
[
name
]
=
item
...
...
@@ -267,7 +267,7 @@ class BlissController(CounterContainer):
msg
=
f
"
\n
Unable to obtain default_class_name from
{
self
.
name
}
with:
\n
"
msg
+=
f
" parent_key: '
{
pkey
}
'
\n
"
msg
+=
f
" config:
{
cfg
}
\n
"
msg
+=
f
"Check item config is supported by this controller
\n
"
msg
+=
"Check item config is supported by this controller
\n
"
raise
RuntimeError
(
msg
)
if
"."
in
class_name
:
# from absolute path
...
...
@@ -288,7 +288,7 @@ class BlissController(CounterContainer):
msg
+=
f
" class_name:
{
class_name
}
\n
"
msg
+=
f
" parent_key: '
{
pkey
}
'
\n
"
msg
+=
f
" config:
{
cfg
}
\n
"
msg
+=
f
"Check item config is supported by this controller
\n
"
msg
+=
"Check item config is supported by this controller
\n
"
raise
RuntimeError
(
msg
)
module
=
import_module
(
module_name
)
if
hasattr
(
module
,
class_name
):
...
...
bliss/controllers/bliss_controller_mockup.py
View file @
3cf1a486
...
...
@@ -7,23 +7,19 @@
from
time
import
perf_counter
,
sleep
from
itertools
import
chain
from
collections
import
ChainMap
from
gevent
import
event
,
sleep
as
gsleep
from
bliss
import
global_map
from
bliss.common.counter
import
(
SamplingCounter
)
# make it available at ctrl level for plugin and tests
from
bliss.common.counter
import
SamplingCounter
from
bliss.common.protocols
import
counter_namespace
,
IterableNamespace
from
bliss.common.utils
import
autocomplete_property
from
bliss.comm.util
import
get_comm
from
bliss.controllers.counter
import
CounterController
,
SamplingCounterController
from
bliss.scanning.acquisition.counter
import
BaseCounterAcquisitionSlave
from
bliss.common.logtools
import
log_info
,
log_debug
,
log_debug_data
,
log_warning
from
bliss.common.logtools
import
log_info
from
bliss.controllers.bliss_controller
import
BlissController
,
from_config_dict
from
bliss.controllers.motors.mockup
import
Mockup
,
calc_motor_mockup
from
bliss.controllers.bliss_controller
import
BlissController
class
HardwareController
:
...
...
@@ -128,7 +124,6 @@ class BCMockup(BlissController):
tag
=
cfg
[
"tag"
]
mode
=
cfg
.
get
(
"mode"
)
unit
=
cfg
.
get
(
"unit"
)
convfunc
=
cfg
.
get
(
"convfunc"
)
if
self
.
_COUNTER_TAGS
[
tag
][
1
]
==
"scc"
:
cnt
=
self
.
_counter_controllers
[
"scc"
].
create_counter
(
...
...
@@ -210,6 +205,10 @@ class BCMockup(BlissController):
return
self
.
_calc_mot
class
CustomSamplingCounter
(
SamplingCounter
):
pass
class
BCSCC
(
SamplingCounterController
):
def
__init__
(
self
,
name
,
bctrl
):
super
().
__init__
(
name
)
...
...
bliss/controllers/motor.py
View file @
3cf1a486
...
...
@@ -5,7 +5,6 @@
# Copyright (c) 2015-2020 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
from
os
import
name
import
numpy
import
functools
from
gevent
import
lock
...
...
bliss/controllers/motors/spec.py
View file @
3cf1a486
...
...
@@ -43,7 +43,7 @@ class Spec(Controller):
super
().
_load_config
()
for
ax_cfg
in
self
.
config
.
get
(
"axes"
,
[]):
if
ax_cfg
.
get
(
"steps_per_unit"
)
!=
1
:
raise
ValueError
(
f
"steps_per_unit must be defined and equal to 1"
)
raise
ValueError
(
"steps_per_unit must be defined and equal to 1"
)
def
_get_subitem_default_class_name
(
self
,
cfg
,
parent_key
):
if
parent_key
==
"axes"
:
...
...
tests/motors/test_initialization.py
View file @
3cf1a486
...
...
@@ -157,9 +157,9 @@ def test_broken_controller_init(default_session):
# === and roby will be initialized too (because with the lazy init faulty hardware is not seen yet)
roby
=
default_session
.
config
.
get
(
"roby"
)
assert
roby
assert
roby
.
_disabled
==
False
# not yet disabled because of lasy hardware init
assert
roby
.
_disabled
is
False
# not yet disabled because of lasy hardware init
assert
(
roby
.
controller
.
_disabled
==
False
roby
.
controller
.
_disabled
is
False
)
# not yet disabled because of lasy hardware init
# print("=== assert roby True")
# print("=== name2instance:", list(config._name2instance.keys()))
...
...
@@ -174,8 +174,8 @@ def test_broken_controller_init(default_session):
with
pytest
.
raises
(
RuntimeError
,
match
=
"FAILED TO INITIALIZE"
):
roby
.
position
# will call initialize_hardware => will fail
# axis roby and controller are now disabled
assert
roby
.
_disabled
==
True
assert
roby
.
controller
.
_disabled
==
True
assert
roby
.
_disabled
is
True
assert
roby
.
controller
.
_disabled
is
True
# roby and robu are on the same controller ;
# controller is disabled because hardware init has failed
...
...
@@ -191,22 +191,22 @@ def test_broken_controller_init(default_session):
with
pytest
.
raises
(
RuntimeError
,
match
=
"Axis roby is disabled"
):
# axis is already disabled
roby
.
position
assert
roby
.
_disabled
==
True
assert
roby
.
controller
.
_disabled
==
True
assert
roby
.
_disabled
is
True
assert
roby
.
controller
.
_disabled
is
True
with
pytest
.
raises
(
RuntimeError
,
match
=
"Controller is disabled"
):
roby
.
enable
()
assert
roby
.
_disabled
==
True
assert
roby
.
controller
.
_disabled
==
True
assert
roby
.
_disabled
is
True
assert
roby
.
controller
.
_disabled
is
True
# === call _init() to re-enable the controller
roby
.
controller
.
_init
()
assert
roby
.
controller
.
_disabled
==
False
assert
roby
.
controller
.
_disabled
is
False
roby2
=
default_session
.
config
.
get
(
"roby"
)
assert
roby
is
roby2
roby
.
enable
()
assert
roby
.
_disabled
==
False
assert
roby
.
_disabled
is
False
roby
.
position
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment