[med-svn] r1511 - trunk/community/infrastructure/scripts

tille at alioth.debian.org tille at alioth.debian.org
Tue Mar 4 22:30:59 UTC 2008


Author: tille
Date: 2008-03-04 22:30:58 +0000 (Tue, 04 Mar 2008)
New Revision: 1511

Modified:
   trunk/community/infrastructure/scripts/cddtasktools.py
Log:
Caching of packages files, escaping '&' in short description


Modified: trunk/community/infrastructure/scripts/cddtasktools.py
===================================================================
--- trunk/community/infrastructure/scripts/cddtasktools.py	2008-03-04 22:28:32 UTC (rev 1510)
+++ trunk/community/infrastructure/scripts/cddtasktools.py	2008-03-04 22:30:58 UTC (rev 1511)
@@ -32,6 +32,7 @@
            }
 HTMLBASE = "/var/lib/gforge/chroot/home/groups"
 KEYSTOIGNORE = ( 'Architecture', 'Avoid', 'Ignore', 'Leaf', 'NeedConfig', 'Note', 'Section' )
+GLOBALCACHE  = "/var/cache/cdd/"
 
 def InitTasksFiles(cddname):
     # Obtain tasks files from SVN of a CDD
@@ -53,7 +54,7 @@
     # Split first line of Description value as short description
     
     lines = description.splitlines()
-    ShortDesc = lines[0]
+    ShortDesc = lines[0].replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
     LongDesc  = ''
     pre       = 0
     for line in lines[1:]:
@@ -447,8 +448,21 @@
                 # has non zero elements
                 return
 
+	cachedir = GLOBALCACHE
+	#if ! -d cachedir :
+	if not os.access(cachedir, os.W_OK):
+    	    try:
+    		os.mkdir(cachedir)
+    	    except:
+    		# If we have no access to global cache create a local one
+    		cachedir = "cache"
+		if not os.access(cachedir, os.W_OK):
+    		    os.mkdir(cachedir)
         for component in self.components:
-            f = urllib.urlopen(BASEURL+'/dists/'+self.dist+'/'+component+'/'+self.binary+'/'+self.source)
+            # f = urllib.urlopen(BASEURL+'/dists/'+self.dist+'/'+component+'/'+self.binary+'/'+self.source)
+            cachefile = cachedir+'/'+self.dist+'_'+component+'_'+self.binary+'_'+self.source
+            (file,info) = urllib.urlretrieve(BASEURL+'/dists/'+self.dist+'/'+component+'/'+self.binary+'/'+self.source, cachefile)
+            f = open(file)
             compresseddata = f.read()
             compressedstream = StringIO.StringIO(compresseddata)
             g = gzip.GzipFile(fileobj=compressedstream)




More information about the debian-med-commit mailing list