ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/GliteConfig.py
Revision: 1.10
Committed: Wed Oct 17 14:04:44 2007 UTC (17 years, 6 months ago) by fanzago
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_2_0_pre15, CRAB_2_2_0_pre13, CRAB_2_2_0_pre12, CRAB_2_2_0_pre11, CRAB_2_2_0_pre10, bp_osg_bdii, CRAB_2_2_0_pre9, CRAB_2_2_0_pre8, CRAB_2_2_0_pre7, CRAB_2_1_2, CRAB_2_2_0_pre5, CRAB_2_1_2_pre2, CRAB_2_1_2_pre1, CRAB_2_2_0_pre4, CRAB_2_2_0_pre2, CRAB_2_1_1, CRAB_2_1_1_pre3, CRAB_2_2_0_pre1, CRAB_2_1_1_pre1, CRAB_2_1_0, CRAB_2_1_0_pre6, CRAB_2_1_0_pre5, CRAB_2_1_0_pre4, CRAB_2_1_0_pre3, CRAB_2_1_0_pre2, CRAB_2_1_0_pre1, CRAB_2_0_4, CRAB_2_0_4_pre2, CRAB_2_0_4_pre1, CRAB_2_0_3, CRAB_2_0_3_pre1, CRAB_2_0_2, CRAB_2_0_2_pre6, CRAB_2_0_2_pre5, CRAB_2_0_2_pre4, CRAB_2_0_2_pre3, CRAB_2_0_2_pre2, CRAB_2_0_2_pre1, CRAB_2_0_1
Branch point for: osg_bdii, CRAB_2_1_2_br, CRAB_2_1_1_pre2
Changes since 1.9: +2 -2 lines
Log Message:
download config file if older then 12 hours

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     pass
16    
17     def config(self):
18     return self.theConfig
19    
20 mcinquil 1.8 def downloadFile(self, url, destination):
21     try:
22     f = urllib.urlopen(url)
23 mcinquil 1.9 ff = open(destination, 'w')
24 mcinquil 1.8 ff.write(f.read())
25     ff.close()
26     except IOError:
27     # print 'Cannot access URL: '+url
28 mcinquil 1.9 raise CrabException('Cannot download config file '+destination+' from '+self.url)
29 mcinquil 1.8
30 fanzago 1.1 def getConfig_(self):
31 mcinquil 1.7 if not os.path.exists(self.configFileName):
32     url = self.url+self.configFileName
33 mcinquil 1.8 common.logger.message('Downloading config files for WMS: '+url)
34     self.downloadFile( url, self.configFileName)
35     else:
36     statinfo = os.stat(self.configFileName)
37 fanzago 1.10 ## if the file is older then 12 hours it is re-downloaded to update the configuration
38     oldness = 12*3600
39 mcinquil 1.8 if (time.time() - statinfo.st_ctime) > oldness:
40     url = self.url+self.configFileName
41     common.logger.message('Downloading config files for WMS: '+url)
42     self.downloadFile( url, self.configFileName)
43     pass
44 spiga 1.5 return os.getcwd()+'/'+self.configFileName