[csw-devel] SF.net SVN: gar:[10577] csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Fri Jul 23 14:39:23 CEST 2010
Revision: 10577
http://gar.svn.sourceforge.net/gar/?rev=10577&view=rev
Author: wahwah
Date: 2010-07-23 12:39:23 +0000 (Fri, 23 Jul 2010)
Log Message:
-----------
mGAR v2: checkpkg_inspect_stats.py, allowing to pass md5 sums and displaying a progress bar.
Modified Paths:
--------------
csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py
Modified: csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py 2010-07-23 10:31:00 UTC (rev 10576)
+++ csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py 2010-07-23 12:39:23 UTC (rev 10577)
@@ -2,11 +2,14 @@
# coding=utf-8
import code
+import itertools
import logging
import optparse
import os
import pprint
import sys
+import re
+import progressbar
# The following bit of code sets the correct path to Python libraries
# distributed with GAR.
@@ -17,7 +20,8 @@
import opencsw
def main():
- parser = optparse.OptionParser()
+ usage = "Usage: %prog [ options ] file | md5 [ file | md5 [ ... ] ]"
+ parser = optparse.OptionParser(usage)
parser.add_option("-d", "--debug", dest="debug",
default=False, action="store_true",
help="Turn on debugging messages")
@@ -29,14 +33,40 @@
else:
logging.basicConfig(level=logging.INFO)
logging.debug("Collecting statistics about given package files.")
- filenames = args
+ 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]
- pkgstats = [checkpkg.PackageStats(x) for x in srv4_pkgs]
- pkgstats = [x.GetAllStats() for x in pkgstats]
+ 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(checkpkg.PackageStats(x, 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()
+ pkgstats = []
+ for pkgstat in pkgstat_objs:
+ pkgstats.append(pkgstat.GetAllStats())
+ bar.update(counter.next())
+ bar.finish()
if options.print_stats:
print "import datetime"
- print "pkgstats = ",
- pprint.pprint(pkgstats)
+ print "pkgstat_objs = ",
+ pprint.pprint(pkgstat_objs)
else:
code.interact(local=locals())
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