I'm trying to delete all the keys i've created after running some doctests. (I know i should be using the test server.. but it appears that i need to be root to run that...)
Here's the script: #!/usr/bin/python if __name__ == "__main__": import doctest print "Running tests...." #doctest.testfile("README.md") # I commented this out because my cleanup is not deleting... print "If nothing happened, success.. otherwise.. DEBUG HOUR!" # Clean up import riak print "Clean up time!" client = riak.RiakClient() bucket = client.bucket("blog") keys = bucket.get_keys() bucket = client.bucket("users") keys.extend(bucket.get_keys()) print "Keys to be cleaned: " + str(keys) for key in keys: print ("Deleting %s..." % key), not bucket.get(key).delete().exists() for key in keys: print "Verifying %s deleted: %s" % (key, not bucket.get(key).exists()) print "Deleted %d keys!" % len(keys) Here's the output: Running tests.... If nothing happened, success.. otherwise.. DEBUG HOUR! Clean up time! Keys to be cleaned: [u'534c8cda268b11e1b1b68ca982440b40', u'b8eb84e8268a11e195748ca982440b40', u'6fa5b678268a11e1bf8d8ca982440b40', u'dada10a6268a11e1a0888ca982440b40', u'549e0e2a268a11e1be1e8ca982440b40', u'4957347e268a11e196e68ca982440b40', u'c03e2df8268b11e1ae5e8ca982440b40', u'ddadfe28268a11e1ad0b8ca982440b40', u'7d54bb7a268a11e187718ca982440b40'] Deleting 534c8cda268b11e1b1b68ca982440b40... True Deleting b8eb84e8268a11e195748ca982440b40... True Deleting 6fa5b678268a11e1bf8d8ca982440b40... True Deleting dada10a6268a11e1a0888ca982440b40... True Deleting 549e0e2a268a11e1be1e8ca982440b40... True Deleting 4957347e268a11e196e68ca982440b40... True Deleting c03e2df8268b11e1ae5e8ca982440b40... True Deleting ddadfe28268a11e1ad0b8ca982440b40... True Deleting 7d54bb7a268a11e187718ca982440b40... True Verifying 534c8cda268b11e1b1b68ca982440b40 deleted: True Verifying b8eb84e8268a11e195748ca982440b40 deleted: True Verifying 6fa5b678268a11e1bf8d8ca982440b40 deleted: True Verifying dada10a6268a11e1a0888ca982440b40 deleted: True Verifying 549e0e2a268a11e1be1e8ca982440b40 deleted: True Verifying 4957347e268a11e196e68ca982440b40 deleted: True Verifying c03e2df8268b11e1ae5e8ca982440b40 deleted: True Verifying ddadfe28268a11e1ad0b8ca982440b40 deleted: True Verifying 7d54bb7a268a11e187718ca982440b40 deleted: True Deleted 9 keys! I can run this multiple times and it doesn't delete it and always show the exact same output... but if i open a separate python console and delete one of these keys via the same method (create a client, get a bucket, get the object via key, delete the object...), this will go down to 9 keys... What's wrong? I'm so confused by this thing.. Shuhao
_______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com