Package Biskit :: Package PVM :: Module pvmTools
[hide private]
[frames] | no frames]

Source Code for Module Biskit.PVM.pvmTools

  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  ## 
 21  ## last $Date: 2006/11/16 15:42:30 $ 
 22  ## last $Author: graik $ 
 23  """ 
 24  low-level tools for PVM 
 25  """ 
 26   
 27  import pvm 
 28  import pypvm_core 
 29  import os 
 30  import Biskit.hosts as H 
 31   
 32   
33 -def expandLocal( host ):
34 """ 35 Expand name of local(!) host. 36 For example, turn 'myhost' into 'myhost.mydomain.com' 37 38 @param host: host name 39 @type host: str 40 41 @return: full host name 42 @rtype: str 43 """ 44 if os.uname()[1].split('.')[0] == host: 45 return os.uname()[1] 46 47 return host
48 49
50 -def addHosts( number=len(H.nodes_all), hosts=H.nodes_all, expand=1 ):
51 """ 52 Add hosts to PVM. 53 54 @param number: number of requested nodes 55 if number == 0, nothing happens 56 @type number: int 57 @param hosts: list of host names 58 @type hosts: [str] 59 @param expand: add full address to local node 60 @type expand: [1|0] 61 """ 62 if expand: 63 hosts = [ expandLocal( h ) for h in hosts ] 64 65 if number == None: 66 pvm.addHosts( hosts ) 67 68 if number > 0: 69 pvm.addHosts( hosts[:number+1] )
70 71
72 -def countHosts():
73 """ 74 @return: number of hosts registered with PVM 75 @rtype: int 76 """ 77 return PVM.pypvm_core.config()[0]
78 79 ## Error codes returned by pvmlib 80 pvmerrors = { 81 0 : 'PvmOk Success', 82 -2 : 'PvmBadParam Bad parameter', 83 -3 : 'PvmMismatch Parameter mismatch', 84 -4 : 'PvmOverflow Value too large', 85 -5 : 'PvmNoData End of buffer', 86 -6 : 'PvmNoHost No such host', 87 -7 : 'PvmNoFile No such file', 88 -8 : 'PvmDenied Permission denied', 89 -10: 'PvmNoMem Malloc failed', 90 -12: "PvmBadMsg Can't decode message", 91 -14: "PvmSysErr Can't contact local daemon", 92 -15: 'PvmNoBuf No current buffer', 93 -16: 'PvmNoSuchBuf No such buffer', 94 -17: 'PvmNullGroup Null group name', 95 -18: 'PvmDupGroup Already in group', 96 -19: 'PvmNoGroup No such group', 97 -20: 'PvmNotInGroup Not in group', 98 -21: 'PvmNoInst No such instance', 99 -22: 'PvmHostFail Host failed', 100 -23: 'PvmNoParent No parent task', 101 -24: 'PvmNotImpl Not implemented', 102 -25: 'PvmDSysErr Pvmd system error', 103 -26: 'PvmBadVersion Version mismatch', 104 -27: 'PvmOutOfRes Out of resources', 105 -28: 'PvmDupHost Duplicate host', 106 -29: "PvmCantStart Can't start pvmd", 107 -30: 'PvmAlready Already in progress', 108 -31: 'PvmNoTask No such task', 109 -32: 'PvmNotFound Not Found', 110 -33: 'PvmExists Already exists', 111 -34: 'PvmHostrNMstr Hoster run on non-master host', 112 -35: 'PvmParentNotSet Spawning parent set PvmNoSpawnParent', 113 -36: "PvmIPLoopback Master Host's IP is Loopback" 114 } 115