gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject cvs commit: jakarta-gump/python/gump __init__.py xmlutils.py document.py conf.py
Date Fri, 26 Sep 2003 20:35:21 GMT
ajack       2003/09/26 13:35:21

  Modified:    python/gump __init__.py xmlutils.py document.py conf.py
  Log:
  1) Trying to set UserAgent (to Jakarta-Gump/version) in order to tell SF.net (and others)
who is calling
  Hoping SF.net's viewcvs will response raw to this
  2) Still trying to cope w/ bad projects (knock on of failures from 1 above)
  
  Revision  Changes    Path
  1.13      +32 -15    jakarta-gump/python/gump/__init__.py
  
  Index: __init__.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/__init__.py,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- __init__.py	26 Sep 2003 19:09:52 -0000	1.12
  +++ __init__.py	26 Sep 2003 20:35:21 -0000	1.13
  @@ -95,7 +95,7 @@
   log = logging.getLogger(__name__)
   
   from gump.xmlutils import SAXDispatcher
  -from gump.conf import dir, default
  +from gump.conf import dir, default, setting
   from gump.utils import *
   
   ###############################################################################
  @@ -116,6 +116,16 @@
   if os.path.exists(timestamp):
     mtime=time.localtime(os.path.getmtime(timestamp))
     default.date = time.strftime('%Y%m%d',mtime)
  +  
  +#
  +# Set the User Agent to be Gump...
  +#
  +class GumpURLopener(urllib.FancyURLopener):
  +    def __init__(self, *args):
  +        self.version = "Jakarta-Gump/"+setting.version
  +        urllib.FancyURLopener.__init__(self, *args)
  +
  +urllib._urlopener = GumpURLopener()
   
   ###############################################################################
   # Functions
  @@ -127,41 +137,48 @@
   def gumpPath(path):
     """returns the path absolutized relative to the base gump dir"""
   
  -  return os.path.normpath(os.path.join(dir.base,path))
  +  return os.path.abspath(os.path.join(dir.base,path))
   
   def gumpCache(href):
     """returns the path of the file in the href, cached if remote"""
   
     #if it's a local file get it locally
     if not href.startswith('http://'):
  -    newHref=gumpPath(href);
  +    cachedHrefFile=gumpPath(href);
     else:
  -    log.debug('url: ' + href)
  +    log.debug('Cache url: ' + href)
       if not os.path.exists(dir.cache):  os.mkdir(dir.cache)
   
       #the name of the cached descriptor
       quotedHref = urllib.quote_plus(href)
       #the path of the cached descriptor
  -    newHref = dir.cache+'/'+quotedHref
  +    cachedHrefFile = dir.cache+'/'+quotedHref
   
       #download the file if not present in the cache
  -    if os.path.exists(newHref):
  -      log.debug('using cached descriptor')
  -    else:
  +    usecached=0
  +    if settings.optimize or settings.optimizenetwork:
  +        if os.path.exists(cachedHrefFile):
  +          log.info('using cached descriptor for ' + href)
  +          usecached=1
  +          
  +    if not usecached:
         log.debug('caching...')
         log.info('downloading '+href)      
         try:
  -        urllib.urlretrieve(href, newHref)
  +        #
  +        # urllib ought do some (timestamp oriented) caching also...
  +        #
  +        urllib.urlretrieve(href, cachedHrefFile)
         except IOError, detail:
  -        log.error(detail)
  +        log.error('Failed to download ['+href+']. Details: ' + detail)
           try:
  -          os.remove(newHref)
  +          os.remove(cachedHrefFile)
           except:
             log.debug('No faulty cached file to remove')
         else: 
            log.debug('...done')
   
  -  return newHref
  +  return cachedHrefFile
   
   from gump.context import GumpContext
   
  
  
  
  1.4       +4 -0      jakarta-gump/python/gump/xmlutils.py
  
  Index: xmlutils.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/xmlutils.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- xmlutils.py	26 Sep 2003 19:25:35 -0000	1.3
  +++ xmlutils.py	26 Sep 2003 20:35:21 -0000	1.4
  @@ -278,6 +278,10 @@
   
     if f==None: f=StringIO.StringIO()
   
  +  # :TODO: Do hack for when content is bad and a parse fails
  +  # so the XML loader has to set element=None
  +  if not object: return
  +      
     attrs=[nodeName]
     elements=[]
     text=''
  
  
  
  1.43      +3 -3      jakarta-gump/python/gump/document.py
  
  Index: document.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/document.py,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- document.py	26 Sep 2003 19:09:52 -0000	1.42
  +++ document.py	26 Sep 2003 20:35:21 -0000	1.43
  @@ -260,7 +260,8 @@
       titledDataInTableXDoc(x,'Gump Preferred Workspace Version', setting.ws_version)
       titledDataInTableXDoc(x,'Java Command', context.javaCommand)
       titledDataInTableXDoc(x,'@@DATE@@', str(default.date))
  -    titledDataInTableXDoc(x,'Start Date/Time', workspace.startdatetime)
  +    titledDataInTableXDoc(x,'Start Date/Time', context.startdatetime)
  +    titledDataInTableXDoc(x,'Timezone', context.timezone)
       
       endTableXDoc(x)
       endSectionXDoc(x)                
  @@ -364,8 +365,7 @@
       footerXDoc(x)
       endXDoc(x)
           
  -    # Document the workspace XML
  -    
  +    # Document the workspace XML    
       f=open(getWorkspaceXMLAsTextDocument(workspace), 'w')
       xml = xmlize('workspace',workspace,f)
       f.close()  
  
  
  
  1.15      +7 -5      jakarta-gump/python/gump/conf.py
  
  Index: conf.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/conf.py,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- conf.py	25 Sep 2003 17:04:52 -0000	1.14
  +++ conf.py	26 Sep 2003 20:35:21 -0000	1.15
  @@ -106,13 +106,15 @@
   class setting:    
       """Configuration of hardcoded settings"""
       
  -    version="2.0.1-alpha-0003"
  +    version="2.0.1-alpha-0004"
       
       # :TODO: Add "minimum checks later..."
       ws_version="0.4"
       
   class switch:
  -    """Configuration of switches """    
  +    """Configuration of switches """   
  +    optimize=0 # Optimize (at risk to exact correctness) anywhere one can
  +    optimizenetwork=1 # Do least network traffic 
       failtesting=0 # Not testing.. 
       debugging=0 # Not debugging..
       
  
  
  

Mime
View raw message