I have bigs files to move to a lot of servers. For now we use rsync, but I would like to experiment with bittorent.
I'm studing the code of Deluge, a Python bittorent client but it uses twisted and is utterly complex. Do you know anything hight level?
EDIT: I just read that Facebook does code deployment using Bittorent. Maybe they published their lib for that, but I can't find it. Ever hear of it?
I definitely recommend libtorrent-rasterbar. It's a C++ library with Python bindings. The same one that powers Deluge, Transmission, Miro and many other bittorrent clients.
In contrast to the other libtorrent (the one that is part of rTorrent project), this one is under active development and supports all modern protocol extensions, like DHT, metadata transfer and even some proprietary uTorrent extensions like peer exchange (PEX).
The API is very well documented.
As you can see from the following fully functional simple client example, you don't need to understand every bit of the underlying protocol (of course, it helps a lot when you do):
#!/bin/python
# Copyright Arvid Norberg 2008. Use, modification and distribution is
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
import libtorrent as lt
import time
import sys
ses = lt.session()
ses.listen_on(6881, 6891)
info = lt.torrent_info(sys.argv[1])
h = ses.add_torrent({'ti': info, 'save_path': './'})
print 'starting', h.name()
while (not h.is_seed()):
s = h.status()
state_str = ['queued', 'checking', 'downloading metadata', 'downloading', \
'finished', 'seeding', 'allocating', 'checking fastresume']
print '\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \
(s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \
s.num_peers, state_str[s.state]),
sys.stdout.flush()
time.sleep(1)
print h.name(), 'complete'
P.S. Facebook has a dedicated page for their opensource projects at http://developers.facebook.com/opensource/. There's no bittorrent implementation listed.
The original BitTorrent client is written in Python. Have you checked that out?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With