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
Evan Edmond
fslpy
Commits
f7bf82cb
Commit
f7bf82cb
authored
May 27, 2018
by
Paul McCarthy
🚵
Browse files
RF,ENH: Simplified management of $FSLDIR. Added $FSLDEVDIR. runfsl function
gives $FSLDEVDIR precedence, and also allows a global override.
parent
badd80c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
fsl/utils/platform.py
View file @
f7bf82cb
...
...
@@ -88,7 +88,6 @@ def isWidgetAlive(widget):
import
wx
if
platform
.
wxFlavour
==
platform
.
WX_PHOENIX
:
excType
=
RuntimeError
elif
platform
.
wxFlavour
==
platform
.
WX_PYTHON
:
...
...
@@ -116,6 +115,7 @@ class Platform(notifier.Notifier):
os
frozen
fsldir
fsldevdir
haveGui
canHaveGui
inSSHSession
...
...
@@ -146,8 +146,9 @@ class Platform(notifier.Notifier):
self
.
__glRenderer
=
None
self
.
__glIsSoftware
=
None
self
.
__fslVersion
=
None
self
.
__fsldir
=
None
self
.
fsldir
=
os
.
environ
.
get
(
'FSLDIR'
,
None
)
# initialise fsldir - see fsldir.setter
self
.
fsldir
=
self
.
fsldir
# Determine if a display is available. We do
# this once at init (instead of on-demand in
...
...
@@ -284,7 +285,13 @@ class Platform(notifier.Notifier):
any registered listeners are notified via the
:class:`.Notifier` interface.
"""
return
self
.
__fsldir
return
os
.
environ
.
get
(
'FSLDIR'
,
None
)
@
property
def
fsldevdir
(
self
):
"""The FSL development directory location. """
return
os
.
environ
.
get
(
'FSLDEVDIR'
,
None
)
@
fsldir
.
setter
...
...
@@ -301,9 +308,9 @@ class Platform(notifier.Notifier):
elif
not
op
.
exists
(
value
):
value
=
None
elif
not
op
.
isdir
(
value
):
value
=
None
self
.
__fsldir
=
value
if
value
is
not
Non
e
:
if
value
is
None
:
os
.
environ
.
pop
(
'FSLDIR'
,
None
)
els
e
:
os
.
environ
[
'FSLDIR'
]
=
value
# Set the FSL version field if we can
...
...
@@ -316,6 +323,26 @@ class Platform(notifier.Notifier):
self
.
notify
(
value
=
value
)
@
fsldevdir
.
setter
def
fsldevdir
(
self
,
value
):
"""Changes the value of the :attr:`fsldevdir` property, and notifies
any registered listeners.
"""
if
value
is
not
None
:
value
=
value
.
strip
()
if
value
is
None
:
pass
elif
value
==
''
:
value
=
None
elif
not
op
.
exists
(
value
):
value
=
None
elif
not
op
.
isdir
(
value
):
value
=
None
if
value
is
None
:
os
.
environ
.
pop
(
'FSLDEVDIR'
,
None
)
else
:
os
.
environ
[
'FSLDEVDIR'
]
=
value
@
property
def
fslVersion
(
self
):
"""Returns the FSL version as a string, e.g. ``'5.0.9'``. Returns
...
...
fsl/utils/run.py
View file @
f7bf82cb
...
...
@@ -40,6 +40,10 @@ execute them.
"""
FSL_PREFIX
=
None
"""Global override for the FSL executable location used by :func:`runfsl`. """
class
FSLNotPresent
(
Exception
):
"""Error raised by the :func:`runfsl` function when ``$FSLDIR`` cannot
be found.
...
...
@@ -239,11 +243,19 @@ def runfsl(*args, **kwargs):
``$FSLDIR/bin/`` to the command before passing it to :func:`run`.
"""
if
fslplatform
.
fsldir
is
None
:
prefix
=
None
if
FSL_PREFIX
is
not
None
:
prefix
=
FSL_PREFIX
elif
fslplatform
.
fsldevdir
is
not
None
:
prefix
=
op
.
join
(
fslplatform
.
fsldevdir
,
'bin'
)
elif
fslplatform
.
fsldir
is
not
None
:
prefix
=
op
.
join
(
fslplatform
.
fsldir
,
'bin'
)
else
:
raise
FSLNotPresent
(
'$FSLDIR is not set - FSL cannot be found!'
)
args
=
_prepareArgs
(
args
)
args
[
0
]
=
op
.
join
(
fslplatform
.
fsldir
,
'bin'
,
args
[
0
])
args
[
0
]
=
op
.
join
(
prefix
,
args
[
0
])
return
run
(
*
args
,
**
kwargs
)
...
...
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