Created
June 2, 2010 00:01
-
-
Save batok/421705 to your computer and use it in GitHub Desktop.
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
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good tip, Mitch... tks.