Skip to content

Instantly share code, notes, and snippets.

@NordomWhistleklik
Created January 2, 2013 15:21
Show Gist options
  • Select an option

  • Save NordomWhistleklik/4435316 to your computer and use it in GitHub Desktop.

Select an option

Save NordomWhistleklik/4435316 to your computer and use it in GitHub Desktop.
Python script for deleting all contents of a Cloud Files container
# Delete all contents of a Cloud Files container
import cloudfiles
username = ''
key = ''
containerName = ''
connection = cloudfiles.get_connection(username,key)
container = connection.create_container(containerName)
obj_list = []
obj_list_10000 = container.list_objects()
while obj_list_10000:
obj_list.extend(obj_list_10000)
mark = obj_list[-1]
obj_list_10000 = container.list_objects(marker=mark)
for i in obj_list:
try:
container.delete_object(i)
print "Successfully deleted",i
except:
print "Failed to delete",i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment