ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/GliteConfig.py
Revision: 1.3
Committed: Tue Jun 26 15:13:40 2007 UTC (17 years, 10 months ago) by corvo
Content type: text/x-python
Branch: MAIN
Changes since 1.2: +3 -2 lines
Log Message:
Download config file for glite in the share dir

File Contents

# User Rev Content
1 fanzago 1.1 from crab_logger import Logger
2     from crab_exceptions import *
3     from crab_util import *
4     import common
5    
6     import urllib
7 slacapra 1.2 import os, time
8 fanzago 1.1
9     class GliteConfig:
10     def __init__(self, RB):
11     common.logger.debug(5,'Calling GliteConfig')
12     self.url = 'http://cmsdoc.cern.ch/cms/ccs/wm/www/Crab/useful_script/'
13     self.configFileName = 'glite.conf.CMS_'+str(RB)
14     self.theConfig = self.getConfig_()
15 corvo 1.3 print "dentro config ", self.theConfig
16 fanzago 1.1 pass
17    
18     def config(self):
19     return self.theConfig
20    
21     def getConfig_(self):
22     if not os.path.exists(self.configFileName):
23     url = self.url+self.configFileName
24     common.logger.message('Downloading config files for RB: '+url)
25     try:
26     f = urllib.urlopen(url)
27 corvo 1.3 ff = open(common.work_space.shareDir() + '/' + self.configFileName, 'w')
28 fanzago 1.1 ff.write(f.read())
29     ff.close()
30     except IOError:
31     # print 'Cannot access URL: '+url
32     raise CrabException('Cannot download config file '+self.configFileName+' from '+self.url)
33 corvo 1.3 return common.work_space.shareDir() + '/' + self.configFileName