MCPcopy Create free account
hub / github.com/Tencent/CodeAnalysis / file_server_download

Method file_server_download

client/task/basic/downloader.py:27–42  ·  view source on GitHub ↗

文件服务器下载 :param path_dict: { '文件服务器上的文件名': '拉取下来后存放的位置' } :return:

(path_dict)

Source from the content-addressed store, hash-verified

25class Downloader(object):
26 @staticmethod
27 def file_server_download(path_dict):
28 '''
29 文件服务器下载
30 :param path_dict: { '文件服务器上的文件名': '拉取下来后存放的位置' }
31 :return:
32 '''
33 for file_name in path_dict.keys():
34 temp_zip_file = tempfile.mktemp(prefix='zip_', dir=settings.DATA_DIR, suffix='.zip')
35 file_server = RetryFileServer(retry_times=2).get_server()
36 file_server.download_file(f"sourcedir/{file_name}", temp_zip_file)
37 if not os.path.exists(temp_zip_file):
38 raise TransferModuleError('文件服务器中拉取文件失败...')
39 Zip().decompress(temp_zip_file, os.path.join(settings.DATA_DIR, path_dict[file_name]))
40 logger.info('decompress done: %s' % os.path.join(settings.DATA_DIR, path_dict[file_name]))
41 PathMgr().rmpath(temp_zip_file)
42 return True
43
44
45if __name__ == "__main__":

Callers 1

download_fileMethod · 0.80

Calls 7

RetryFileServerClass · 0.90
TransferModuleErrorClass · 0.90
ZipClass · 0.90
get_serverMethod · 0.80
decompressMethod · 0.80
download_fileMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected