[csw-devel] SF.net SVN: gar:[8599] csw/mgar/gar/v2-checkpkg-stats
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Tue Feb 16 20:51:21 CET 2010
Revision: 8599
http://gar.svn.sourceforge.net/gar/?rev=8599&view=rev
Author: wahwah
Date: 2010-02-16 19:51:20 +0000 (Tue, 16 Feb 2010)
Log Message:
-----------
mGAR v2-checkpkg-stats: prettified output, added cache database update progress estimation information
Modified Paths:
--------------
csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg
csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg_collect_stats.py
csw/mgar/gar/v2-checkpkg-stats/lib/python/checkpkg.py
Modified: csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg
===================================================================
--- csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg 2010-02-16 18:48:54 UTC (rev 8598)
+++ csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg 2010-02-16 19:51:20 UTC (rev 8599)
@@ -558,14 +558,15 @@
fi
done
+if [[ "${DEBUG}" != "" ]]; then
+ extra_options="--debug"
+fi
+
# /var/sadm/install/contents cache update
${command_basedir}/update_contents_cache.py
# Collects package stats to be later analyzed
-${command_basedir}/checkpkg_collect_stats.py "$@"
+${command_basedir}/checkpkg_collect_stats.py ${extra_options} "$@"
-if [[ "${DEBUG}" != "" ]]; then
- extra_options="--debug"
-fi
debugmsg "checkpkg_module_dir: '$checkpkg_module_dir'"
log_files=""
module_name_format="%-40s"
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 18:48:54 UTC (rev 8598)
+++ csw/mgar/gar/v2-checkpkg-stats/bin/checkpkg_collect_stats.py 2010-02-16 19:51:20 UTC (rev 8599)
@@ -22,14 +22,18 @@
def main():
- debug = True
- logging.basicConfig(level=logging.DEBUG)
parser = optparse.OptionParser()
+ parser.add_option("-d", "--debug", dest="debug",
+ default=False, action="store_true",
+ help="Turn on debugging messages")
options, args = parser.parse_args()
- logging.basicConfig(level=logging.INFO)
+ if options.debug:
+ logging.basicConfig(level=logging.DEBUG)
+ else:
+ logging.basicConfig(level=logging.INFO)
logging.info("Collecting statistics about given package files.")
logging.debug("args: %s", args)
- packages = [opencsw.CswSrv4File(x, debug) for x in 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:
pkg_stats.CollectStats()
Modified: csw/mgar/gar/v2-checkpkg-stats/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2-checkpkg-stats/lib/python/checkpkg.py 2010-02-16 18:48:54 UTC (rev 8598)
+++ csw/mgar/gar/v2-checkpkg-stats/lib/python/checkpkg.py 2010-02-16 19:51:20 UTC (rev 8599)
@@ -34,6 +34,7 @@
("/64", ["/amd64", "/sparcv9"]),
("/opt/csw/lib/i386", ["/opt/csw/lib"]),
)
+INSTALL_CONTENTS_AVG_LINE_LENGTH = 102.09710677919261
# This shared library is present on Solaris 10 on amd64, but it's missing on
# Solaris 8 on i386. It's okay if it's missing.
@@ -206,18 +207,21 @@
fgrep -f $EXTRACTDIR/liblist >$EXTRACTDIR/shortcatalog
"""
+ contents_length = os.stat(SYSTEM_PKGMAP).st_size
+ estimated_lines = contents_length / INSTALL_CONTENTS_AVG_LINE_LENGTH
system_pkgmap_fd = open(SYSTEM_PKGMAP, "r")
stop_re = re.compile("(%s)" % "|".join(self.STOP_PKGS))
# Creating a data structure:
# soname - {<path1>: <line1>, <path2>: <line2>, ...}
logging.debug("Building sqlite3 cache db of the %s file",
SYSTEM_PKGMAP)
+ print "Processing %s" % SYSTEM_PKGMAP
c = self.conn.cursor()
count = itertools.count()
for line in system_pkgmap_fd:
i = count.next()
if not i % 1000:
- print "\r%s" % i,
+ print "\r~%3.1f%%" % (100.0 * i / estimated_lines,),
if stop_re.search(line):
continue
fields = re.split(WS_RE, line)
@@ -225,7 +229,7 @@
pkgmap_entry_dir, pkgmap_entry_base_name = os.path.split(pkgmap_entry_path)
sql = "INSERT INTO systempkgmap (basename, path, line) VALUES (?, ?, ?);"
c.execute(sql, (pkgmap_entry_base_name, pkgmap_entry_dir, line.strip()))
- print
+ print "\rAll lines of %s were processed." % SYSTEM_PKGMAP
print "Creating the main database index."
sql = "CREATE INDEX basename_idx ON systempkgmap(basename);"
c.execute(sql)
@@ -287,17 +291,18 @@
return self.GetFileMtime() <= self.GetDatabaseMtime()
def PurgeDatabase(self):
- logging.info("Purging the cache database")
+ 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()
sql = "DELETE FROM config;"
c.execute(sql)
sql = "DELETE FROM systempkgmap;"
c.execute(sql)
- sql = "DROP INDEX basename_idx;"
- try:
- c.execute(sql)
- except sqlite3.OperationalError, e:
- logging.warn(e)
def SharedObjectDependencies(pkgname,
binaries_by_pkgname,
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