-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_remote_list.py
More file actions
executable file
·55 lines (44 loc) · 1.48 KB
/
get_remote_list.py
File metadata and controls
executable file
·55 lines (44 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
"""
Get all files in a cloudfiles container and print
them out - works for containers with >10000 objects
"""
import cloudfiles
import ConfigParser
from sys import argv
# get our config from the config file
config = ConfigParser.ConfigParser()
config.read("./cf.ini")
USERNAME = config.get("auth", "username")
AUTH_URL = config.get("auth", "url")
API_KEY = config.get("auth", "key")
try:
CONTAINER = argv[1]
print "Using container: \'%s\'" % CONTAINER
except:
CONTAINER = "test.birkett"
print "Using default container: \'%s\'" % CONTAINER
# create the connection object
conn = cloudfiles.get_connection(USERNAME,API_KEY,authurl = AUTH_URL)
# get the container object
container = conn.get_container(CONTAINER)
# print some container details
print "total size of \'%s\' container: %d bytes" %(container, container.size_used)
print "total number of objects in \'%s\' container: %d" % (container, container.object_count)
# build the list 10000 at a time
last_marker = ''
counter = 0
mainlist = []
print "Just populating the list..."
while (counter < container.object_count):
mylist = container.get_objects(marker=last_marker)
print "Just grabbing files %d to %d" % (counter, counter + len(mylist))
counter += 10000
last_marker = mylist[-1]
# extend mainlist by adding current iteration of mylist
mainlist += mylist
# print the entire main list out
obnum = 1
for object in mainlist:
print "object number %d: %s" % (obnum, object)
obnum += 1