[csw-devel] SF.net SVN: gar:[10749] csw/mgar/gar/v2

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Mon Aug 16 09:43:45 CEST 2010


Revision: 10749
          http://gar.svn.sourceforge.net/gar/?rev=10749&view=rev
Author:   wahwah
Date:     2010-08-16 07:43:44 +0000 (Mon, 16 Aug 2010)

Log Message:
-----------
mGAR v2: bug fixes for checkpkg_inspect_stats and pkgdb.

Modified Paths:
--------------
    csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py
    csw/mgar/gar/v2/lib/python/checkpkg.py
    csw/mgar/gar/v2/lib/python/pkgdb.py

Modified: csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py	2010-08-15 14:56:14 UTC (rev 10748)
+++ csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py	2010-08-16 07:43:44 UTC (rev 10749)
@@ -33,28 +33,10 @@
   else:
     logging.basicConfig(level=logging.INFO)
   logging.debug("Collecting statistics about given package files.")
-  filenames = []
-  md5s = []
-  md5_re = re.compile(r"^[0123456789abcdef]{32}$")
-  for arg in args:
-    if md5_re.match(arg):
-      md5s.append(arg)
-    else:
-      filenames.append(arg)
-  srv4_pkgs = [opencsw.CswSrv4File(x) for x in filenames]
-  pkgstat_objs = []
+  pkgstat_objs = checkpkg.GetPackageStatsByFilenamesOrMd5s(
+      args,
+      options.debug)
   bar = progressbar.ProgressBar()
-  bar.maxval = len(md5s) + len(srv4_pkgs)
-  bar.start()
-  counter = itertools.count()
-  for pkg in srv4_pkgs:
-    pkgstat_objs.append(checkpkg.PackageStats(pkg, debug=options.debug))
-    bar.update(counter.next())
-  for md5 in md5s:
-    pkgstat_objs.append(checkpkg.PackageStats(None, md5sum=md5, debug=options.debug))
-    bar.update(counter.next())
-  bar.finish()
-  bar = progressbar.ProgressBar()
   bar.maxval = len(pkgstat_objs)
   bar.start()
   counter = itertools.count()

Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py	2010-08-15 14:56:14 UTC (rev 10748)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py	2010-08-16 07:43:44 UTC (rev 10749)
@@ -67,6 +67,7 @@
 ]
 
 CONTENT_PKG_RE = r"^\*?(CSW|SUNW)[0-9a-zA-Z\-]?[0-9a-z\-]+$"
+MD5_RE = r"^[0123456789abcdef]{32}$"
 
 REPORT_TMPL = u"""#if $missing_deps or $surplus_deps or $orphan_sonames
 Dependency issues of $pkgname:
@@ -1527,3 +1528,31 @@
   idxes = xrange(0, len(l), size)
   sliced = [l[i:i+size] for i in idxes]
   return sliced
+
+def IsMd5(s):
+  # For optimization, move the compilation elsewhere.
+  md5_re = re.compile(MD5_RE)
+  return md5_re.match(s)
+
+def GetPackageStatsByFilenamesOrMd5s(args, debug=False):
+  filenames = []
+  md5s = []
+  for arg in args:
+    if IsMd5(arg):
+      md5s.append(arg)
+    else:
+      filenames.append(arg)
+  srv4_pkgs = [opencsw.CswSrv4File(x) for x in filenames]
+  pkgstat_objs = []
+  bar = progressbar.ProgressBar()
+  bar.maxval = len(md5s) + len(srv4_pkgs)
+  bar.start()
+  counter = itertools.count()
+  for pkg in srv4_pkgs:
+    pkgstat_objs.append(PackageStats(pkg, debug=debug))
+    bar.update(counter.next())
+  for md5 in md5s:
+    pkgstat_objs.append(PackageStats(None, md5sum=md5, debug=debug))
+    bar.update(counter.next())
+  bar.finish()
+  return pkgstat_objs

Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py	2010-08-15 14:56:14 UTC (rev 10748)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py	2010-08-16 07:43:44 UTC (rev 10749)
@@ -8,6 +8,9 @@
 import sqlobject
 import logging
 import code
+import os
+import os.path
+import socket
 import sys
 from Cheetah.Template import Template
 
@@ -28,7 +31,7 @@
 """
 
 def GetPkg(some_id):
-  logging.debug("Selecting from db: %s", some_id)
+  logging.debug("Selecting from db: %s", repr(some_id))
   res = m.Srv4FileStats.select(
       sqlobject.OR(
         m.Srv4FileStats.q.md5_sum==some_id,
@@ -60,7 +63,11 @@
     args = args[1:]
 
   # db_path = checkpkg.DatabaseClient.GetDatabasePath()
-  db_path = '/home/maciej/.checkpkg/checkpkg-db-current9s'
+  # db_path = '/home/maciej/.checkpkg/checkpkg-db-current9s'
+  db_path = os.path.join(
+      os.environ["HOME"],
+      ".checkpkg",
+      "checkpkg-db-%s" % socket.getfqdn())
   sqo_conn = sqlobject.connectionForURI('sqlite:%s' % db_path)
   sqlobject.sqlhub.processConnection = sqo_conn
 


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