Guest User

Untitled

a guest
May 27th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import configobj
  2. from boto.gs.connection import GSConnection
  3. import os
  4. def main(upload = False):
  5. try:
  6. from win32com.shell import shellcon, shell
  7. homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)
  8.  
  9. except ImportError:
  10. homedir = os.path.expanduser("~")
  11. config = configobj.ConfigObj( os.path.join(homedir,".boto"))
  12. cred = config["Credentials"]
  13. ak, sak = cred["gs_access_key_id"], cred["gs_secret_access_key"]
  14. c = GSConnection(ak,sak)
  15. for bucket in c.get_all_buckets():
  16. print "Bucket ... ", bucket.name
  17. for key in bucket.get_all_keys():
  18. print key.name
  19. if upload:
  20. key = bucket.new_key("testboto.py")
  21. with open("testboto.py","rb") as f:
  22. key.set_contents_from_file(f,policy="private")
  23.  
  24. if __name__ == "__main__":
  25. main(True)
  26. main()
Add Comment
Please, Sign In to add comment