Re: [PATCH 1 of 4] Download progress display

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch hooks up a TextMeter progress display object to the repositories
so that the user gets feedback when downloading repository metadata and
individual packages. It also tells the user how many packages have been
downloaded from the repo & how many are needed in total. 

Output looks like

  development               100% |=========================|  951 B    00:00     
  primary.xml.gz            100% |=========================| 232 kB    00:07     
  ...snipped other 12000 lines...
  [development: 12052 of 12957 ] Skipping existing Fedora/werken-xpath-javadoc-0.9.4-0.beta.12jpp.2.i386.rpm
  [development: 12053 of 12957 ] Downloading Fedora/wesnoth-1.2.4-1.fc7.x86_64.rpm
  wesnoth-1.2.4-1.fc7.x86_6  37% |=========                |  25 MB    04:13 ETA 

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
diff -r 11dd5bccfc29 reposync.py
--- a/reposync.py	Wed May 30 12:33:54 2007 -0400
+++ b/reposync.py	Wed May 30 13:34:48 2007 -0400
@@ -47,6 +47,7 @@ from yum.packageSack import ListPackageS
 from yum.packageSack import ListPackageSack
 import rpmUtils.arch
 import logging
+from urlgrabber.progress import TextMeter
 
 # for yum 2.4.X compat
 def sortPkgObj(pkg1 ,pkg2):
@@ -145,6 +146,11 @@ def main():
         for repo in myrepos:
             repo.enable()
 
+    # Use progress bar display when downloading repo metadata
+    # and package files
+    if not opts.quiet:
+        my.repos.setProgressBar(TextMeter(fo=sys.stdout))
+
     my.doRpmDBSetup()
     my.doRepoSetup()
     my.doSackSetup(rpmUtils.arch.getArchList(opts.arch))
@@ -163,7 +169,9 @@ def main():
             download_list = list(reposack)
         
         download_list.sort(sortPkgObj)
+        n = 0
         for pkg in download_list:
+            n = n + 1
             repo = my.repos.getRepo(pkg.repoid)
             remote = pkg.returnSimple('relativepath')
             local = local_repo_path + '/' + remote
@@ -175,7 +183,7 @@ def main():
                 str(os.path.getsize(local)) == pkg.returnSimple('packagesize')):
                 
                 if not opts.quiet:
-                    my.logger.error("%s already exists and appears to be complete" % local)
+                    my.logger.error("[%s: %-5d of %-5d ] Skipping existing %s" % (repo.id, n, len(download_list), remote))
                 continue
     
             if opts.urls:
@@ -195,7 +203,7 @@ def main():
             # Disable cache otherwise things won't download            
             repo.cache = 0
             if not opts.quiet:
-                my.logger.info( 'Downloading %s' % os.path.basename(remote))
+                my.logger.info( '[%s: %-5d of %-5d ] Downloading %s' % (repo.id, n, len(download_list), remote))
             pkg.localpath = local # Hack: to set the localpath we want.
             path = repo.getPackage(pkg)
             if opts.gpgcheck:
_______________________________________________
Yum mailing list
Yum@xxxxxxxxxxxxxxxxxxxx
https://lists.dulug.duke.edu/mailman/listinfo/yum

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux