def test_get_environment(self): env = pyrax.get_environment() all_envs = pyrax.list_environments() self.assertTrue(env in all_envs)
parser = argparse.ArgumentParser() parser.add_argument('container', help = "Which container to deploy to", nargs = "?", type = str, default = DEFAULT_CONTAINER) parser.add_argument('-r', '--region', help = "Which region to use. 'ORD' if none is specified.", type = str, default = DEFAULT_REGION, choices = CLOUDFILES_REGIONS) parser.add_argument('-e', '--environment', help = "Which environment to use. 'default' if none is specified.", type = str, default = 'default') parser.add_argument('--delete', help = "Remove orphaned files from Rackspace", action = "store_true", default = False) parser.add_argument('-v', '--version', help = "Print the script version and exit", action = "store_true", default = False) pyrax.set_credential_file(os.path.expanduser('~/.rackspace')) pyrax.set_setting('custom_user_agent', 'Rackup Python Script/%s' % VERSION) pyrax.authenticate() if not pyrax.identity.authenticated: alert('Your credentials failed to authenticate.', os.EX_UNAVAILABLE) args = parser.parse_args() if not args.environment in pyrax.list_environments(): alert('"%s" is not a valid environment.' % args.environment, os.EX_UNAVAILABLE) pyrax.set_environment(args.environment) if not args.container: alert("You must pass a container as the first argument.", os.EX_NOINPUT, ERROR_COLOR) cf = pyrax.connect_to_cloudfiles(region=args.region) containers = cf.list_containers() if not args.container in containers: alert('"%s" was not found in this accounts containers.' % args.container, os.EX_UNAVAILABLE, ERROR_COLOR) def main(): alert('Syncing files to "%s"' % args.container) cf.sync_folder_to_container('.', args.container, ignore = EXCLUDES, delete = args.delete, include_hidden = True)