简体   繁体   English

使用python通过LAN从多个源复制文件的一部分

[英]copy parts of a file from multiple sources over LAN using python

Python seems to have functions for copying files (eg shutil.copy) and functions for copying directories.This also works with network paths. Python似乎具有复制文件的功能(例如shutil.copy)和复制目录的功能。这也适用于网络路径。

Is there a way to copy only part of the file from multiple sources and merge them afterwards 有没有一种方法可以从多个源中仅复制文件的一部分并在以后合并它们

Like a download manager downloads parts of a single file from multiple sources increasing the overall download speed. 就像下载管理器一样,它可以从多个来源下载单个文件的一部分,从而提高了整体下载速度。

I want to achive the same over lan. 我想通过局域网达到同样的效果。

I have a file on more than two machines on my network. 我的网络上有两台以上的计算机上有一个文件。

How could i copy parts of file to a single destination from multiple sources ? 如何将文件的一部分从多个来源复制到单个目标?

Can it be done with standard shutil libraries? 可以使用标准的shuti库来完成吗?

  • Stat the file to find the size 统计文件以查找大小
  • Divvy up the the start:end points that each reader will handle 划分每个读者将要处理的起点:终点
  • Open your write file in binary mode 以二进制模式打开您的写入文件
  • Open your readers in binary mode 以二进制模式打开阅读器
  • Handle the merging/collating of data when writing it out 写入时处理数据的合并/整理

I suggest you use a free open source peer-to-peer library. 我建议您使用免费的开源对等库。

Peer-to-peer file transfers are effective for the problem you are describing: to copy some huge files ~1gb from one machine on a network to 40 -50 machines 对等文件传输可有效解决您所描述的问题: 将一些大文件〜1gb从网络上的一台计算机复制到40 -50台计算机

Eg http://code.google.com/p/python-libtorrent/ 例如http://code.google.com/p/python-libtorrent/

Or use a client implementation. 或使用客户端实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM