Skip to content

Instantly share code, notes, and snippets.

@batok
Created June 2, 2010 00:01
Show Gist options
  • Save batok/421705 to your computer and use it in GitHub Desktop.
Save batok/421705 to your computer and use it in GitHub Desktop.
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()
@batok
Copy link
Author

batok commented Jun 2, 2010

Good tip, Mitch... tks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment