[csw-devel] SF.net SVN: gar:[10157] csw/mgar/gar/v2
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Wed Jun 9 17:17:33 CEST 2010
Revision: 10157
http://gar.svn.sourceforge.net/gar/?rev=10157&view=rev
Author: wahwah
Date: 2010-06-09 15:17:33 +0000 (Wed, 09 Jun 2010)
Log Message:
-----------
mGAR v2: checkpkg, progressbar! :-)
Modified Paths:
--------------
csw/mgar/gar/v2/gar.conf.mk
csw/mgar/gar/v2/lib/python/checkpkg.py
Modified: csw/mgar/gar/v2/gar.conf.mk
===================================================================
--- csw/mgar/gar/v2/gar.conf.mk 2010-06-09 14:09:34 UTC (rev 10156)
+++ csw/mgar/gar/v2/gar.conf.mk 2010-06-09 15:17:33 UTC (rev 10157)
@@ -184,6 +184,7 @@
DEF_BASE_PKGS += CSWgsed
DEF_BASE_PKGS += CSWgtar
DEF_BASE_PKGS += CSWpy-cheetah
+DEF_BASE_PKGS += CSWpy-progressbar
DEF_BASE_PKGS += CSWpy-yaml
DEF_BASE_PKGS += CSWpython
DEF_BASE_PKGS += CSWtextutils
Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py 2010-06-09 14:09:34 UTC (rev 10156)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py 2010-06-09 15:17:33 UTC (rev 10157)
@@ -14,6 +14,7 @@
import os.path
import re
import pprint
+import progressbar
import socket
import sqlite3
import subprocess
@@ -292,6 +293,10 @@
self.conn.commit()
def _ProcessSystemPkgmap(self, pkgmap_path):
+ # The progressbar library doesn't like to handle large numbers, and it
+ # displays up to 99% if we feed it a maxval in the range of hundreds of
+ # thousands.
+ progressbar_divisor = 100L
contents_length = os.stat(pkgmap_path).st_size
estimated_lines = contents_length / INSTALL_CONTENTS_AVG_LINE_LENGTH
system_pkgmap_fd = open(pkgmap_path, "r")
@@ -304,10 +309,13 @@
c = self.conn.cursor()
count = itertools.count()
sql = "INSERT INTO systempkgmap (basename, path, line) VALUES (?, ?, ?);"
+ bar = progressbar.ProgressBar()
+ bar.maxval = estimated_lines / progressbar_divisor
+ bar.start()
for line in system_pkgmap_fd:
i = count.next()
- if not i % 1000:
- print "\r~%3.1f%%" % (100.0 * i / estimated_lines,),
+ if not i % 100:
+ bar.update(i / progressbar_divisor)
if stop_re.search(line):
continue
if line.startswith("#"):
@@ -316,7 +324,9 @@
pkgmap_entry_path = fields[0].split("=")[0]
pkgmap_entry_dir, pkgmap_entry_base_name = os.path.split(pkgmap_entry_path)
c.execute(sql, (pkgmap_entry_base_name, pkgmap_entry_dir, line.strip()))
- print "\rAll lines of %s were processed." % SYSTEM_PKGMAP
+ # We rock at 101%!
+ bar.finish()
+ print "All lines of %s were processed." % SYSTEM_PKGMAP
def _CreateDbIndex(self):
print "Creating the main database index."
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