ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/DLSInfo.py
Revision: 1.5
Committed: Tue Mar 28 11:25:39 2006 UTC (19 years, 1 month ago) by slacapra
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_1_1_0, CRAB_1_1_0_pre4, CRAB_1_1_0_pre3, CRAB_1_1_0_pre1
Changes since 1.4: +39 -39 lines
Log Message:
fix indenting - 4 spaces, no tabcvs diff DBSInfo.py!

File Contents

# User Rev Content
1 afanfani 1.1 #!/usr/bin/env python
2     import sys, os, commands,string, re
3 afanfani 1.4 import exceptions
4     from crab_exceptions import *
5 afanfani 1.1 from crab_util import *
6     import common
7    
8     class DLSError:
9 slacapra 1.5 def __init__(self, fileblocks):
10     print '\nERROR accessing DLS for fileblock '+fileblocks+'\n'
11     pass
12 afanfani 1.1
13 afanfani 1.4
14     class DLSNoReplicas(exceptions.Exception):
15 slacapra 1.5 def __init__(self, FileBlock):
16     args ="No replicas exists for fileblock: "+FileBlock+"\n"
17     exceptions.Exception.__init__(self, args)
18     pass
19    
20     def getClassName(self):
21     """ Return class name. """
22     return "%s" % (self.__class__.__name__)
23    
24     def getErrorMessage(self):
25     """ Return exception error. """
26     return "%s" % (self.args)
27 afanfani 1.4
28 afanfani 1.1 ##############################################################################
29     # Class to extract info from DLS
30     ##############################################################################
31    
32     class DLSInfo:
33 slacapra 1.5 def __init__(self, fileblocks):
34     self.fileblocks = fileblocks
35     self.DLSclient_ = 'dls-get-se '
36     self.DLSServer_ = 'lxgate10.cern.ch'
37     self.DLSServerPort_ = '18081'
38     #self.DLSServerPort_ = '18080
39    
40     out=commands.getstatusoutput('which '+self.DLSclient_)
41     if out[0]>0:
42     msg="ERROR no DLS CLI available in $PATH : %s"%self.DLSclient_
43     raise CrabException(msg)
44 afanfani 1.1
45     # ####################################
46 slacapra 1.5 def getReplicas(self):
47     """
48     query DLS to get replicas
49     """
50     ##
51     cmd = self.DLSclient_+" --port "+self.DLSServerPort_+" --host "+self.DLSServer_+" --datablock "+self.fileblocks
52     #print cmd
53     sites = runCommand(cmd)
54     sites=string.strip(sites)
55     if len(sites)<=0:
56     raise DLSNoReplicas(self.fileblocks)
57 afanfani 1.4
58 slacapra 1.5 ListSites=string.split(string.strip(sites),'\n')
59     return ListSites