00001 """
00002 Defaults for GlobalVars class
00003
00004 """
00005
00006 __copyright__ = """
00007 Copyright 2008 Sean Ross-Ross
00008 """
00009 __license__ = """
00010 This file is part of SLIMpy .
00011
00012 SLIMpy is free software: you can redistribute it and/or modify
00013 it under the terms of the GNU Lesser General Public License as published by
00014 the Free Software Foundation, either version 3 of the License, or
00015 (at your option) any later version.
00016
00017 SLIMpy is distributed in the hope that it will be useful,
00018 but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020 GNU Lesser General Public License for more details.
00021
00022 You should have received a copy of the GNU Lesser General Public License
00023 along with SLIMpy . If not, see <http://www.gnu.org/licenses/>.
00024 """
00025
00026 import os
00027 from os.path import curdir, join, sep, isfile, devnull, abspath
00028 NULLOUT = open( devnull, 'w' )
00029
00030
00031 DEFAULTS = {
00032 "verbose": 0,
00033 "debug" : ['cmd','err','stat'] ,
00034 "check_path" : False,
00035 "strict_check" : 2,
00036 "memsize":500 ,
00037
00038
00039 "runtype":'normal' ,
00040 "globaltmpdir": abspath( curdir ),
00041 "localtmpdir": join( sep, 'var', 'tmp' ),
00042 'datapath': abspath( os.environ.get( 'DATAPATH', abspath( curdir ) ) ),
00043
00044 "mpi": False,
00045 "MPIFLAGS": "${MPIRUN} -np ${np} -hostfile ${NODEFILE}",
00046 "NODEFILE" : None,
00047 "NODELIST" : [],
00048 "nodemap_type":'lin' ,
00049
00050 "MPIRUN" : "mpirun_ssh",
00051 "np" : 1 ,
00052 "rsh": 'ssh',
00053 "eps":0,
00054 "nwin": 0,
00055 "abridge":True,
00056 "test_devel":False,
00057 'abridgeMap' : {abspath( curdir ):'.'},
00058 'walltime':30,
00059 'no_del':False,
00060 'logfile':None,
00061
00062 'keep_tb_info': True,
00063 'show_std_err': False,
00064 'use_scalar_obj': True,
00065
00066 'sync_disk_om_rm': True,
00067 'SYNC_CMD': 'sync',
00068
00069 'run_again':False,
00070
00071
00072 }
00073
00074
00075
00076 tmpPath = join( sep, 'var', 'tmp' )
00077 PBS_JOBID = os.environ.get( 'PBS_JOBID', '' )
00078
00079 PBS_JOBID = join( tmpPath, PBS_JOBID )
00080
00081 if os.access( PBS_JOBID, os.W_OK | os.R_OK ):
00082 DEFAULTS['tmpdatapath'] = abspath( PBS_JOBID )
00083 else:
00084 DEFAULTS['tmpdatapath'] = abspath( curdir )
00085
00086 SYS_DEFAULTS = DEFAULTS.copy()
00087
00088 def rc_update_defaults():
00089 """
00090 try and get the defaults from the SLIMpy rcfile
00091 """
00092
00093 SLIMPY_RC = os.environ.get( 'SLIMPY_RC', None )
00094 HOME = os.environ.get( 'HOME', None )
00095
00096 if SLIMPY_RC is None:
00097 if isfile( '.slimpy_rc' ):
00098 SLIMPY_RC = '.slimpy_rc'
00099 elif isfile( join( HOME, '.slimpy_rc' ) ):
00100 SLIMPY_RC = join( HOME, '.slimpy_rc' )
00101
00102 if SLIMPY_RC is not None:
00103 rc_globals = {}
00104 execfile( SLIMPY_RC, rc_globals )
00105
00106 try:
00107 DEFAULTS.update( rc_globals['DEFAULTS'] )
00108 except KeyError:
00109 raise KeyError( "slimpy rcfile must contain 'DEFAULTS' attribute" )
00110
00111
00112 rc_update_defaults()
00113