ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Downloader.py
Revision: 1.2
Committed: Mon Dec 7 17:31:01 2009 UTC (15 years, 4 months ago) by mcinquil
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_7_1_pre2, CRAB_2_7_1_pre1
Changes since 1.1: +1 -1 lines
Log Message:
better debug print

File Contents

# Content
1 from WMCore.Services.Service import Service
2 import common
3
4 class Downloader:
5
6 def __init__(self, endpoint, cachepath, cacheduration = 0.5, timeout = 20, \
7 type = "txt/csv", logger = common.logger):
8 self.wmcorecache = {}
9 self.wmcorecache['logger'] = logger
10 self.wmcorecache['cachepath'] = cachepath ## cache area
11 self.wmcorecache['cacheduration'] = 0.5 ## half an hour
12 self.wmcorecache['timeout'] = 20 ## seconds
13 self.wmcorecache['endpoint'] = endpoint
14
15 def downloadConfig(self, cacheFile, type = "txt/csv"):
16 self.wmcorecache['type'] = type
17 common.logger.debug("Downloading file [%s] to [%s]." %(str(self.wmcorecache['endpoint']),(str(self.wmcorecache['cachepath'])+"/"+cacheFile)))
18 servo = Service( self.wmcorecache )
19 return servo.refreshCache( cacheFile, cacheFile )
20
21 def config(self, fileName = "prova"):
22 f = self.downloadConfig(fileName)
23 l = ''.join( f.readlines() )
24 f.close()
25
26 value = None
27 try:
28 value = eval(l)
29 except SyntaxError, se:
30 common.logger.debug("Problem reading downloaded file %s "%str(fileName))
31
32 return value