fixed simple_clien.py example

This commit is contained in:
Arvid Norberg 2008-11-21 18:04:59 +00:00
parent 340476f45b
commit 9d148d6816
1 changed files with 8 additions and 13 deletions

View File

@ -6,31 +6,26 @@
import libtorrent as lt
import time
import sys
ses = lt.session()
ses.listen_on(6881, 6891)
e = lt.bdecode(open("test.torrent", 'rb').read())
info = lt.torrent_info(e)
atp = {}
atp["ti"] = info
atp["save_path"] = "./"
atp["storage_mode"] = lt.storage_mode_t(1)
atp["paused"] = False
atp["auto_managed"] = True
atp["duplicate_is_error"] = True
h = ses.add_torrent(atp)
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']
'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'