Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import configobj
- from boto.gs.connection import GSConnection
- import os
- def main(upload = False):
- try:
- from win32com.shell import shellcon, shell
- homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)
- except ImportError:
- homedir = os.path.expanduser("~")
- config = configobj.ConfigObj( os.path.join(homedir,".boto"))
- cred = config["Credentials"]
- ak, sak = cred["gs_access_key_id"], cred["gs_secret_access_key"]
- c = GSConnection(ak,sak)
- for bucket in c.get_all_buckets():
- print "Bucket ... ", bucket.name
- for key in bucket.get_all_keys():
- print key.name
- if upload:
- key = bucket.new_key("testboto.py")
- with open("testboto.py","rb") as f:
- key.set_contents_from_file(f,policy="private")
- if __name__ == "__main__":
- main(True)
- main()
Add Comment
Please, Sign In to add comment