Пример #1
0
def pack_agent_files(tmp_path, src_path, artifacts_files, dstfile):
    tar_file, cwd, pack_path = _pack_files_begin(tmp_path, src_path, dstfile)
    for f in artifacts_files:
        loghelper.LogInfo(f.src)
        tar_file.add(f.src)
    _pack_files_end(tar_file, cwd, pack_path)
    return pack_path
Пример #2
0
def pack_repo_files(artifact_map, tmp_path, src_path, instance_list, dstfile):
    tar_file, cwd, pack_path = _pack_files_begin(tmp_path, src_path, dstfile)
    for instance in instance_list:
        artifacts = artifact_map[instance.artifact_name]
        for f in artifacts.files:
            loghelper.LogInfo(f.src)
            tar_file.add(f.src)
    _pack_files_end(tar_file, cwd, pack_path)
    return pack_path
Пример #3
0
def _pack_files_begin(tmp_path, src_path, dstfile):
    loghelper.LogInfo(
        '\n\n==================================== collecting file or directory ====================================')
    if not os.path.exists(src_path):
        loghelper.LogError('src_path: %s is not exist' % src_path)
        raise BaseException()
    if not os.path.exists(tmp_path):
        os.mkdir(tmp_path)

    pack_path = os.path.join(tmp_path, dstfile)
    tar_file = tarfile.open(pack_path, "w:gz")
    cwd = os.getcwd()
    os.chdir(src_path)
    return tar_file, cwd, pack_path
Пример #4
0
def _pack_files_end(tar_file, cwd, pack_path):
    tar_file.close()
    os.chdir(cwd)
    loghelper.LogInfo('tar.gz file: %s' % pack_path)