Skip to content
Snippets Groups Projects
Commit cafabc0f authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Module/function to call a FSL command. Platform object has FSL version

parent 252cd24c
No related branches found
No related tags found
No related merge requests found
:orphan:
fsl.utils.callfsl module
========================
.. automodule:: fsl.utils.callfsl
:members:
:undoc-members:
:show-inheritance:
......@@ -6,6 +6,7 @@ fsl.utils package
fsl.utils.async
fsl.utils.cache
fsl.utils.callfsl
fsl.utils.colourbarbitmap
fsl.utils.dialog
fsl.utils.imagepanel
......
#!/usr/bin/env python
#
# callfsl.py - The callFSL function.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
"""This module provides the :func:`callFSL` function, which can be
used to call a FSL command, and retrieve the result.
"""
import logging
import subprocess as sp
import os.path as op
from fsl.utils.platform import platform as fslplatform
log = logging.getLogger(__name__)
def callFSL(*args):
"""Call a FSL command and return the result.
You can pass the command and arguments as a single string, or as a
list/tuple.
"""
if fslplatform.fsldir is None:
raise RuntimeError('FSL cannot be found!')
# If we've been given a single argument,
# assume it is a string containing the
# command and its arguments. Otherwise,
# assume it is a sequence containing
# separate command and arguments.
if len(args) == 1:
args = args.split()
args = list(args)
args[0] = op.join(fslplatform.fsldir, 'bin', args[0])
log.debug('callfsl: {}'.format(' '.join(args)))
result = sp.check_output(args)
log.debug('result: {}'.format(result))
return result
......@@ -145,11 +145,12 @@ class Platform(notifier.Notifier):
self.WX_GTK = WX_GTK
self.isWidgetAlive = isWidgetAlive
self.fsldir = os.environ.get('FSLDIR', None)
self.__inSSHSession = False
self.__glVersion = None
self.__glRenderer = None
self.__glIsSoftware = None
self.__fslVersion = None
self.fsldir = os.environ.get('FSLDIR', None)
# Determine if a display is available. We do
# this once at init (instead of on-demand in
......@@ -293,9 +294,24 @@ class Platform(notifier.Notifier):
if value is not None:
os.environ['FSLDIR'] = value
# Set the FSL version field if we can
versionFile = op.join(value, 'etc', 'fslversion')
if op.exists(versionFile):
with open(versionFile, 'rt') as f:
self.__fslVersion = f.read().strip()
self.notify()
@property
def fslVersion(self):
"""Returns the FSL version as a string, e.g. ``'5.0.9'``. Returns
``None`` if a FSL installation could not be found.
"""
return self.__fslVersion
@property
def glVersion(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment