Skip to content

Instantly share code, notes, and snippets.

@loverdos
Created May 25, 2015 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loverdos/4ad1c46d4b302bf0cfed to your computer and use it in GitHub Desktop.
Save loverdos/4ad1c46d4b302bf0cfed to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from os.path import expanduser
from ConfigParser import ConfigParser
from sys import argv
kamakirc = "%s/.kamakirc" % expanduser("~")
cfg=ConfigParser()
cfg.read(kamakirc)
if len(argv) == 1:
print "Usage %s -l" % argv[0]
print " to see a listing of all cloud sections in ~/.kamakirc"
print "Usage %s --list" % argv[0]
print " ditto"
print "Usage %s cloud1 cloud2 ... cloudN" % argv[0]
print " to read the tokens of the given cloud sections"
print " e.g.: %s production" % argv[0]
print " to read [cloud \"production\"] section from ~/.kamakirc"
elif len(argv) == 2 and (argv[1] == '-l' or argv[1] == '--list'):
sections = cfg.sections()
for section in sections:
if section.startswith('cloud '):
print section
else:
clouds = argv[1:]
for cloud in clouds:
token = cfg.get('cloud "%s"' % cloud, 'token')
print token
@loverdos
Copy link
Author

print token is print cloud, token

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