def execute(helper, config, args):
version_label = args.version_label<EOL>archive = args.archive<EOL>env_config = parse_env_config(config, args.environment)<EOL>option_settings = parse_option_settings(env_config.get('<STR_LIT>', {}))<EOL>cname_prefix = env_config.get('<STR_LIT>', None)<EOL>tier_name = env_config.get('<STR_LIT>', '<STR_LIT>')<EOL>if tier_name != '<STR_LIT>':<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (tier_name, ))<EOL><DEDENT>out("<STR_LIT>")<EOL>new_env_name = None<EOL>if not helper.environment_exists(args.environment):<EOL><INDENT>new_env_name = args.environment<EOL><DEDENT>else:<EOL><INDENT>for i in range(<NUM_LIT:10>):<EOL><INDENT>temp_env_name = args.environment + '<STR_LIT:->' + str(i)<EOL>if not helper.environment_exists(temp_env_name):<EOL><INDENT>new_env_name = temp_env_name<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if new_env_name is None:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>out("<STR_LIT>" + new_env_name)<EOL>out("<STR_LIT>")<EOL>new_env_cname = None<EOL>for i in range(<NUM_LIT:10>):<EOL><INDENT>temp_cname = cname_prefix + '<STR_LIT:->' + str(i)<EOL>if not helper.environment_name_for_cname(temp_cname):<EOL><INDENT>new_env_cname = temp_cname<EOL>break<EOL><DEDENT><DEDENT>if new_env_cname is None:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>out("<STR_LIT>" + new_env_cname)<EOL>version_label = upload_application_archive(<EOL>helper, env_config, archive=args.archive, directory=args.directory, version_label=version_label)<EOL>helper.create_environment(new_env_name,<EOL>solution_stack_name=env_config.get('<STR_LIT>'),<EOL>cname_prefix=new_env_cname,<EOL>description=env_config.get('<STR_LIT:description>', None),<EOL>option_settings=option_settings,<EOL>version_label=version_label,<EOL>tier_name=tier_name,<EOL>tier_type=env_config.get('<STR_LIT>'),<EOL>tier_version=env_config.get('<STR_LIT>'))<EOL>helper.wait_for_environments(new_env_name, status='<STR_LIT>', health='<STR_LIT>', include_deleted=False)<EOL>old_env_name = helper.environment_name_for_cname(cname_prefix)<EOL>if old_env_name is None:<EOL><INDENT>raise Exception("<STR_LIT>" + cname_prefix)<EOL><DEDENT>out("<STR_LIT>" + old_env_name)<EOL>out("<STR_LIT>")<EOL>helper.swap_environment_cnames(old_env_name, new_env_name)<EOL>helper.wait_for_environments([old_env_name, new_env_name], status='<STR_LIT>', include_deleted=False)<EOL>if args.termination_delay:<EOL><INDENT>out("<STR_LIT>".format(args.termination_delay))<EOL>time.sleep(args.termination_delay)<EOL><DEDENT>out("<STR_LIT>".format(old_env_name))<EOL>helper.delete_environment(old_env_name)<EOL>helper.delete_unused_versions(versions_to_keep=int(get(config, '<STR_LIT>', <NUM_LIT:10>)))<EOL>
Deploys to an environment