summaryrefslogtreecommitdiffstats
path: root/yum-presto/shared/prestoTransaction.py
diff options
context:
space:
mode:
authorJonathan Dieter <jdieter@gmail.com>2007-04-04 17:35:37 +0300
committerJonathan Dieter <jdieter@gmail.com>2007-04-04 17:35:37 +0300
commit1942f8d44c679fc612c97202727ce362c3acb130 (patch)
tree4af5637766d4e44e1b4bc451861a9281f839e123 /yum-presto/shared/prestoTransaction.py
parentbdfb4037667c6af7d0537f9bc36b33d55d86e059 (diff)
downloadpresto-1942f8d44c679fc612c97202727ce362c3acb130.tar.gz
presto-1942f8d44c679fc612c97202727ce362c3acb130.tar.xz
presto-1942f8d44c679fc612c97202727ce362c3acb130.zip
Add improved logging. Many bug fixes.
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
Diffstat (limited to 'yum-presto/shared/prestoTransaction.py')
-rw-r--r--yum-presto/shared/prestoTransaction.py51
1 files changed, 49 insertions, 2 deletions
diff --git a/yum-presto/shared/prestoTransaction.py b/yum-presto/shared/prestoTransaction.py
index 166fe6d..4f08391 100644
--- a/yum-presto/shared/prestoTransaction.py
+++ b/yum-presto/shared/prestoTransaction.py
@@ -1,5 +1,7 @@
# author: Jonathan Dieter <jdieter@gmail.com>
#
+# format_number taken almost completely from progress_meter.py in yum
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@@ -14,10 +16,52 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Copyright 2005 Duke University
+# Copyright 2007 Jonathan Dieter
import os
import deltarpm
+def format_number(number, SI=False, space=''):
+ """Turn numbers into human-readable metric-like numbers"""
+ symbols = ['', # (none)
+ 'K', # kilo
+ 'M', # mega
+ 'G', # giga
+ 'T', # tera
+ 'P', # peta
+ 'E', # exa
+ 'Z', # zetta
+ 'Y'] # yotta
+
+ if SI: step = 1000.0
+ else: step = 1024.0
+
+ thresh = 999
+ depth = 0
+
+ # we want numbers between
+ while number > thresh:
+ depth = depth + 1
+ number = number / step
+
+ # just in case someone needs more than 1000 yottabytes!
+ diff = depth - len(symbols) + 1
+ if diff > 0:
+ depth = depth - diff
+ number = number * thresh**depth
+
+ if type(number) == type(1) or type(number) == type(1L):
+ format = '%i%s%s'
+ elif number < 9.95:
+ # must use 9.95 for proper sizing. For example, 9.99 will be
+ # rounded to 10.0 with the .1f format string (which is too long)
+ format = '%.1f%s%s'
+ else:
+ format = '%.0f%s%s'
+
+ return(format % (number, space, symbols[depth]))
+
+
def find_available_drpms(conduit, newpkg):
"""Find any applicable drpms for newpkg
newpkg is a TransactionMember"""
@@ -89,9 +133,12 @@ def find_available_drpms(conduit, newpkg):
# don't even try to download it.
try:
drpm.verifySequence(sequence)
- chosen_drpm = p_repo.deltalist[key]
- chosen_drpm['baseurl'] = p_repo.baseurl[0]
except:
conduit.info(5, "Verification of %s failed" % seq)
+ else:
+ chosen_drpm = p_repo.deltalist[key]
+ chosen_drpm['baseurl'] = p_repo.baseurl[0]
+ newpkg.po.oldpkg_string = "%s.%s %s:%s-%s" % (oldpkg.name, oldpkg.arch, oldpkg.epoch, oldpkg.version, oldpkg.release)
+ newpkg.po.newpkg_string = "%s.%s %s:%s-%s" % (newpkg.name, newpkg.arch, newpkg.epoch, newpkg.version, newpkg.release)
return (chosen_drpm, installed, is_local, drpm_enabled)