1 |
from crab_logger import Logger
|
2 |
from crab_exceptions import *
|
3 |
from crab_util import *
|
4 |
import common
|
5 |
|
6 |
import urllib
|
7 |
import os, time
|
8 |
|
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 |
def getConfig_(self):
|
21 |
if not os.path.exists(self.configFileName):
|
22 |
url = self.url+self.configFileName
|
23 |
common.logger.message('Downloading config files for RB: '+url)
|
24 |
try:
|
25 |
f = urllib.urlopen(url)
|
26 |
ff = open(self.configFileName, 'w')
|
27 |
ff.write(f.read())
|
28 |
ff.close()
|
29 |
except IOError:
|
30 |
# print 'Cannot access URL: '+url
|
31 |
raise CrabException('Cannot download config file '+self.configFileName+' from '+self.url)
|
32 |
return os.getcwd()+'/'+self.configFileName
|