Exemplo n.º 1
0
 def test_sizeof_fmt(self):
     self.assertEqual('1.0 B', utils.sizeof_fmt(1))
     self.assertEqual('1.0 kB', utils.sizeof_fmt(10**3))
     self.assertEqual('1.0 MB', utils.sizeof_fmt(10**6))
     self.assertEqual('1.0 GB', utils.sizeof_fmt(10**9))
     self.assertEqual('1.0 TB', utils.sizeof_fmt(10**12))
     self.assertEqual('1000.0 TB', utils.sizeof_fmt(10**15))
Exemplo n.º 2
0
def list_backups(backend, path, backup_id=None):
    backups = backend.list(prefix="b-*")
    for backup in backups:
        backup_name = os.path.basename(backup)
        if backup_id is None:
            print backup_name
        else:
            if backup_name == backup_id:
                om = backend.get(backup_id)
                try:
                    old_meta_data = json.loads(om)
                except ValueError:
                    pass
                for name in sorted(old_meta_data):
                    meta = old_meta_data.get(name)
                    datestring = time.strftime(
                        "%d %b %Y %H:%M:%S", time.localtime(meta.get('m')))
                    size = utils.sizeof_fmt(meta.get('s'))
                    print u"%20s %10s %s" % (datestring, size, name)