~ubuntu-branches/ubuntu/saucy/python-glanceclient/saucy

« back to all changes in this revision

Viewing changes to glanceclient/common/utils.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 10:22:06 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20121123102206-0dlq52aydhudnrrc
Tags: 1:0.6.0-0ubuntu1
[ Adam Gandelman ]
* Ensure python-prettytable >= 0.6. (LP: #1073275)
* debian/control, pydist-overrides: Add python-openssl override.

[ Chuck Short ]
* New usptream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
        raise IOError(errno.EPIPE,
169
169
                      'Corrupt image download. Checksum was %s expected %s' %
170
170
                      (md5sum, checksum))
 
171
 
 
172
 
 
173
def make_size_human_readable(size):
 
174
    suffix = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB']
 
175
    base = 1024.0
 
176
 
 
177
    index = 0
 
178
    while size >= base:
 
179
        index = index + 1
 
180
        size = size / base
 
181
 
 
182
    padded = '%.1f' % size
 
183
    stripped = padded.rstrip('0').rstrip('.')
 
184
 
 
185
    return '%s%s' % (stripped, suffix[index])