def prompt_new_cloud_app_account(): # Have the user give us their username/password print "---------------" print "I need to store your Cloudapp username/password for URL shortening." print "(FYI: These will be stored in the clear in your local mongoDB.)" username = string_prompt("Enter your Cloudapp username:"******"Enter your Cloudapp password:"******"username": username, "password": password, "default": True, }) # This will confirm that auth works: test_client = CloudAppClient.get(account=account) # Save the account to mongo and return it: account.save() print "" print "CloudApp Account successfully stored!" print "" return account
def main(): """ This is what runs! """ options = parse_args() app = get_application() if options.add_twitter: prompt_new_twitter_account(app) if options.cloud: # delete the default if it exists: try: CloudAppAccount.get_default().delete() except: pass cloud_app = get_cloud_app_client() print "\n Setup complete! \n"
def shorten_urls(text): """ :param text: String. :returns: String. """ # Fetch our account model: cloud_account = CloudAppAccount.get_default() # Configure the pycloud module: cloud.URI = cloud_account.URI # Create a pycloud client instance: cloud_client = cloud.Cloud() # Authenticate: cloud_client.auth(cloud_account.username, cloud_account.password)