CVS: src/si/extras entitycheck.py,1.27,1.28

Mats Wichmann <[email protected]>
Newsgroups gmane.linux.lsb.implementation
Message-ID <[email protected]>
Update of /cvsroot/lsb/src/si/extras
In directory sc8-pr-cvs1:/tmp/cvs-serv19235/si/extras

Modified Files:
	entitycheck.py 
Log Message:
Pretty up retrieval printing (now estimates time remaining)


Index: entitycheck.py
===================================================================
RCS file: /cvsroot/lsb/src/si/extras/entitycheck.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** entitycheck.py	6 Feb 2003 13:39:55 -0000	1.27
--- entitycheck.py	7 Feb 2003 23:05:14 -0000	1.28
***************
*** 29,33 ****
  """
  
! import sys, re, os, getopt, string, md5, urllib
  
  # PATH DEFAULTS the only stuff that should need tuning
--- 29,33 ----
  """
  
! import sys, re, os, getopt, string, md5, urllib, time
  
  # PATH DEFAULTS the only stuff that should need tuning
***************
*** 87,91 ****
          """Callback function for urllib.urlretrieve()"""
          so_far = block_count * block_size
!         self.message = "%d of %d bytes retrieved" % (so_far, total)
          self.running_output()
          sys.stdout.flush()		# force text to be displayed
--- 87,102 ----
          """Callback function for urllib.urlretrieve()"""
          so_far = block_count * block_size
! 	if not so_far: return
! 	pct = so_far * 100 / total
! 	# Work out remaining time: need transfer rate first
! 	now = time.time()
! 	elapsed = now - self.start
! 	rate = so_far / elapsed
! 	left = (total - so_far) / rate
! 	tmp = time.gmtime(left)
! 	if tmp[3]: timestr = "%2d:" % tmp[3]
! 	else: timestr = "" 	# skip hours if zero
! 	timestr = "%s%02d:%02d remaining" % (timestr, tmp[4], tmp[5])
!         self.message = "%d of %d bytes (%d%%) %s" % (so_far, total, pct, timestr)
          self.running_output()
          sys.stdout.flush()		# force text to be displayed
***************
*** 100,104 ****
          """
          self.message = "not found"
!         self.front = "%s ->" % self.name
          for loc in locations:
              if self.name != loc.name: continue
--- 111,115 ----
          """
          self.message = "not found"
!         self.front = "%s ->" % self.file
          for loc in locations:
              if self.name != loc.name: continue
***************
*** 109,113 ****
              if dry_run:			# just print a message and bail
                  self.message = "fetch %s from (%s, ...) to %s" % (self.file,
!                                loc.path, destination)
                  self.running_output()
                  print	# line break so previous message isn't overwritten
--- 120,124 ----
              if dry_run:			# just print a message and bail
                  self.message = "fetch %s from (%s, ...) to %s" % (self.file,
! 				loc.path, destination)
                  self.running_output()
                  print	# line break so previous message isn't overwritten
***************
*** 121,124 ****
--- 132,136 ----
  
                  try:
+ 		    self.start = time.time()
                      filename, mime = urllib.urlretrieve(to_get, pkgpath,
  		                                        self.feedback)
***************
*** 330,333 ****
--- 342,346 ----
      fails, missing = [], []
      global initial_text
+     print "Retrieving..."
      for pkg in missing_packages:
          if pkg.fetch(locations, fallback_url, package_path):
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.