Created
January 2, 2013 15:21
-
-
Save NordomWhistleklik/4435316 to your computer and use it in GitHub Desktop.
Python script for deleting all contents of a Cloud Files container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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