[Collab-maint-devel] SVN: r112 - in lib/trunk: . bin etc lib/collabmaint templates

hertzog at debian.org hertzog at debian.org
Thu Apr 13 22:41:32 UTC 2006


Author: hertzog
Date: 2006-04-13 22:41:31 +0000 (Thu, 13 Apr 2006)
New Revision: 112

Modified:
   lib/trunk/README
   lib/trunk/bin/update-db.py
   lib/trunk/etc/collab-maint.conf
   lib/trunk/lib/collabmaint/conf.py
   lib/trunk/lib/collabmaint/db.py
   lib/trunk/lib/collabmaint/web.py
   lib/trunk/templates/list-packages.kid
Log:
A bit of progress, the web interface displays the list of packages with
basic meta-information.


Modified: lib/trunk/README
===================================================================
--- lib/trunk/README	2006-04-13 22:39:56 UTC (rev 111)
+++ lib/trunk/README	2006-04-13 22:41:31 UTC (rev 112)
@@ -1,4 +1,4 @@
-
+  
 Packages required :
 -------------------
 pythonX.X-subversion

Modified: lib/trunk/bin/update-db.py
===================================================================
--- lib/trunk/bin/update-db.py	2006-04-13 22:39:56 UTC (rev 111)
+++ lib/trunk/bin/update-db.py	2006-04-13 22:41:31 UTC (rev 112)
@@ -9,32 +9,49 @@
 import collabmaint.db
 from sqlobject import *
 
-objects = collabmaint.repos.builder.getAllRepositories(Cnf)
 
+# Handle verbose mode
+def log_message(msg, level=1):
+    global Cnf
+    if int(Cnf["Options::Verbose"]) >= level:
+	print msg
+
+# Start of the code
+repositories = collabmaint.repos.builder.getAllRepositories(Cnf)
+
 # TODO:
-# this script should insert everything in the DB and for some reasons,
-# doesn't manage to handle the versions ...
+# Synchronize list of repositories
 
-for obj in objects:
-    mylist = obj.getPackageList()
-    for pkg_name in mylist:
-	meta = obj.getMetaInformation(pkg_name)
+# Synchronize list of distributions / suite
+
+# Synchronize info from repository into database
+for repo in repositories: # Loop on all repositories
+    mylist = repo.getPackageList()
+    for pkg_name in mylist: # Loop on all packages of this repo
+	# Retrieve information about the package from the repository
+	# and synchronize it to the database
+	meta = repo.getMetaInformation(pkg_name)
+	log_message ("Found %s/%s in %s" % (pkg_name, meta["version"], repo.id))
 	try:
 	    package = collabmaint.db.Package.byName(pkg_name)
 	except SQLObjectNotFound:
 	    package = collabmaint.db.Package(name=pkg_name)
 	try:
-	    suite = collabmaint.db.Suite.byDistribution(meta["distribution"])
+	    suite = collabmaint.db.Suite.byName(meta["distribution"])
 	except SQLObjectNotFound:
-	    suite = collabmaint.db.Suite(distribution=meta["distribution"])
-	versions = list(collabmaint.db.Version.select( AND(
-		    collabmaint.db.Version.q.packageID == package.q.id,
-		    collabmaint.db.Version.q.source == obj.id)))
-	if len(versions) == 0:
+	    suite = collabmaint.db.Suite(name=meta["distribution"])
+	found_version = False
+	version = None
+	for v in package.versions:
+	    if (v.version == meta["version"] and 
+		v.source == repo.id):
+		found_version = True
+		version = v
+	if not found_version:
 	    version = collabmaint.db.Version(package=package, version=meta["version"],
-		    suite=suite, source=obj.id)
+		    suite=suite, source=repo.id)
+	    log_message("New version created.", 2)
 	else:
-	    version = versions[0]
-	if version not in package.versions:
-	    print package
-	    print version
+	    log_message("Good version already exists.", 2)
+	# Update the information on the version
+	version.suite = suite

Modified: lib/trunk/etc/collab-maint.conf
===================================================================
--- lib/trunk/etc/collab-maint.conf	2006-04-13 22:39:56 UTC (rev 111)
+++ lib/trunk/etc/collab-maint.conf	2006-04-13 22:41:31 UTC (rev 112)
@@ -36,3 +36,7 @@
     type "svn-remote";
     URI "svn://svn.debian.org/collab-maint/ext-maint";
 };
+
+Options {
+    Verbose 0;
+}

Modified: lib/trunk/lib/collabmaint/conf.py
===================================================================
--- lib/trunk/lib/collabmaint/conf.py	2006-04-13 22:39:56 UTC (rev 111)
+++ lib/trunk/lib/collabmaint/conf.py	2006-04-13 22:41:31 UTC (rev 112)
@@ -8,17 +8,18 @@
     def __init__(self):
 	self.Cnf = apt_pkg.newConfiguration()
 	       
-	self.Cnf.Set("config-file","./etc/collab-maint.conf");
+	self.Cnf.Set("Options::Config-file","./etc/collab-maint.conf");
 	if posixpath.exists("./etc/collab-maint.conf"):
 	    apt_pkg.ReadConfigFile(self.Cnf,"./etc/collab-maint.conf")
 	else:
-	    self.Cnf.Set("config-file","/etc/collab-maint.conf");
-	    if posixpath.exists(self.Cnf.FindFile("config-file")):
+	    self.Cnf.Set("Options::Config-file","/etc/collab-maint.conf");
+	    if posixpath.exists(self.Cnf.FindFile("Options::Config-file")):
 		apt_pkg.ReadConfigFile(self.Cnf,"/etc/collab-maint.conf")
 
 	# Merge the command line arguments into the configuration space
-	Arguments = [('h',"help","help"),
-		     ('c',"config-file","","ConfigFile"),
+	Arguments = [('h',"help","Options::Help"),
+		     ('c',"config-file","Options::Config-file","ConfigFile"),
+		     ('v',"verbose","Options::Verbose","IntLevel"),
 		     ('o',"option","","ArbItem")]
 	self.Filenames = apt_pkg.ParseCommandLine(self.Cnf,Arguments,sys.argv);
 

Modified: lib/trunk/lib/collabmaint/db.py
===================================================================
--- lib/trunk/lib/collabmaint/db.py	2006-04-13 22:39:56 UTC (rev 111)
+++ lib/trunk/lib/collabmaint/db.py	2006-04-13 22:41:31 UTC (rev 112)
@@ -1,21 +1,49 @@
 
 from collabmaint.conf import Cnf
 from sqlobject import *
+import apt_pkg
+import datetime
 
 __connection__ = Cnf["DB"]
 
 class Package(SQLObject):
     name = StringCol(alternateID=True)
     versions = MultipleJoin('Version')
+    
+    def getVersionsFromSource(self, source):
+	"""pkg->getVersionsFromSource(src) -> [Version]
 
+	Returns all the known versions of the package in the indicated
+	source."""
+	res = []
+	for v in self.versions:
+	    if v.source == source:
+		res.append(v)
+	return res
+
+    def getLatestVersionFromSource(self, source):
+	"""pkg->getLatestVersionFromSource(source) -> Version
+	
+	Returns the latest version object known in the indicated source."""
+	cur_v = None
+	for v in self.getVersionsFromSource(source):
+	    if cur_v == None:
+		cur_v = v
+	    else:
+		if apt_pkg.VersionCompare(v.version, cur_v.version) > 0:
+		    cur_v = v
+	return cur_v
+
 class Suite(SQLObject):
-    distribution = StringCol(alternateID=True)
+    name = StringCol(alternateID=True)
 
 class Version(SQLObject):
     package = ForeignKey('Package')
     version = StringCol()
     source = StringCol()
     suite = ForeignKey('Suite')
+    timestamp = DateTimeCol(default=datetime.datetime.now())
+    active = BoolCol(default=True)
 
 class Contributor(SQLObject):
     name = StringCol()

Modified: lib/trunk/lib/collabmaint/web.py
===================================================================
--- lib/trunk/lib/collabmaint/web.py	2006-04-13 22:39:56 UTC (rev 111)
+++ lib/trunk/lib/collabmaint/web.py	2006-04-13 22:41:31 UTC (rev 112)
@@ -3,6 +3,9 @@
 import kid
 import collabmaint.conf
 
+from sqlobject import *
+from collabmaint import db
+
 class WebInterface:
     def __init__(self):
 	return
@@ -14,10 +17,30 @@
 	return template.serialize(output='xhtml')
     index.exposed = True
 
-    def default(self, repository):
+    def default(self, *args):
+	if len(args) == 1:
+	    return self.showRepository(args[0])
+	elif len(args) == 2:
+	    return "Package view: todo"
+    default.exposed = True
+
+    def showRepository(self, repository):
 	template = kid.Template(file="templates/list-packages.kid")
 	template.repository = repository
-	template.list = [ "a", "b" ]
+	versions = db.Version.select(
+	    AND(db.Version.q.source == repository,
+		db.Version.q.packageID == db.Package.q.id,
+		db.Version.q.active == True),
+	    orderBy=db.Package.q.name)
+	packages = []
+	for v in versions:
+	    package = db.Package.get(v.packageID)
+	    suite = db.Suite.get(v.suiteID)
+	    desc = { "name": package.name,
+		  "version": v.version,
+		    "suite": suite.name }
+	    packages.append(desc)
+	group = { "title": "Main group",
+		  "packages": packages }
+	template.groups = [ group ]
 	return template.serialize(output='xhtml')
-    default.exposed = True
-    

Modified: lib/trunk/templates/list-packages.kid
===================================================================
--- lib/trunk/templates/list-packages.kid	2006-04-13 22:39:56 UTC (rev 111)
+++ lib/trunk/templates/list-packages.kid	2006-04-13 22:41:31 UTC (rev 112)
@@ -12,9 +12,19 @@
 
   <div py:match="item.tag == 'content'">
     <h1>${repository}</h1>
+
+    <div py:for="group in groups">
+    <h2>${group["title"]}</h2>
     <table>
-	<!-- list all the packages -->
+      <!-- list all the packages -->
+      <tr><th>Package</th><th>Version</th><th>Distribution</th></tr>
+      <tr py:for="p in group['packages']">
+        <td><a href="http://packages.qa.debian.org/${p['name']}">${p["name"]}</a></td>
+        <td>${p["version"]}</td>
+        <td>${p["suite"]}</td>
+      </tr>
     </table>
+    </div>
   </div>
 
 </html>




More information about the Collab-maint-devel mailing list