def checkenv(exitonfail=False):
 import sys
 fs_home = os.environ.get('FREESURFER_HOME')
 path = os.environ.get('PATH')
 print 'FREESURFER_HOME: {0}'.format(fs_home)
 if (fs_home == None):
  msg = 'please set FREESURFER_HOME before running the workflow'
 elif (not os.path.isdir(fs_home)):
  msg = 'FREESURFER_HOME must be set to a valid directory before running this workflow'
 elif (os.path.join(fs_home, 'bin') not in path.replace('//', '/')):
  print path
  msg = 'Could not find necessary executable in path'
  setupscript = os.path.join(fs_home, 'SetUpFreeSurfer.sh')
  if os.path.isfile(setupscript):
   print ('Please source the setup script before running the workflow:' + '\nsource {0}'.format(setupscript))
  else:
   print (('Please ensure that FREESURFER_HOME is set to a valid fs ' + 'directory and source the necessary SetUpFreeSurfer.sh script before running ') + 'this workflow')
 else:
  return fs_home
 if exitonfail:
  print ('ERROR: ' + msg)
  sys.exit(2)
 else:
  print ('Warning: ' + msg)

def checkenv ( exitonfail = False ) : import sys fs_home = os . environ . get ( 'FREESURFER_HOME' ) path = os . environ . get ( 'PATH' ) print 'FREESURFER_HOME: {0}' . format ( fs_home ) if ( fs_home == None ) : msg = 'please set FREESURFER_HOME before running the workflow' elif ( not os . path . isdir ( fs_home ) ) : msg = 'FREESURFER_HOME must be set to a valid directory before running this workflow' elif ( os . path . join ( fs_home , 'bin' ) not in path . replace ( '//' , '/' ) ) : print path msg = 'Could not find necessary executable in path' setupscript = os . path . join ( fs_home , 'SetUpFreeSurfer.sh' ) if os . path . isfile ( setupscript ) : print ( 'Please source the setup script before running the workflow:' + '\nsource {0}' . format ( setupscript ) ) else : print ( ( 'Please ensure that FREESURFER_HOME is set to a valid fs ' + 'directory and source the necessary SetUpFreeSurfer.sh script before running ' ) + 'this workflow' ) else : return fs_home if exitonfail : print ( 'ERROR: ' + msg ) sys . exit ( 2 ) else : print ( 'Warning: ' + msg )
check for the necessary fs environment variables .