[csw-devel] SF.net SVN: gar:[8608] csw/mgar/gar/v2-checkpkg-stats
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Wed Feb 17 01:16:18 CET 2010
Revision: 8608
http://gar.svn.sourceforge.net/gar/?rev=8608&view=rev
Author: wahwah
Date: 2010-02-17 00:16:14 +0000 (Wed, 17 Feb 2010)
Log Message:
-----------
mGAR v2-checkpkg-stats: Fixed a problem with custom-pkgtrans
Modified Paths:
--------------
csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg.d/checkpkg-actionclasses.py
csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg_collect_stats.py
csw/mgar/gar/v2-checkpkg-stats/gar.conf.mk
csw/mgar/gar/v2-checkpkg-stats/lib/python/checkpkg.py
csw/mgar/gar/v2-checkpkg-stats/lib/python/opencsw.py
Modified: csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg.d/checkpkg-actionclasses.py
===================================================================
--- csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg.d/checkpkg-actionclasses.py 2010-02-16 23:10:13 UTC (rev 8607)
+++ csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg.d/checkpkg-actionclasses.py 2010-02-17 00:16:14 UTC (rev 8608)
@@ -49,6 +49,10 @@
def main():
options, args = checkpkg.GetOptions()
+ if options.debug:
+ logging.basicConfig(level=logging.DEBUG)
+ else:
+ logging.basicConfig(level=logging.INFO)
md5sums = args
# CheckpkgManager class abstracts away things such as the collection of
# results.
Modified: csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg_collect_stats.py
===================================================================
--- csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg_collect_stats.py 2010-02-16 23:10:13 UTC (rev 8607)
+++ csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg_collect_stats.py 2010-02-17 00:16:14 UTC (rev 8608)
@@ -32,7 +32,7 @@
else:
logging.basicConfig(level=logging.INFO)
logging.info("Collecting statistics about given package files.")
- logging.debug("args: %s", args)
+ logging.debug("calling: %s, please be patient", args)
packages = [opencsw.CswSrv4File(x, options.debug) for x in args]
stats_list = [checkpkg.PackageStats(pkg) for pkg in packages]
for pkg_stats in stats_list:
Modified: csw/mgar/gar/v2-checkpkg-stats/gar.conf.mk
===================================================================
--- csw/mgar/gar/v2-checkpkg-stats/gar.conf.mk 2010-02-16 23:10:13 UTC (rev 8607)
+++ csw/mgar/gar/v2-checkpkg-stats/gar.conf.mk 2010-02-17 00:16:14 UTC (rev 8608)
@@ -179,6 +179,7 @@
DEF_BASE_PKGS += CSWgsed
DEF_BASE_PKGS += CSWgtar
DEF_BASE_PKGS += CSWpy-cheetah
+DEF_BASE_PKGS += CSWpy-yaml
DEF_BASE_PKGS += CSWpython
DEF_BASE_PKGS += CSWtextutils
DEF_BASE_PKGS += CSWwget
Modified: csw/mgar/gar/v2-checkpkg-stats/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2-checkpkg-stats/lib/python/checkpkg.py 2010-02-16 23:10:13 UTC (rev 8607)
+++ csw/mgar/gar/v2-checkpkg-stats/lib/python/checkpkg.py 2010-02-17 00:16:14 UTC (rev 8608)
@@ -291,14 +291,14 @@
return self.GetFileMtime() <= self.GetDatabaseMtime()
def PurgeDatabase(self):
+ c = self.conn.cursor()
logging.info("Dropping the index.")
sql = "DROP INDEX basename_idx;"
try:
c.execute(sql)
except sqlite3.OperationalError, e:
logging.warn(e)
- logging.info("Removing all rows from the cache database")
- c = self.conn.cursor()
+ logging.info("Deleting all rows from the cache database")
sql = "DELETE FROM config;"
c.execute(sql)
sql = "DELETE FROM systempkgmap;"
@@ -692,7 +692,6 @@
basket_b["tag_info"] = tag.tag_info
basket_a["tag_name"] = self.tag_name
basket_b["tag_name"] = tag.tag_name
- # print "comparing", basket_a, basket_b
return basket_a == basket_b
def ParseOverrideLine(line):
@@ -929,6 +928,7 @@
f = open(in_file_name, "r")
obj = yaml.safe_load(f)
f.close()
+ logging.debug("ReadObject(): finished reading %s", repr(in_file_name))
return obj
def ReadSavedStats(self):
Modified: csw/mgar/gar/v2-checkpkg-stats/lib/python/opencsw.py
===================================================================
--- csw/mgar/gar/v2-checkpkg-stats/lib/python/opencsw.py 2010-02-16 23:10:13 UTC (rev 8607)
+++ csw/mgar/gar/v2-checkpkg-stats/lib/python/opencsw.py 2010-02-17 00:16:14 UTC (rev 8608)
@@ -344,14 +344,13 @@
def ShellCommand(self, args, quiet=False):
logging.debug("Calling: %s", repr(args))
if quiet:
- sub_stdout = subprocess.PIPE
- sub_stderr = subprocess.PIPE
+ process = subprocess.Popen(args,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = process.communicate()
+ retcode = process.wait()
else:
- sub_stdout = None
- sub_stderr = None
- retcode = subprocess.call(args,
- stdout=sub_stdout,
- stderr=sub_stderr)
+ retcode = subprocess.call(args)
if retcode:
raise Error("Running %s has failed." % repr(args))
return retcode
@@ -406,15 +405,28 @@
This requires custom-pkgtrans to be available.
"""
if not os.path.isdir(destdir):
- raise PackageError("%s doesn't exist or is not a directory" % destdir)
+ raise PackageError("%s doesn't exist or is not a directory" % destdir)
args = [os.path.join(os.path.dirname(__file__), "custom-pkgtrans"),
src_file, destdir, pkgname ]
pkgtrans_proc = subprocess.Popen(args)
pkgtrans_proc.communicate()
ret = pkgtrans_proc.wait()
if ret:
- logging.error("% has failed" % args)
+ logging.error("% has failed" % args)
+ def GetPkgname(self):
+ """It's necessary to figure out the pkgname from the .pkg file.
+ # nawk 'NR == 2 {print $1; exit;} $f
+ """
+ gunzipped_path = self.GetGunzippedPath()
+ args = ["nawk", "NR == 2 {print $1; exit;}", gunzipped_path]
+ nawk_proc = subprocess.Popen(args, stdout=subprocess.PIPE)
+ stdout, stderr = nawk_proc.communicate()
+ ret_code = nawk_proc.wait()
+ pkgname = stdout.strip()
+ logging.debug("GetPkgname(): %s", repr(pkgname))
+ return pkgname
+
def TransformToDir(self):
"""Transforms the file to the directory format.
@@ -423,10 +435,12 @@
achieve consistent behavior.
"""
if not self.transformed:
+ gunzipped_path = self.GetGunzippedPath()
+ pkgname = self.GetPkgname()
args = [os.path.join(os.path.dirname(__file__),
"..", "..", "bin", "custom-pkgtrans"),
- self.GetGunzippedPath(), self.GetWorkDir(), "all"]
- print "args", args
+ gunzipped_path, self.GetWorkDir(), pkgname]
+ print "transforming", args
unused_retcode = self.ShellCommand(args, quiet=(not self.debug))
dirs = self.GetDirs()
if len(dirs) != 1:
@@ -753,15 +767,15 @@
# worry about that at this stage.
logging.debug("Trying to open %s", repr(file_path))
if os.path.isfile(file_path):
- return open(file_path, "r")
+ return open(file_path, "r")
else:
- return None
+ return None
def _ParseOverridesStream(self, stream):
overrides = []
for line in stream:
if line.startswith("#"):
- continue
+ continue
overrides.append(checkpkg.ParseOverrideLine(line))
return overrides
@@ -769,9 +783,9 @@
"""Returns overrides, a list of checkpkg.Override instances."""
stream = self._GetOverridesStream()
if stream:
- return self._ParseOverridesStream(stream)
+ return self._ParseOverridesStream(stream)
else:
- return list()
+ return list()
class Pkgmap(object):
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