I have chased that bug a bit further. Today few small updates wait for downloading, and I executed apt-get update.
Current version of update-manager 1:0.142.22 on maverick 2.6.35-27-generic
user@desktop:~$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from apt import Cache
>>> a=0
>>> for pkg in Cache():
... if pkg.is_upgradable:
... print "%s: %s" % (pkg.name, pkg.candidate.size)
... a=a+pkg.candidate.size
...
krb5-multidev: 103014
libgssapi-krb5-2: 120252
libgssrpc4: 75052
libk5crypto3: 96398
libkadm5clnt-mit7: 58928
libkadm5srv-mit7: 71640
libkdb5-4: 59080
libkrb5-3: 348606
libkrb5-dev: 36444
libkrb5support0: 42672
libtiff4: 136668
tzdata: 682952
tzdata-java: 145636
>>> a
1977342
>>>
update-manager shows these packages with their size:
krb5-multidev: 100kB
libgssapi-krb5-2: 117 kB
libgssrpc4: 73 kB
libk5crypto3: 94 kB
libkadm5clnt-mit7: 57 kB
libkadm5srv-mit7: 69 kB
libkdb5-4: 57 kB
libkrb5-3: 340 kB
libkrb5-dev: 35 kB
libkrb5support0: 41 kB
libtiff4: 133 kB
tzdata: 666 kB
tzdata-java: 142 kB
That fits to the sizes shown in python
BUT: The total size to download in update-manager shows 1.0 MB
This is definitely wrong when I compare that to the total size in Python of 1977342 B (=~1,9 MB)
If I copy the definition of humanize_size from Update-Manager and call
humanize_size(1977342) what do I see?
'1.0 MB'
So there is definitely a bug in the humanize_size function.
Instead of
return locale.format(_("%.1f MB"), bytes / 1024 / 1024)
it has to be
return locale.format(_("%.1f MB"), float(bytes) / 1024 / 1024)
(Without the float command python used integer division and cuts all remainders off!)
I am not sure if that will cure all differences in the display of file sizes, but I hope it is at least a first step into the right direction.
I found this buggy definition for humanize_size in the following files
/usr/lib/python2.6/dist-packages/UpdateManager/Core/utils.py
/usr/lib/python2.6/dist-packages/DistUpgrade/utils.py
As far as I can see all versions up to natty contain the same.
I have chased that bug a bit further. Today few small updates wait for downloading, and I executed apt-get update.
Current version of update-manager 1:0.142.22 on maverick 2.6.35-27-generic
user@desktop:~$ python candidate. size
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from apt import Cache
>>> a=0
>>> for pkg in Cache():
... if pkg.is_upgradable:
... print "%s: %s" % (pkg.name, pkg.candidate.size)
... a=a+pkg.
...
krb5-multidev: 103014
libgssapi-krb5-2: 120252
libgssrpc4: 75052
libk5crypto3: 96398
libkadm5clnt-mit7: 58928
libkadm5srv-mit7: 71640
libkdb5-4: 59080
libkrb5-3: 348606
libkrb5-dev: 36444
libkrb5support0: 42672
libtiff4: 136668
tzdata: 682952
tzdata-java: 145636
>>> a
1977342
>>>
update-manager shows these packages with their size:
krb5-multidev: 100kB
libgssapi-krb5-2: 117 kB
libgssrpc4: 73 kB
libk5crypto3: 94 kB
libkadm5clnt-mit7: 57 kB
libkadm5srv-mit7: 69 kB
libkdb5-4: 57 kB
libkrb5-3: 340 kB
libkrb5-dev: 35 kB
libkrb5support0: 41 kB
libtiff4: 133 kB
tzdata: 666 kB
tzdata-java: 142 kB
That fits to the sizes shown in python
BUT: The total size to download in update-manager shows 1.0 MB
This is definitely wrong when I compare that to the total size in Python of 1977342 B (=~1,9 MB)
If I copy the definition of humanize_size from Update-Manager and call size(1977342) what do I see?
humanize_
'1.0 MB'
So there is definitely a bug in the humanize_size function. format( _("%.1f MB"), bytes / 1024 / 1024) format( _("%.1f MB"), float(bytes) / 1024 / 1024)
Instead of
return locale.
it has to be
return locale.
(Without the float command python used integer division and cuts all remainders off!)
I am not sure if that will cure all differences in the display of file sizes, but I hope it is at least a first step into the right direction.
I found this buggy definition for humanize_size in the following files python2. 6/dist- packages/ UpdateManager/ Core/utils. py python2. 6/dist- packages/ DistUpgrade/ utils.py
/usr/lib/
/usr/lib/
As far as I can see all versions up to natty contain the same.