Package Biskit :: Package Mod :: Module settings
[hide private]
[frames] | no frames]

Source Code for Module Biskit.Mod.settings

  1  ## 
  2  ## Biskit, a toolkit for the manipulation of macromolecular structures 
  3  ## Copyright (C) 2004-2005 Raik Gruenberg & Johan Leckner 
  4  ## 
  5  ## This program is free software; you can redistribute it and/or 
  6  ## modify it under the terms of the GNU General Public License as 
  7  ## published by the Free Software Foundation; either version 2 of the 
  8  ## License, or any later version. 
  9  ## 
 10  ## This program is distributed in the hope that it will be useful, 
 11  ## but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 13  ## General Public License for more details. 
 14  ## 
 15  ## You find a copy of the GNU General Public License in the file 
 16  ## license.txt along with this program; if not, write to the Free 
 17  ## Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
 18  ## 
 19  ## 
 20  ## last $Author: graik $ 
 21  ## last $Date: 2006/12/19 09:25:37 $ 
 22  ## $Revision: 2.4 $ 
 23   
 24  """ 
 25  Settings 
 26  ======== 
 27   
 28  This module provides Mod-global settings as fields. Throughout 
 29  Biskit.Mod a (environment-dependent) parameter such as, e.g., ssh_bin 
 30  can be addressed as: 
 31   
 32    >>> import Biskit.Mod.settings as S 
 33    >>> bin = S.ssh_bin 
 34   
 35  However, since a user should not be required to hack python modules, 
 36  ssh_bin is not actually defined in settings.py. Instead, the value is 
 37  taken from C{~/.biskit/settings_Mod.cfg} -- which should have an entry 
 38  like C{ssh_bin=/bin/ssh # comment}. If this entry (or the config file) 
 39  is not found, settings.py uses the default value from 
 40  C{biskit/external/defaults/settings_Mod.cfg}. 
 41   
 42  If missing, the user configuration file C{~/.biskit/settings_Mod.cfg} is 
 43  created automatically during the startup of Biskit.Mod (i.e. for any 
 44  import). The auto-generated file only contains parameters for which 
 45  the default values don't seem to work (invalid paths or binaries). 
 46   
 47  See L{Biskit.SettingsManager} 
 48   
 49  Summary for Biskit users 
 50  ------------------------ 
 51      If you want to change a biskit parameter, do so in 
 52      C{~/.biskit/settings_Mod.cfg} 
 53   
 54  Summary for Biskit developpers 
 55  ------------------------------ 
 56    If you want to create a new user-adjustable parameter, do so in 
 57    C{biskit/external/defaults/settings_Mod.cfg}. 
 58   
 59  Summary for all 
 60  --------------- 
 61    !Dont't touch C{settings.py}! 
 62  """ 
 63  import Biskit as B 
 64  import Biskit.tools as T 
 65  import Biskit.SettingsManager as M 
 66   
 67  import user, sys 
 68   
 69  __CFG_DEFAULT = T.projectRoot() + '/external/defaults/settings_Mod.cfg' 
 70  __CFG_USER    = user.home + '/.biskit/settings_Mod.cfg' 
 71   
 72  try: 
 73      m = M.SettingsManager(__CFG_DEFAULT, __CFG_USER, createmissing=True  ) 
 74   
 75      m.updateNamespace( locals() ) 
 76   
 77  except Exception, why: 
 78      B.EHandler.fatal( 'Error importing Biskit.Mod settings' ) 
 79   
 80   
 81   
 82  ############################## 
 83  ## Check environment variables 
 84  env = {} 
 85   
 86  net_env = {'http_proxy':'http://cache.pasteur.fr:8080'} 
 87   
 88  ##either this set or .ncbi 
 89  net_ncbi = { 'BLASTDB': '/Bis/db/blastdb', 
 90               'BLASTMAT' : '/Bis/shared/rh73/ncbi' } 
 91   
 92  env.update(net_env) 
 93  env.update(net_ncbi) 
 94   
 95   
 96  ## .ncbi example: 
 97  ## [NCBI] 
 98  ## DATA=/home/Bis/shared/rh73/ncbi/data/ 
 99   
100  ## [NET_SERV] 
101  ## SRV_CONN_MODE=FIREWALL 
102  ## SRV_HTTP_PROXY_HOST=cache.pasteur.fr 
103  ## SRV_HTTP_PROXY_PORT=8080 
104   
105   
106  ###################### 
107  ## clean up name space 
108   
109  del B, T, M, user, sys 
110  del __CFG_DEFAULT, __CFG_USER, m 
111