[csw-devel] SF.net SVN: gar:[19711] csw/mgar/gar/v2/lib/python/system_pkgmap.py

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Mon Nov 19 08:48:43 CET 2012


Revision: 19711
          http://gar.svn.sourceforge.net/gar/?rev=19711&view=rev
Author:   wahwah
Date:     2012-11-19 07:48:43 +0000 (Mon, 19 Nov 2012)
Log Message:
-----------
pkgdb: More progress bar during system pkg import

After creating the fake package objects, it's necessary do create CswFile
objects related to these packages so that the buildfarm database is able to
map from files to packages. It can take a couple minutes, so let's display
a progress bar for it as well.

Before the CswFile registration, display a msg, so people have a better idea
what's the progress bar for.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/system_pkgmap.py

Modified: csw/mgar/gar/v2/lib/python/system_pkgmap.py
===================================================================
--- csw/mgar/gar/v2/lib/python/system_pkgmap.py	2012-11-19 07:48:12 UTC (rev 19710)
+++ csw/mgar/gar/v2/lib/python/system_pkgmap.py	2012-11-19 07:48:43 UTC (rev 19711)
@@ -506,6 +506,13 @@
       self.fake_srv4_cache[key] = sqo_srv4
     return self.fake_srv4_cache[key]
 
+  def _GetPbar(self, show_progress):
+    if show_progress:
+      pbar = progressbar.ProgressBar()
+    else:
+      pbar = mute_progressbar.MuteProgressBar()
+    return pbar
+
   def _ImportFiles(self, data, include_prefixes=None, show_progress=False):
     logging.debug("_ImportFiles()")
     osrel = data["osrel"]
@@ -521,10 +528,7 @@
       progressbar_divisor = 1
     update_period = 1L
     count = itertools.count()
-    if show_progress:
-      pbar = progressbar.ProgressBar()
-    else:
-      pbar = mute_progressbar.MuteProgressBar()
+    pbar = self._GetPbar(show_progress)
     pbar.maxval = len(contents) / progressbar_divisor
     pbar.start()
     cleaned_pkgs = set()
@@ -574,12 +578,19 @@
             srv4_file=sqo_srv4)
         srv4_files_to_catalog.add(sqo_srv4)
     pbar.finish()
-    logging.debug(
-        "Registering all the fake srv4 files in all catalogs.")
+    logging.info(
+        "Registering the fake svr4 files (of system packages) "
+        "in all catalogs.")
+    count = itertools.count()
+    pbar = self._GetPbar(show_progress)
+    pbar.maxval = len(srv4_files_to_catalog)
+    pbar.start()
     for sqo_srv4 in srv4_files_to_catalog:
       for sqo_catrel in m.CatalogRelease.select():
         catalog.AddSrv4ToCatalog(
             sqo_srv4, osrel, arch, sqo_catrel.name)
+      pbar.update(count.next())
+    pbar.finish()
 
   def ComposeFakeSrv4Md5(self, pkgname, osrel, arch):
     """Returns a fake md5 sum of a fake srv4 package.

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list