I stumbled over this problem as well and found some bugs in the function configure_matlab()
Here is a tiny patch that probably fixes three issues:
+ create_file boolean is actually a global function name -> rename
+ mlines should be set in all cases
+ create startup.m even when path to startup.m exists
--- /dev/null 2012-09-12 00:11:05.816554589 +0200
+++ fslinstaller.py 2012-09-12 00:12:34.252269031 +0200
@@ -1050,15 +1050,15 @@
return FslIResult(False, FslIResult.ERROR, 'Unknown shell')
return add_to_file(self.profile, fsl_env, False)
- def configure_matlab(self, m_startup='', create_file=True):
+ def configure_matlab(self, m_startup='', createfile=True):
'''Setup your startup.m file to enable FSL MATLAB functions to work'''
from os import path, getenv, mkdir
if m_startup == '':
m_startup = '/'.join((getenv('HOME'), 'matlab', 'startup.m'))
+ mlines = self.lines['startup.m']
if path.exists(m_startup):
# Check if already configured
- mlines = self.lines['startup.m']
match = file_contains_1stline(mlines[0], m_startup)
MsgUser.debug(match)
if match == '':
@@ -1072,14 +1072,14 @@
else:
MsgUser.debug('MATLAB already configured.')
result = FslIResult(True, FslIResult.WARN, "MATLAB already configured.")
- elif create_file:
+ elif createfile:
# No startup.m file found. Create one
try:
MsgUser.debug('No MATLAB startup.m file found, creating one.')
if not path.isdir( path.dirname(m_startup)):
MsgUser.debug('No MATLAB startup.m file found, creating one.')
mkdir(path.dirname(m_startup))
- result = create_file(m_startup, mlines)
+ result = create_file(m_startup, mlines)
except OSError:
MsgUser.debug('Unable to create ~/matlab folder, cannot configure.')
result = FslIResult(False, FslIResult.ERROR, "Unable to create your ~/matlab folder, so cannot configure MATLAB for FSL.")
|