from twisted.internet import defer
from allmydata.node import ConfigOnly
from allmydata.client import Client
+ from allmydata.util.namespace import Namespace
out = options.stdout
err = options.stderr
(backend, _) = Client.configure_backend(config)
+ ns = Namespace()
+ ns.total_size = 0
d2 = backend.list_container()
def _done(items):
print >>out, "Listing %d object(s):" % len(items)
print >>out, " Size Last modified Key"
for item in items:
print >>out, "% 8s %20s %s" % (item.size, format_date(item.modification_date), item.key)
+ ns.total_size += int(item.size)
+
+ print >>out
+ print >>out, "Total size: %d bytes" % (ns.total_size,)
d2.addCallback(_done)
return d2
d.addCallback(_do_create)
self.failUnlessEqual(out_lines[0], "Listing 0 object(s):", str(res))
self.failUnless(re.match(r'^\s*Size\s+Last modified\s+Key$', out_lines[1]), str(res))
self.failUnlessEqual(out_lines[2], "", str(res))
- self.failUnlessEqual(len(out_lines), 3)
+ self.failUnlessEqual(out_lines[3], "Total size: 0 bytes", str(res))
+ self.failUnlessEqual(out_lines[4], "", str(res))
+ self.failUnlessEqual(len(out_lines), 5)
self.failUnlessEqual(err, "", str(res))
self.failUnlessEqual(rc, 0, str(res))
d.addCallback(_check_no_objects)
self.failUnlessEqual(out_lines[0], "Listing 1 object(s):", str(res))
self.failUnless(re.match(r'^\s*Size\s+Last modified\s+Key$', out_lines[1]), str(res))
self.failUnless(re.match(r'^\s*10\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d*)?Z\s+shares/fo/foo/0$', out_lines[2]), str(res))
- self.failUnlessEqual(len(out_lines), 4)
+ self.failUnlessEqual(out_lines[3], "", str(res))
+ self.failUnlessEqual(out_lines[4], "Total size: 10 bytes", str(res))
+ self.failUnlessEqual(out_lines[5], "", str(res))
+ self.failUnlessEqual(len(out_lines), 6)
self.failUnlessEqual(err, "", str(res))
self.failUnlessEqual(rc, 0, str(res))
d.addCallback(_check_one_object)