Skip to content

Instantly share code, notes, and snippets.

@rgbkrk
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgbkrk/8807115 to your computer and use it in GitHub Desktop.
Save rgbkrk/8807115 to your computer and use it in GitHub Desktop.
CloudFiles Summary in ORD
# The Rackspace SDK for Python
import pyrax
# For printing pretty byte totals
import humanize
pyrax.set_setting("identity_type", "rackspace")
pyrax.set_credentials(USER, APIKEY) # Replace these or use a credential file
cf = pyrax.connect_to_cloudfiles(region="ORD")
containers = cf.get_all_containers()
total_bytes = sum(container.total_bytes for container in containers)
total_objects = sum(container.object_count for container in containers)
print("{} Containers".format(len(containers)))
print("Total Bytes: {}".format(humanize.naturalsize(total_bytes)))
print("Total Objects: {}".format(total_objects))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment