Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
gui
fsl-gui-bet
Commits
5f8ec497
Commit
5f8ec497
authored
Mar 24, 2021
by
Paul McCarthy
🚵
Browse files
RF: Port over to async execution.
parent
af67a347
Changes
1
Hide whitespace changes
Inline
Side-by-side
python/fsl/gui/bet/bet.py
View file @
5f8ec497
...
...
@@ -5,32 +5,31 @@
import
sys
import
fsl.utils.run
as
run
import
fsl.data.image
as
fslimage
import
fsl.wrappers
as
wrappers
import
fsl.gui.server
as
common
import
fsl.gui.server
as
fslserver
def
set_input
(
sio
,
msg
):
async
def
set_input
(
sid
,
sio
,
msg
):
"""This handler is called when a message of type ``'input'`` is received.
When the user selects an input file, a default output file name is
generated and emitted via a message of type ``'output'``.
"""
infile
=
msg
[
'filename'
]
outfile
=
fslimage
.
removeExt
(
infile
)
+
'_brain'
sio
.
emit
(
'output'
,
{
'filename'
:
outfile
})
await
sio
.
emit
(
'output'
,
{
'filename'
:
outfile
}
,
room
=
sid
)
def
run_bet
(
sio
,
msg
):
async
def
run_bet
(
sid
,
sio
,
msg
):
"""This handler is called when a message of type ``'run'`` is received.
It expects to be passed all of the parameters required to run BET via the
:func:`fsl.wrappers.bet` function.
"""
# TODO make this non blocking
cmd
=
wrappers
.
bet
(
**
msg
,
v
=
True
,
cmdonly
=
True
)
common
.
run_command
(
sio
,
cmd
)
await
fslserver
.
run_command
(
sid
,
sio
,
cmd
)
def
main
(
argv
=
None
):
...
...
@@ -40,13 +39,17 @@ def main(argv=None):
if
argv
is
None
:
argv
=
sys
.
argv
[
1
:]
port
=
int
(
argv
[
0
])
if
len
(
argv
)
==
0
:
port
=
None
else
:
port
=
int
(
argv
[
0
])
handlers
=
{
'input'
:
set_input
,
'run'
:
run_bet
,
}
common
.
start_server
(
port
,
handlers
)
fslserver
.
start_server
(
port
=
port
,
handlers
=
handlers
)
if
__name__
==
'__main__'
:
...
...
Write
Preview
Supports
Markdown
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