Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bliss
bliss
Commits
ba44b02c
Commit
ba44b02c
authored
Apr 20, 2021
by
Valentin Valls
Browse files
Handle PreparedScanEvent as 'on_scan_started'
parent
65fee165
Changes
2
Hide whitespace changes
Inline
Side-by-side
bliss/data/scan.py
View file @
ba44b02c
...
...
@@ -115,6 +115,16 @@ class ScansObserver:
"""
pass
def
on_scan_started
(
self
,
scan_db_name
:
str
,
scan_info
:
Dict
):
"""
Called upon scan started (the devices was prepared).
Arguments:
scan_db_name: Identifier of the scan
scan_info: Dictionary containing scan metadata
"""
pass
def
on_child_created
(
self
,
scan_db_name
:
str
,
node
):
"""
Called upon scan child creation (e.g. channel node)
...
...
@@ -403,6 +413,16 @@ class ScansWatcher:
)
except
Exception
:
sys
.
excepthook
(
*
sys
.
exc_info
())
elif
event_type
==
EventType
.
PREPARED_SCAN
:
node_type
=
node
.
type
if
self
.
_watch_scan_group
or
node_type
==
"scan"
:
db_name
=
node
.
db_name
if
db_name
in
self
.
_running_scans
:
scan_info
=
node
.
info
.
get_all
()
try
:
observer
.
on_scan_started
(
db_name
,
scan_info
)
except
Exception
:
sys
.
excepthook
(
*
sys
.
exc_info
())
elif
event_type
==
EventType
.
END_SCAN
:
node_type
=
node
.
type
if
self
.
_watch_scan_group
or
node_type
==
"scan"
:
...
...
tests/scans/test_data_watch.py
View file @
ba44b02c
...
...
@@ -466,7 +466,9 @@ def test_scan_observer(session, diode_acq_device_factory, mocker):
gevent
.
sleep
(
0.5
)
session_watcher
.
kill
()
# TODO check the order of the received events
observer
.
on_scan_created
.
assert_called_once
()
observer
.
on_scan_started
.
assert_called_once
()
observer
.
on_scan_finished
.
assert_called_once
()
call
=
observer
.
on_scan_created
.
call_args_list
[
0
]
scan_info
=
call
[
0
][
1
]
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment