d2b144df |
#!/usr/bin/env python |
add6b7fc |
# vim: set fileencoding=utf-8 : |
d2b144df |
## Amazon S3 manager
## Author: Michal Ludvig <michal@logix.cz>
## http://www.logix.cz/michal
## License: GPL Version 2
import sys
import os
import logging
from optparse import OptionParser, Option, OptionValueError, IndentedHelpFormatter
from logging import debug, info, warning, error
## Our modules
from S3 import PkgInfo
from S3.SimpleDB import SimpleDB
from S3.Config import Config
from S3.Exceptions import *
|
add6b7fc |
def display_response(response): |
d439efb4 |
print "%s\n%s\n%s" % ('-'*40, response['data'], '-'*40)
|
d2b144df |
if __name__ == '__main__': |
d439efb4 |
if float("%d.%d" %(sys.version_info[0], sys.version_info[1])) < 2.4:
sys.stderr.write("ERROR: Python 2.4 or higher required, sorry.\n")
sys.exit(1)
cfg = Config(os.getenv("HOME")+"/.s3cfg")
logging.root.setLevel(logging.DEBUG)
sdb = SimpleDB(cfg) |
add6b7fc |
|
d439efb4 |
try:
display_response(sdb.ListDomains()) |
add6b7fc |
|
d439efb4 |
display_response(sdb.CreateDomain("logix.cz-test")) |
add6b7fc |
|
d439efb4 |
display_response(sdb.ListDomains()) |
add6b7fc |
|
d439efb4 |
display_response(sdb.PutAttributes("logix.cz-test", "AbCd", {'First': "One", "Second" : 2, "Third" : u"drei"}))
display_response(sdb.PutAttributes("logix.cz-test", "XyZ", {'xyz' : ['x', 'y', 'z'], 'Third' : u'traja'})) |
add6b7fc |
|
d439efb4 |
display_response(sdb.GetAttributes("logix.cz-test", "AbCd", ['Second', 'Third']))
display_response(sdb.GetAttributes("logix.cz-test", "XyZ")) |
add6b7fc |
|
d439efb4 |
display_response(sdb.Query("logix.cz-test", "['xyz' = 'z']")) |
add6b7fc |
|
d439efb4 |
display_response(sdb.DeleteDomain("logix.cz-test")) |
add6b7fc |
|
d439efb4 |
display_response(sdb.ListDomains())
except S3Error, e:
error(e)
error(e.info) |
add6b7fc |
|
d439efb4 |
# vim:et:ts=4:sts=4:ai |