Last active
January 4, 2016 22:09
-
-
Save azizmb/8686059 to your computer and use it in GitHub Desktop.
Simple shell which initializes a connection to Rackspace CloudFiles
This file contains 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 argparse | |
import cloudfiles | |
from cloudfiles.connection import Connection | |
AUTH_URLS = ['uk_authurl', 'us_authurl'] | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument("rcloud_user", help="the rcloud user to use") | |
parser.add_argument("rcloud_key", help="the rcloud api key to use") | |
parser.add_argument("-s", "--servicenet", help="whether to use servicenet", | |
action="store_true") | |
parser.add_argument("-a", "--authurl", help="which authurl to use", | |
choices=AUTH_URLS, default=AUTH_URLS[0]) | |
args = parser.parse_args() | |
con = Connection( | |
username=args.rcloud_user, | |
api_key=args.rcloud_key, | |
authurl=getattr(cloudfiles, args.authurl), | |
servicenet=args.servicenet | |
) | |
print 'Connection object is available as con' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment