def upload_application_archive(helper, env_config, archive=None, directory=None, version_label=None):
    if version_label is None:
        version_label = datetime.now().strftime('%Y%m%d_%H%M%S')
    archive_file_name = None
    if archive:
        archive_file_name = os.path.basename(archive)

    archive_files = get(env_config, 'archive.files', [])

    # generate the archive externally
    if get(env_config, 'archive.generate'):
        cmd = get(env_config, 'archive.generate.cmd')
        output_file = get(env_config, 'archive.generate.output_file')
        use_shell = get(env_config, 'archive.generate.use_shell', True)
        exit_code = get(env_config, 'archive.generate.exit_code', 0)
        if not cmd or not output_file:
            raise Exception('Archive generation requires cmd and output_file at a minimum')
        output_regex = None
        try:
            output_regex = re.compile(output_file)
        except:
            pass
        result = subprocess.call(cmd, shell=use_shell)
        if result != exit_code:
            raise Exception('Generate command execited with code %s (expected %s)' % (result, exit_code))

        if output_file and os.path.exists(output_file):
            archive_file_name = os.path.basename(output_file)
        else:
            for root, dirs, files in os.walk(".", followlinks=True):
                for f in files:
                    fullpath = os.path.join(root, f)
                    if fullpath.endswith(output_file):
                        archive = fullpath
                        archive_file_name = os.path.basename(fullpath)
                        break
                    elif output_regex and output_regex.match(fullpath):
                        archive = fullpath
                        archive_file_name = os.path.basename(fullpath)
                        break
                if archive:
                    break
            if not archive or not archive_file_name:
                raise Exception((output_file) % 'Unable to find expected output file matching: %s')

    # create the archive
    elif not archive:
        if not directory:
            directory = "."
        includes = get(env_config, 'archive.includes', [])
        excludes = get(env_config, 'archive.excludes', [])

        def _predicate(f):
            for exclude in excludes:
                if re.match(exclude, f):
                    return False
            if len(includes) > 0:
                for include in includes:
                    if re.match(include, f):
                        return True
                return False
            return True
        archive = create_archive(directory, str(version_label) + ".zip", config=archive_files, ignore_predicate=_predicate)
        archive_file_name = str(version_label) + ".zip"

    add_config_files_to_archive(directory, archive, config=archive_files)
    helper.upload_archive(archive, archive_file_name)
    helper.create_application_version(version_label, archive_file_name)
    return version_label
dataset/ETHPy150Open briandilley/ebs-deploy/ebs_deploy/__init__.py/upload_application_archive/swapped operands of `%`