1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-23 00:43:28 +00:00

o Update to 4.0 which supports new protocol standards

o The GUI interface now depends on x11-toolkits/py-gtk2 instead of
  x11-toolkits/py-wxPython
This commit is contained in:
Mario Sergio Fujikawa Ferreira 2005-03-12 23:19:07 +00:00
parent 1863e37e72
commit 818beb0701
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=131044
56 changed files with 650 additions and 1196 deletions

View File

@ -6,14 +6,11 @@
#
PORTNAME= BitTorrent
PORTVERSION= 3.4.2
PORTREVISION= 5
PORTVERSION= 4.0.0
PORTEPOCH= 1
CATEGORIES?= net python
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE_EXTENDED}
MASTER_SITE_SUBDIR= ${PORTNAME:L}
MASTER_SITES= http://www.bittorrent.com/dl/
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
#DISTNAME= ${PORTNAME}-${PORTVERSION:C/\.(.)$/\1/}
MAINTAINER= lioux@FreeBSD.org
COMMENT?= A peer-to-peer tool for distributing files written in Python
@ -24,9 +21,14 @@ USE_REINPLACE= yes
CONFLICTS= py??-*[Bb]it[Tt]orrent* py??-*[Bb]it[Tt]ornado* btqueue*
PORTDOCS= BUILD.windows.txt INSTALL.unix.txt LICENSE.txt \
PORTDOCS= LICENSE.txt \
redirdonate.html \
README.txt credits.txt
.ifdef(NOPORTDOCS)
EXTRA_PATCHES+= ${FILESDIR}/extra-noportdocs-setup.py
.endif
.include <bsd.port.pre.mk>
.if ${ARCH} != "i386"
@ -35,11 +37,27 @@ WITHOUT_PSYCO= yes
# required for GUI
.ifndef(WITHOUT_GUI)
RUN_DEPENDS+= ${PYTHON_SITELIBDIR}/wxPython/__init__.py:${PORTSDIR}/x11-toolkits/py-wxPython
RUN_DEPENDS+= ${PYTHON_SITELIBDIR}/pygtk.py:${PORTSDIR}/x11-toolkits/py-gtk2
PLIST_FILES+= \
bin/btcompletedirgui.py \
bin/btdownloadgui.py
bin/btmaketorrentgui.py \
bin/btdownloadgui.py \
share/pixmaps/BitTorrent/bittorrent.ico \
share/pixmaps/BitTorrent/broken.png \
share/pixmaps/BitTorrent/finished.png \
share/pixmaps/BitTorrent/info.png \
share/pixmaps/BitTorrent/logo/bittorrent_32.png \
share/pixmaps/BitTorrent/logo/bittorrent_96.png \
share/pixmaps/BitTorrent/pause.png \
share/pixmaps/BitTorrent/paused.png \
share/pixmaps/BitTorrent/play.png \
share/pixmaps/BitTorrent/queued.png \
share/pixmaps/BitTorrent/remove.png \
share/pixmaps/BitTorrent/running.png
PLIST_DIRS+= share/pixmaps/BitTorrent/logo \
share/pixmaps/BitTorrent
.else
EXTRA_PATCHES+= ${FILESDIR}/extra-nogui-patch-setup.py
.endif
@ -48,14 +66,15 @@ EXTRA_PATCHES+= ${FILESDIR}/extra-nogui-patch-setup.py
RUN_DEPENDS+= ${PYTHON_SITELIBDIR}/psyco/_psyco.so:${PORTSDIR}/devel/py-psyco
EXTRA_PATCHES+= \
${FILESDIR}/extra-psyco-patch-btcompletedir.py \
${FILESDIR}/extra-psyco-patch-btcompletedirgui.py \
${FILESDIR}/extra-psyco-patch-btdownloadcurses.py \
${FILESDIR}/extra-psyco-patch-btdownloadgui.py \
${FILESDIR}/extra-psyco-patch-btdownloadheadless.py \
${FILESDIR}/extra-psyco-patch-btlaunchmany.py \
${FILESDIR}/extra-psyco-patch-btlaunchmanycurses.py \
${FILESDIR}/extra-psyco-patch-btmakemetafile.py \
${FILESDIR}/extra-psyco-patch-btmaketorrent.py \
${FILESDIR}/extra-psyco-patch-btreannouce.py \
${FILESDIR}/extra-psyco-patch-btrename.py \
${FILESDIR}/extra-psyco-patch-btshowmetainfo.py \
${FILESDIR}/extra-psyco-patch-bttest.py \
${FILESDIR}/extra-psyco-patch-bttrack.py
PLIST_FILES+= \
@ -76,28 +95,29 @@ post-patch:
@${FIND} ${WRKSRC} -type f | \
${XARGS} -x -n 10 \
${REINPLACE_CMD} -E \
-e 's|/usr/bin/env python2|${LOCALBASE}/bin/python|'
.ifdef(WITHOUT_GUI)
@${REINPLACE_CMD} -E \
-e 's|btdownloadgui.py|btdownloadcurses.py|' \
${WRKSRC}/INSTALL.unix.txt
.endif
-e 's|/usr/bin/env python.*|${LOCALBASE}/bin/python|'
.ifndef(WITHOUT_PSYCO)
# activate psyco optimization
@${ECHO_CMD} 'psyco = 1' > ${WRKSRC}/BitTorrent/PSYCO.py
.endif
post-install:
.ifndef(NOPORTDOCS)
@${MKDIR} ${DOCSDIR}
.for file in ${PORTDOCS}
@${INSTALL_DATA} ${WRKSRC}/${file} ${DOCSDIR}
.endfor
.endif
# set proper permissions
@${CHMOD} -R ${SHAREMODE} \
${PREFIX}/${PYTHON_SITELIBDIR:S|^${PYTHONBASE}/||}/BitTorrent
@${CHMOD} ${SHAREMODE} ${PREFIX}/${PYTHON_SITELIBDIR:S|^${PYTHONBASE}/||}/BitTorrent
@${CHMOD} a+x ${PREFIX}/${PYTHON_SITELIBDIR:S|^${PYTHONBASE}/||}/BitTorrent
.ifndef(WITHOUT_GUI)
# pixmaps
@${CHMOD} -R ${SHAREMODE} \
${PREFIX}/share/pixmaps/${PORTNAME}/*
@${CHMOD} a+x \
${PREFIX}/share/pixmaps/${PORTNAME}/logo
.endif
.ifndef(NOPORTDOCS)
# docs
@${CHMOD} -R ${SHAREMODE} \
${DOCSDIR}/*
.endif
.include <bsd.port.post.mk>

View File

@ -1,2 +1,2 @@
MD5 (BitTorrent-3.4.2.tar.gz) = b854f25a33289565bcaeaded04955c1a
SIZE (BitTorrent-3.4.2.tar.gz) = 198026
MD5 (BitTorrent-4.0.0.tar.gz) = 67f449df351b66f408b72b6bd196952f
SIZE (BitTorrent-4.0.0.tar.gz) = 148649

View File

@ -1,14 +1,20 @@
--- setup.py.orig Sun Mar 30 17:01:05 2003
+++ setup.py Sun Mar 30 17:01:20 2003
@@ -18,9 +18,9 @@
packages = ["BitTorrent"],
--- setup.py.orig Sat Mar 12 10:01:45 2005
+++ setup.py Sat Mar 12 10:14:21 2005
@@ -19,9 +19,9 @@
- scripts = ["btdownloadgui.py", "btdownloadheadless.py", "btdownloadlibrary.py",
+ scripts = ["btdownloadheadless.py", "btdownloadlibrary.py",
"bttrack.py", "btmakemetafile.py", "btlaunchmany.py", "btcompletedir.py",
- "btdownloadcurses.py", "btcompletedirgui.py", "btlaunchmanycurses.py",
+ "btdownloadcurses.py", "btlaunchmanycurses.py",
"btmakemetafile.py", "btreannounce.py", "btrename.py", "btshowmetainfo.py",
"bttest.py"]
)
import glob
-scripts = ["btdownloadgui.py", "btdownloadcurses.py", "btdownloadheadless.py",
- "btmaketorrentgui.py", "btmaketorrent.py",
+scripts = ["btdownloadcurses.py", "btdownloadheadless.py",
+ "btmaketorrent.py",
"btlaunchmany.py", "btlaunchmanycurses.py",
"bttrack.py", "btreannounce.py", "btrename.py", "btshowmetainfo.py",
"bttest.py"]
@@ -28,4 +28,3 @@
img_root, doc_root = BitTorrent.calc_unix_dirs()
-data_files = [ (img_root , glob.glob('images/*png')+['images/bittorrent.ico',]),
- (img_root+'/logo', glob.glob('images/logo/bittorrent_[0-9]*.png') ),
+data_files = [

View File

@ -0,0 +1,8 @@
--- setup.py.bak Mon Mar 7 00:55:50 2005
+++ setup.py Fri Mar 11 22:55:38 2005
@@ -31,5 +31,3 @@
- (doc_root , ['credits.txt', 'LICENSE.txt',
- 'README.txt', 'redirdonate.html'] ),
]
setup(

View File

@ -0,0 +1,18 @@
--- BitTorrent/launchmanycore.py.orig Sat Mar 12 10:00:19 2005
+++ BitTorrent/launchmanycore.py Sat Mar 12 10:00:40 2005
@@ -13,6 +13,15 @@
# Original version written by John Hoffman, heavily modified for different
# multitorrent architecture by Uoti Urpala (over 40% shorter than original)
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
import os
from cStringIO import StringIO
from traceback import print_exc

View File

@ -0,0 +1,18 @@
--- BitTorrent/makemetafile.py.orig Sat Mar 12 09:58:42 2005
+++ BitTorrent/makemetafile.py Sat Mar 12 09:59:06 2005
@@ -12,6 +12,15 @@
# Written by Bram Cohen
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from __future__ import division
import os

View File

@ -1,18 +0,0 @@
--- btcompletedir.py Thu Dec 16 11:03:11 2004
+++ btcompletedir.py Thu Dec 16 11:12:55 2004
@@ -3,6 +3,15 @@
# Written by Bram Cohen
# see LICENSE.txt for license information
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from os.path import join, split
from threading import Event
from traceback import print_exc

View File

@ -1,18 +0,0 @@
--- btcompletedirgui.py Thu Dec 16 11:03:11 2004
+++ btcompletedirgui.py Thu Dec 16 11:13:34 2004
@@ -3,6 +3,15 @@
# Written by Bram Cohen
# see LICENSE.txt for license information
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import argv, version
from btcompletedir import completedir

View File

@ -1,18 +1,18 @@
--- btdownloadcurses.py Thu Dec 16 11:03:11 2004
+++ btdownloadcurses.py Thu Dec 16 11:13:54 2004
@@ -3,6 +3,15 @@
# Written by Henry 'Pi' James
# see LICENSE.txt for license information
--- btdownloadcurses.py.orig Fri Mar 11 23:12:10 2005
+++ btdownloadcurses.py Fri Mar 11 23:13:08 2005
@@ -15,6 +15,15 @@
from __future__ import division
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+ pass
+
from BitTorrent.download import download
from threading import Event
from os.path import abspath
SPEW_SCROLL_RATE = 1
import sys

View File

@ -1,18 +0,0 @@
--- btdownloadgui.py Thu Dec 16 11:03:11 2004
+++ btdownloadgui.py Thu Dec 16 11:14:07 2004
@@ -3,6 +3,15 @@
# Written by Bram Cohen and Myers Carpenter
# see LICENSE.txt for license information
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import argv
from BitTorrent import version
from BitTorrent.download import download

View File

@ -1,18 +1,18 @@
--- btdownloadheadless.py Thu Dec 16 11:03:11 2004
+++ btdownloadheadless.py Thu Dec 16 11:14:16 2004
@@ -3,6 +3,15 @@
# Written by Bram Cohen
# see LICENSE.txt for license information
--- btdownloadheadless.py.orig Fri Mar 11 23:14:21 2005
+++ btdownloadheadless.py Fri Mar 11 23:14:28 2005
@@ -14,6 +14,15 @@
from __future__ import division
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+ pass
+
from BitTorrent.download import download
from threading import Event
from os.path import abspath
import sys
import os
import threading

View File

@ -1,18 +1,18 @@
--- btlaunchmany.py Thu Dec 16 11:03:11 2004
+++ btlaunchmany.py Thu Dec 16 11:14:54 2004
@@ -7,6 +7,15 @@
# fmttime and fmtsize stolen from btdownloadcurses.
# see LICENSE.txt for license information
--- btlaunchmany.py.orig Fri Mar 11 23:14:47 2005
+++ btlaunchmany.py Fri Mar 11 23:14:54 2005
@@ -12,6 +12,15 @@
# Written by John Hoffman
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+ pass
+
from BitTorrent.download import download
from threading import Thread, Event, Lock
from os import listdir
import sys
import os

View File

@ -1,18 +1,18 @@
--- btlaunchmanycurses.py Thu Dec 16 11:03:11 2004
+++ btlaunchmanycurses.py Thu Dec 16 11:14:47 2004
@@ -7,6 +7,15 @@
# fmttime and fmtsize stolen from btdownloadcurses.
# see LICENSE.txt for license information
--- btlaunchmanycurses.py.orig Fri Mar 11 23:15:15 2005
+++ btlaunchmanycurses.py Fri Mar 11 23:15:22 2005
@@ -14,6 +14,15 @@
from __future__ import division
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+ pass
+
from BitTorrent.download import download
from threading import Thread, Event, Lock
from os import listdir
DOWNLOAD_SCROLL_RATE = 1
import sys, os

View File

@ -1,18 +0,0 @@
--- btmakemetafile.py Thu Dec 16 11:03:11 2004
+++ btmakemetafile.py Thu Dec 16 11:15:10 2004
@@ -3,6 +3,15 @@
# Written by Bram Cohen
# see LICENSE.txt for license information
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import argv
from os.path import getsize, split, join, abspath, isdir
from os import listdir

View File

@ -0,0 +1,18 @@
--- btmaketorrent.py.orig Fri Mar 11 23:15:38 2005
+++ btmaketorrent.py Fri Mar 11 23:15:43 2005
@@ -12,6 +12,15 @@
# Written by Bram Cohen
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
import sys
from BitTorrent.makemetafile import make_meta_files
from BitTorrent.parseargs import parseargs, printHelp

View File

@ -0,0 +1,18 @@
--- btreannounce.py.orig Fri Mar 11 23:15:59 2005
+++ btreannounce.py Fri Mar 11 23:16:05 2005
@@ -12,6 +12,15 @@
# Written by Henry 'Pi' James and Bram Cohen
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import argv
from BitTorrent.bencode import bencode, bdecode

View File

@ -0,0 +1,18 @@
--- btrename.py.orig Fri Mar 11 23:16:21 2005
+++ btrename.py Fri Mar 11 23:16:28 2005
@@ -12,6 +12,15 @@
# Written by Henry 'Pi' James
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import *
from os.path import *
from sha import *

View File

@ -0,0 +1,18 @@
--- btshowmetainfo.py.orig Fri Mar 11 23:16:39 2005
+++ btshowmetainfo.py Fri Mar 11 23:16:48 2005
@@ -12,6 +12,15 @@
# Written by Henry 'Pi' James and Loring Holden
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import *
from os.path import *
from sha import *

View File

@ -0,0 +1,18 @@
--- bttest.py.orig Fri Mar 11 23:17:05 2005
+++ bttest.py Fri Mar 11 23:17:12 2005
@@ -12,6 +12,15 @@
# Written by Bram Cohen
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from BitTorrent import testtest
import bttrack
import btmakemetafile

View File

@ -1,17 +1,17 @@
--- bttrack.py Thu Dec 16 11:03:11 2004
+++ bttrack.py Thu Dec 16 11:15:33 2004
@@ -3,6 +3,15 @@
--- bttrack.py.orig Fri Mar 11 23:17:26 2005
+++ bttrack.py Fri Mar 11 23:17:31 2005
@@ -12,6 +12,15 @@
# Written by Bram Cohen
# see LICENSE.txt for license information
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+ pass
+
from sys import argv
from BitTorrent.track import track

View File

@ -1,30 +0,0 @@
--- BitTorrent/Rerequester.py Sat Apr 3 01:10:23 2004
+++ BitTorrent/Rerequester.py Sun Apr 18 17:03:33 2004
@@ -5,7 +5,7 @@
from btformats import check_peers
from bencode import bdecode
from threading import Thread, Lock
-from socket import error
+from socket import error, gethostbyname
from time import time
from random import randrange
from binascii import b2a_hex
@@ -18,8 +18,7 @@
self.url = ('%s?info_hash=%s&peer_id=%s&port=%s&key=%s' %
(url, quote(infohash), quote(myid), str(port),
b2a_hex(''.join([chr(randrange(256)) for i in xrange(4)]))))
- if ip != '':
- self.url += '&ip=' + quote(ip)
+ self.ip = ip
self.interval = interval
self.last = None
self.trackerid = None
@@ -81,6 +80,8 @@
def rerequest(self, url, set):
try:
+ if self.ip:
+ url += '&ip=' + gethostbyname(self.ip)
h = urlopen(url)
r = h.read()
h.close()

View File

@ -0,0 +1,11 @@
--- BitTorrent/__init__.py.orig Fri Mar 11 22:53:12 2005
+++ BitTorrent/__init__.py Fri Mar 11 22:53:27 2005
@@ -21,7 +21,7 @@
import os
def calc_unix_dirs():
- appdir = '%s-%s'%(app_name, version)
+ appdir = '%s'%(app_name)
ip = os.path.join('share', 'pixmaps', appdir)
dp = os.path.join('share', 'doc' , appdir)
return ip, dp

View File

@ -0,0 +1,11 @@
--- BitTorrent/defaultargs.py.orig Sun Dec 26 08:41:09 2004
+++ BitTorrent/defaultargs.py Sun Dec 26 08:41:16 2004
@@ -83,7 +83,7 @@
'if nonzero, set the TOS option for peer connections to this value'),
('filesystem_encoding', '',
"character encoding used on the local filesystem. If left empty, autodetected. Autodetection doesn't work under python versions older than 2.3"),
- ('enable_bad_libc_workaround', 0,
+ ('enable_bad_libc_workaround', 1,
'enable workaround for a bug in BSD libc that makes file reads very slow.'),
]

View File

@ -1,300 +0,0 @@
--- BitTorrent/track.py Sun Mar 21 16:32:55 2004
+++ BitTorrent/track.py Sun Jun 6 09:33:07 2004
@@ -37,12 +37,15 @@
'minimum time it must have been since the last flush to do another one'),
('allowed_dir', '', 'only allow downloads for .torrents in this dir'),
('parse_allowed_interval', 15, 'minutes between reloading of allowed_dir'),
+ ('show_infopage', 1, "whether to display an info page when the tracker's root dir is loaded"),
+ ('infopage_redirect', '', 'a URL to redirect the info page to'),
('show_names', 1, 'whether to display names from allowed dir'),
('favicon', '', 'file containing x-icon data to return when browser requests favicon.ico'),
('only_local_override_ip', 1, "ignore the ip GET parameter from machines which aren't on local network IPs"),
('logfile', '', 'file to write the tracker logs, use - for stdout (default)'),
('allow_get', 0, 'use with allowed_dir; adds a /file?hash={hash} url that allows users to download the torrent file'),
('keep_dead', 0, 'keep dead torrents after they expire (so they still show up on your /scrape and web page)'),
+ ('scrape_allowed', 'full', 'scrape access allowed (can be none, specific or full)'),
('max_give', 200, 'maximum number of peers to give with any one request'),
]
@@ -124,11 +127,11 @@
favicon = config['favicon']
self.favicon = None
if favicon:
- if isfile(favicon):
+ try:
h = open(favicon, 'rb')
self.favicon = h.read()
h.close()
- else:
+ except:
print "**warning** specified favicon file -- %s -- does not exist." % favicon
self.rawserver = rawserver
self.becache1 = {}
@@ -190,6 +193,130 @@
self.uq_broken = 0
self.keep_dead = config['keep_dead']
+ def get_infopage(self):
+ if not self.config['show_infopage']:
+ return (404, 'Not Found', {'Content-Type': 'text/plain', 'Pragma': 'no-cache'}, alas)
+ red = self.config['infopage_redirect']
+ if red != '':
+ return (302, 'Found', {'Content-Type': 'text/html', 'Location': red},
+ '<A HREF="'+red+'">Click Here</A>')
+
+ s = StringIO()
+ s.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n' \
+ '<html><head><title>BitTorrent download info</title>\n')
+ if self.favicon != None:
+ s.write('<link rel="shortcut icon" href="/favicon.ico" />\n')
+ s.write('</head>\n<body>\n' \
+ '<h3>BitTorrent download info</h3>\n'\
+ '<ul>\n'
+ '<li><strong>tracker version:</strong> %s</li>\n' \
+ '<li><strong>server time:</strong> %s</li>\n' \
+ '</ul>\n' % (version, isotime()))
+ names = self.downloads.keys()
+ if not names:
+ s.write('<p>not tracking any files yet...</p>\n')
+ else:
+ names.sort()
+ tn = 0
+ tc = 0
+ td = 0
+ tt = 0 # Total transferred
+ ts = 0 # Total size
+ nf = 0 # Number of files displayed
+ uc = {}
+ ud = {}
+ if self.allowed != None and self.show_names:
+ s.write('<table summary="files" border="1">\n' \
+ '<tr><th>info hash</th><th>torrent name</th><th align="right">size</th><th align="right">complete</th><th align="right">downloading</th><th align="right">downloaded</th><th align="right">transferred</th></tr>\n')
+ else:
+ s.write('<table summary="files">\n' \
+ '<tr><th>info hash</th><th align="right">complete</th><th align="right">downloading</th><th align="right">downloaded</th></tr>\n')
+ for name in names:
+ l = self.downloads[name]
+ n = self.completed.get(name, 0)
+ tn = tn + n
+ lc = []
+ for i in l.values():
+ if type(i) == DictType:
+ if i['left'] == 0:
+ lc.append(1)
+ uc[i['ip']] = 1
+ else:
+ ud[i['ip']] = 1
+ c = len(lc)
+ tc = tc + c
+ d = len(l) - c
+ td = td + d
+ if self.allowed != None and self.show_names:
+ if self.allowed.has_key(name):
+ nf = nf + 1
+ sz = self.allowed[name]['length'] # size
+ ts = ts + sz
+ szt = sz * n # Transferred for this torrent
+ tt = tt + szt
+ if self.allow_get == 1:
+ linkname = '<a href="/file?info_hash=' + quote(name) + '">' + self.allowed[name]['name'] + '</a>'
+ else:
+ linkname = self.allowed[name]['name']
+ s.write('<tr><td><code>%s</code></td><td>%s</td><td align="right">%s</td><td align="right">%i</td><td align="right">%i</td><td align="right">%i</td><td align="right">%s</td></tr>\n' \
+ % (b2a_hex(name), linkname, size_format(sz), c, d, n, size_format(szt)))
+ else:
+ s.write('<tr><td><code>%s</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td></tr>\n' \
+ % (b2a_hex(name), c, d, n))
+ ttn = 0
+ for i in self.completed.values():
+ ttn = ttn + i
+ if self.allowed != None and self.show_names:
+ s.write('<tr><td align="right" colspan="2">%i files</td><td align="right">%s</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%s</td></tr>\n'
+ % (nf, size_format(ts), len(uc), tc, len(ud), td, tn, ttn, size_format(tt)))
+ else:
+ s.write('<tr><td align="right">%i files</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%i/%i</td></tr>\n'
+ % (nf, len(uc), tc, len(ud), td, tn, ttn))
+ s.write('</table>\n' \
+ '<ul>\n' \
+ '<li><em>info hash:</em> SHA1 hash of the "info" section of the metainfo (*.torrent)</li>\n' \
+ '<li><em>complete:</em> number of connected clients with the complete file (total: unique IPs/total connections)</li>\n' \
+ '<li><em>downloading:</em> number of connected clients still downloading (total: unique IPs/total connections)</li>\n' \
+ '<li><em>downloaded:</em> reported complete downloads (total: current/all)</li>\n' \
+ '<li><em>transferred:</em> torrent size * total downloaded (does not include partial transfers)</li>\n' \
+ '</ul>\n')
+ s.write('</body>\n' \
+ '</html>\n')
+ return (200, 'OK', {'Content-Type': 'text/html; charset=iso-8859-1'}, s.getvalue())
+
+ def scrapedata(self, name, return_name = True):
+ l = self.downloads[name]
+ n = self.completed.get(name, 0)
+ c = len([1 for i in l.values() if i['left'] == 0])
+ d = len(l) - c
+ f = {'complete': c, 'incomplete': d, 'downloaded': n}
+ if ( return_name and self.show_names
+ and self.allowed is not None and self.allowed.has_key(name) ):
+ f['name'] = self.allowed[name]['name']
+ return (f)
+
+ def get_scrape(self, paramslist):
+ fs = {}
+ if paramslist.has_key('info_hash'):
+ if self.config['scrape_allowed'] not in ['specific', 'full']:
+ return (400, 'Not Authorized', {'Content-Type': 'text/plain', 'Pragma': 'no-cache'},
+ bencode({'failure reason':
+ 'specific scrape function is not available with this tracker.'}))
+ for infohash in paramslist['info_hash']:
+ if infohash in self.downloads.keys():
+ fs[infohash] = self.scrapedata(infohash)
+ else:
+ if self.config['scrape_allowed'] != 'full':
+ return (400, 'Not Authorized', {'Content-Type': 'text/plain', 'Pragma': 'no-cache'},
+ bencode({'failure reason':
+ 'full scrape function is not available with this tracker.'}))
+ names = self.downloads.keys()
+ names.sort()
+ for name in names:
+ fs[name] = self.scrapedata(name)
+
+ return (200, 'OK', {'Content-Type': 'text/plain'}, bencode({'files': fs}))
+
def get(self, connection, path, headers):
try:
(scheme, netloc, path, pars, query, fragment) = urlparse(path)
@@ -197,117 +324,22 @@
path = path.replace('+',' ')
query = query.replace('+',' ')
path = unquote(path)[1:]
+ paramslist = {}
params = {}
for s in query.split('&'):
if s != '':
i = s.index('=')
- params[unquote(s[:i])] = unquote(s[i+1:])
+ kw = unquote(s[:i])
+ key, value = unquote(s[:i]), unquote(s[i+1:])
+ paramslist.setdefault(key, []).append(value)
+ params[key] = value
except ValueError, e:
return (400, 'Bad Request', {'Content-Type': 'text/plain'},
'you sent me garbage - ' + str(e))
if path == '' or path == 'index.html':
- s = StringIO()
- s.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n' \
- '<html><head><title>BitTorrent download info</title>\n')
- if self.favicon != None:
- s.write('<link rel="shortcut icon" href="/favicon.ico" />\n')
- s.write('</head>\n<body>\n' \
- '<h3>BitTorrent download info</h3>\n'\
- '<ul>\n'
- '<li><strong>tracker version:</strong> %s</li>\n' \
- '<li><strong>server time:</strong> %s</li>\n' \
- '</ul>\n' % (version, isotime()))
- names = self.downloads.keys()
- if names:
- names.sort()
- tn = 0
- tc = 0
- td = 0
- tt = 0 # Total transferred
- ts = 0 # Total size
- nf = 0 # Number of files displayed
- uc = {}
- ud = {}
- if self.allowed != None and self.show_names:
- s.write('<table summary="files" border="1">\n' \
- '<tr><th>info hash</th><th>torrent name</th><th align="right">size</th><th align="right">complete</th><th align="right">downloading</th><th align="right">downloaded</th><th align="right">transferred</th></tr>\n')
- else:
- s.write('<table summary="files">\n' \
- '<tr><th>info hash</th><th align="right">complete</th><th align="right">downloading</th><th align="right">downloaded</th></tr>\n')
- for name in names:
- l = self.downloads[name]
- n = self.completed.get(name, 0)
- tn = tn + n
- lc = []
- for i in l.values():
- if type(i) == DictType:
- if i['left'] == 0:
- lc.append(1)
- uc[i['ip']] = 1
- else:
- ud[i['ip']] = 1
- c = len(lc)
- tc = tc + c
- d = len(l) - c
- td = td + d
- if self.allowed != None and self.show_names:
- if self.allowed.has_key(name):
- nf = nf + 1
- sz = self.allowed[name]['length'] # size
- ts = ts + sz
- szt = sz * n # Transferred for this torrent
- tt = tt + szt
- if self.allow_get == 1:
- linkname = '<a href="/file?info_hash=' + quote(name) + '">' + self.allowed[name]['name'] + '</a>'
- else:
- linkname = self.allowed[name]['name']
- s.write('<tr><td><code>%s</code></td><td>%s</td><td align="right">%s</td><td align="right">%i</td><td align="right">%i</td><td align="right">%i</td><td align="right">%s</td></tr>\n' \
- % (b2a_hex(name), linkname, size_format(sz), c, d, n, size_format(szt)))
- else:
- s.write('<tr><td><code>%s</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td></tr>\n' \
- % (b2a_hex(name), c, d, n))
- ttn = 0
- for i in self.completed.values():
- ttn = ttn + i
- if self.allowed != None and self.show_names:
- s.write('<tr><td align="right" colspan="2">%i files</td><td align="right">%s</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%s</td></tr>\n'
- % (nf, size_format(ts), len(uc), tc, len(ud), td, tn, ttn, size_format(tt)))
- else:
- s.write('<tr><td align="right">%i files</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%i/%i</td></tr>\n'
- % (nf, len(uc), tc, len(ud), td, tn, ttn))
- s.write('</table>\n' \
- '<ul>\n' \
- '<li><em>info hash:</em> SHA1 hash of the "info" section of the metainfo (*.torrent)</li>\n' \
- '<li><em>complete:</em> number of connected clients with the complete file (total: unique IPs/total connections)</li>\n' \
- '<li><em>downloading:</em> number of connected clients still downloading (total: unique IPs/total connections)</li>\n' \
- '<li><em>downloaded:</em> reported complete downloads (total: current/all)</li>\n' \
- '<li><em>transferred:</em> torrent size * total downloaded (does not include partial transfers)</li>\n' \
- '</ul>\n')
- else:
- s.write('<p>not tracking any files yet...</p>\n')
- s.write('</body>\n' \
- '</html>\n')
- return (200, 'OK', {'Content-Type': 'text/html; charset=iso-8859-1'}, s.getvalue())
+ return self.get_infopage()
elif path == 'scrape':
- fs = {}
- names = []
- if params.has_key('info_hash'):
- if self.downloads.has_key(params['info_hash']):
- names = [ params['info_hash'] ]
- # else return nothing
- else:
- names = self.downloads.keys()
- names.sort()
- for name in names:
- l = self.downloads[name]
- n = self.completed.get(name, 0)
- c = len([1 for i in l.values() if type(i) == DictType and i['left'] == 0])
- d = len(l) - c
- fs[name] = {'complete': c, 'incomplete': d, 'downloaded': n}
- if (self.allowed is not None) and self.allowed.has_key(name) and self.show_names:
- fs[name]['name'] = self.allowed[name]['name']
- r = {'files': fs}
- return (200, 'OK', {'Content-Type': 'text/plain'}, bencode(r))
+ return self.get_scrape(paramslist)
elif (path == 'file') and (self.allow_get == 1) and params.has_key('info_hash') and self.allowed.has_key(params['info_hash']):
hash = params['info_hash']
fname = self.allowed[hash]['file']
@@ -506,9 +538,9 @@
r = str(s) + 'B'
elif (s < 1048576):
r = str(int(s/1024)) + 'KiB'
- elif (s < 1073741824l):
+ elif (s < 1073741824L):
r = str(int(s/1048576)) + 'MiB'
- elif (s < 1099511627776l):
+ elif (s < 1099511627776L):
r = str(int((s/1073741824.0)*100.0)/100.0) + 'GiB'
else:
r = str(int((s/1099511627776.0)*100.0)/100.0) + 'TiB'

View File

@ -1,18 +0,0 @@
--- BitTorrent/zurllib.py.orig Thu Dec 9 10:36:43 2004
+++ BitTorrent/zurllib.py Thu Dec 9 10:38:19 2004
@@ -35,7 +35,14 @@
if DEBUG:
pprint.pprint(headers.dict)
url = fp.url
- return addinfourldecompress(fp, headers, url)
+ resp = addinfourldecompress(fp, headers, url)
+ # As of Python 2.4 http_open response also has 'code' and 'msg'
+ # members, and HTTPErrorProcessor breaks if they don't exist.
+ if 'code' in dir(fp):
+ resp.code = fp.code
+ if 'msg' in dir(fp):
+ resp.msg = fp.msg
+ return resp
class addinfourldecompress(addinfourl):

View File

@ -1,12 +0,0 @@
diff -ruN BitTorrent-3.4.2/btcompletedir.py BitTorrent.cvs/btcompletedir.py
--- btcompletedir.py Wed Mar 3 14:44:06 2004
+++ btcompletedir.py Sun May 23 04:31:44 2004
@@ -30,6 +30,8 @@
subtotal[0] += x
vc(float(subtotal[0]) / total)
for i in togen:
+ if flag.isSet():
+ break
t = split(i)
if t[1] == '':
i = t[0]

View File

@ -1,61 +0,0 @@
# Written by John Hoffman
# see LICENSE.txt for license information
from httplib import HTTPConnection
from urlparse import urlparse
import socket
from gzip import GzipFile
from StringIO import StringIO
from urllib import quote, unquote
from __init__ import version
MAX_REDIRECTS = 10
class urlopen:
def __init__(self, url):
self.tries = 0
self._open(url)
def _open(self, url):
self.tries += 1
if self.tries > MAX_REDIRECTS:
raise IOError, ('http error', 500,
"Internal Server Error: Redirect Recursion")
(scheme, netloc, path, pars, query, fragment) = urlparse(url)
if scheme != 'http':
raise IOError, ('url error', 'unknown url type', scheme, url)
url = path
if pars:
url += ';'+pars
if query:
url += '?'+query
# if fragment:
self.connection = HTTPConnection(netloc)
self.connection.request('GET', url, None,
{ 'User-Agent': 'BitTorrent/' + version,
'Accept-Encoding': 'gzip' } )
self.response = self.connection.getresponse()
status = self.response.status
if status in (301,302):
try:
self.connection.close()
except:
pass
self._open(self.response.getheader('Location'))
return
if status != 200:
raise IOError, ('http error', status, self.response.reason)
def read(self):
data = self.response.read()
if self.response.getheader('Content-Encoding','').find('gzip') >= 0:
try:
compressed = StringIO(data)
f = GzipFile(fileobj = compressed)
data = f.read()
except:
raise IOError, ('http error', 'got corrupt response')
return data
def close(self):
self.connection.close()

View File

@ -1,10 +1,8 @@
bin/btcompletedir.py
bin/btdownloadcurses.py
bin/btdownloadheadless.py
bin/btdownloadlibrary.py
bin/btlaunchmany.py
bin/btlaunchmanycurses.py
bin/btmakemetafile.py
bin/btmaketorrent.py
bin/btreannounce.py
bin/btrename.py
bin/btshowmetainfo.py
@ -13,30 +11,48 @@ bin/bttrack.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Choker.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Choker.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Choker.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/ClientIdentifier.py
%%PYTHON_SITELIBDIR%%/BitTorrent/ClientIdentifier.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/ClientIdentifier.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Connecter.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Connecter.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Connecter.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/ConvertedMetainfo.py
%%PYTHON_SITELIBDIR%%/BitTorrent/ConvertedMetainfo.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/ConvertedMetainfo.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/CurrentRateMeasure.py
%%PYTHON_SITELIBDIR%%/BitTorrent/CurrentRateMeasure.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/CurrentRateMeasure.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Desktop.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Desktop.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Desktop.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Downloader.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Downloader.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Downloader.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/DownloaderFeedback.py
%%PYTHON_SITELIBDIR%%/BitTorrent/DownloaderFeedback.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/DownloaderFeedback.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Encrypter.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Encrypter.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Encrypter.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Encoder.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Encoder.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Encoder.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/GUI.py
%%PYTHON_SITELIBDIR%%/BitTorrent/GUI.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/GUI.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/HTTPHandler.py
%%PYTHON_SITELIBDIR%%/BitTorrent/HTTPHandler.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/HTTPHandler.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/NatCheck.py
%%PYTHON_SITELIBDIR%%/BitTorrent/NatCheck.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/NatCheck.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/OpenPath.py
%%PYTHON_SITELIBDIR%%/BitTorrent/OpenPath.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/OpenPath.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/PiecePicker.py
%%PYTHON_SITELIBDIR%%/BitTorrent/PiecePicker.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/PiecePicker.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/RateLimiter.py
%%PYTHON_SITELIBDIR%%/BitTorrent/RateLimiter.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/RateLimiter.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/RateMeasure.py
%%PYTHON_SITELIBDIR%%/BitTorrent/RateMeasure.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/RateMeasure.pyo
@ -52,6 +68,9 @@ bin/bttrack.py
%%PYTHON_SITELIBDIR%%/BitTorrent/StorageWrapper.py
%%PYTHON_SITELIBDIR%%/BitTorrent/StorageWrapper.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/StorageWrapper.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/TorrentQueue.py
%%PYTHON_SITELIBDIR%%/BitTorrent/TorrentQueue.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/TorrentQueue.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Uploader.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Uploader.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Uploader.pyo
@ -67,15 +86,33 @@ bin/bttrack.py
%%PYTHON_SITELIBDIR%%/BitTorrent/btformats.py
%%PYTHON_SITELIBDIR%%/BitTorrent/btformats.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/btformats.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/configfile.py
%%PYTHON_SITELIBDIR%%/BitTorrent/configfile.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/configfile.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/controlsocket.py
%%PYTHON_SITELIBDIR%%/BitTorrent/controlsocket.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/controlsocket.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/defaultargs.py
%%PYTHON_SITELIBDIR%%/BitTorrent/defaultargs.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/defaultargs.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/download.py
%%PYTHON_SITELIBDIR%%/BitTorrent/download.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/download.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/fakeopen.py
%%PYTHON_SITELIBDIR%%/BitTorrent/fakeopen.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/fakeopen.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/launchmanycore.py
%%PYTHON_SITELIBDIR%%/BitTorrent/launchmanycore.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/launchmanycore.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/makemetafile.py
%%PYTHON_SITELIBDIR%%/BitTorrent/makemetafile.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/makemetafile.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/obsoletepythonsupport.py
%%PYTHON_SITELIBDIR%%/BitTorrent/obsoletepythonsupport.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/obsoletepythonsupport.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/parseargs.py
%%PYTHON_SITELIBDIR%%/BitTorrent/parseargs.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/parseargs.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/parsedir.py
%%PYTHON_SITELIBDIR%%/BitTorrent/parsedir.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/parsedir.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/selectpoll.py
%%PYTHON_SITELIBDIR%%/BitTorrent/selectpoll.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/selectpoll.pyo
@ -88,6 +125,7 @@ bin/bttrack.py
%%PYTHON_SITELIBDIR%%/BitTorrent/zurllib.py
%%PYTHON_SITELIBDIR%%/BitTorrent/zurllib.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/zurllib.pyo
@unexec rmdir %D/share/pixmaps 2>/dev/null || true
@dirrm %%PYTHON_SITELIBDIR%%/BitTorrent
@unexec rmdir %D/%%PYTHON_SITELIBDIR%% 2>/dev/null || true
@unexec rmdir %D/%%PYTHON_LIBDIR%% 2>/dev/null || true

View File

@ -6,14 +6,11 @@
#
PORTNAME= BitTorrent
PORTVERSION= 3.4.2
PORTREVISION= 5
PORTVERSION= 4.0.0
PORTEPOCH= 1
CATEGORIES?= net python
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE_EXTENDED}
MASTER_SITE_SUBDIR= ${PORTNAME:L}
MASTER_SITES= http://www.bittorrent.com/dl/
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
#DISTNAME= ${PORTNAME}-${PORTVERSION:C/\.(.)$/\1/}
MAINTAINER= lioux@FreeBSD.org
COMMENT?= A peer-to-peer tool for distributing files written in Python
@ -24,9 +21,14 @@ USE_REINPLACE= yes
CONFLICTS= py??-*[Bb]it[Tt]orrent* py??-*[Bb]it[Tt]ornado* btqueue*
PORTDOCS= BUILD.windows.txt INSTALL.unix.txt LICENSE.txt \
PORTDOCS= LICENSE.txt \
redirdonate.html \
README.txt credits.txt
.ifdef(NOPORTDOCS)
EXTRA_PATCHES+= ${FILESDIR}/extra-noportdocs-setup.py
.endif
.include <bsd.port.pre.mk>
.if ${ARCH} != "i386"
@ -35,11 +37,27 @@ WITHOUT_PSYCO= yes
# required for GUI
.ifndef(WITHOUT_GUI)
RUN_DEPENDS+= ${PYTHON_SITELIBDIR}/wxPython/__init__.py:${PORTSDIR}/x11-toolkits/py-wxPython
RUN_DEPENDS+= ${PYTHON_SITELIBDIR}/pygtk.py:${PORTSDIR}/x11-toolkits/py-gtk2
PLIST_FILES+= \
bin/btcompletedirgui.py \
bin/btdownloadgui.py
bin/btmaketorrentgui.py \
bin/btdownloadgui.py \
share/pixmaps/BitTorrent/bittorrent.ico \
share/pixmaps/BitTorrent/broken.png \
share/pixmaps/BitTorrent/finished.png \
share/pixmaps/BitTorrent/info.png \
share/pixmaps/BitTorrent/logo/bittorrent_32.png \
share/pixmaps/BitTorrent/logo/bittorrent_96.png \
share/pixmaps/BitTorrent/pause.png \
share/pixmaps/BitTorrent/paused.png \
share/pixmaps/BitTorrent/play.png \
share/pixmaps/BitTorrent/queued.png \
share/pixmaps/BitTorrent/remove.png \
share/pixmaps/BitTorrent/running.png
PLIST_DIRS+= share/pixmaps/BitTorrent/logo \
share/pixmaps/BitTorrent
.else
EXTRA_PATCHES+= ${FILESDIR}/extra-nogui-patch-setup.py
.endif
@ -48,14 +66,15 @@ EXTRA_PATCHES+= ${FILESDIR}/extra-nogui-patch-setup.py
RUN_DEPENDS+= ${PYTHON_SITELIBDIR}/psyco/_psyco.so:${PORTSDIR}/devel/py-psyco
EXTRA_PATCHES+= \
${FILESDIR}/extra-psyco-patch-btcompletedir.py \
${FILESDIR}/extra-psyco-patch-btcompletedirgui.py \
${FILESDIR}/extra-psyco-patch-btdownloadcurses.py \
${FILESDIR}/extra-psyco-patch-btdownloadgui.py \
${FILESDIR}/extra-psyco-patch-btdownloadheadless.py \
${FILESDIR}/extra-psyco-patch-btlaunchmany.py \
${FILESDIR}/extra-psyco-patch-btlaunchmanycurses.py \
${FILESDIR}/extra-psyco-patch-btmakemetafile.py \
${FILESDIR}/extra-psyco-patch-btmaketorrent.py \
${FILESDIR}/extra-psyco-patch-btreannouce.py \
${FILESDIR}/extra-psyco-patch-btrename.py \
${FILESDIR}/extra-psyco-patch-btshowmetainfo.py \
${FILESDIR}/extra-psyco-patch-bttest.py \
${FILESDIR}/extra-psyco-patch-bttrack.py
PLIST_FILES+= \
@ -76,28 +95,29 @@ post-patch:
@${FIND} ${WRKSRC} -type f | \
${XARGS} -x -n 10 \
${REINPLACE_CMD} -E \
-e 's|/usr/bin/env python2|${LOCALBASE}/bin/python|'
.ifdef(WITHOUT_GUI)
@${REINPLACE_CMD} -E \
-e 's|btdownloadgui.py|btdownloadcurses.py|' \
${WRKSRC}/INSTALL.unix.txt
.endif
-e 's|/usr/bin/env python.*|${LOCALBASE}/bin/python|'
.ifndef(WITHOUT_PSYCO)
# activate psyco optimization
@${ECHO_CMD} 'psyco = 1' > ${WRKSRC}/BitTorrent/PSYCO.py
.endif
post-install:
.ifndef(NOPORTDOCS)
@${MKDIR} ${DOCSDIR}
.for file in ${PORTDOCS}
@${INSTALL_DATA} ${WRKSRC}/${file} ${DOCSDIR}
.endfor
.endif
# set proper permissions
@${CHMOD} -R ${SHAREMODE} \
${PREFIX}/${PYTHON_SITELIBDIR:S|^${PYTHONBASE}/||}/BitTorrent
@${CHMOD} ${SHAREMODE} ${PREFIX}/${PYTHON_SITELIBDIR:S|^${PYTHONBASE}/||}/BitTorrent
@${CHMOD} a+x ${PREFIX}/${PYTHON_SITELIBDIR:S|^${PYTHONBASE}/||}/BitTorrent
.ifndef(WITHOUT_GUI)
# pixmaps
@${CHMOD} -R ${SHAREMODE} \
${PREFIX}/share/pixmaps/${PORTNAME}/*
@${CHMOD} a+x \
${PREFIX}/share/pixmaps/${PORTNAME}/logo
.endif
.ifndef(NOPORTDOCS)
# docs
@${CHMOD} -R ${SHAREMODE} \
${DOCSDIR}/*
.endif
.include <bsd.port.post.mk>

View File

@ -1,2 +1,2 @@
MD5 (BitTorrent-3.4.2.tar.gz) = b854f25a33289565bcaeaded04955c1a
SIZE (BitTorrent-3.4.2.tar.gz) = 198026
MD5 (BitTorrent-4.0.0.tar.gz) = 67f449df351b66f408b72b6bd196952f
SIZE (BitTorrent-4.0.0.tar.gz) = 148649

View File

@ -1,14 +1,20 @@
--- setup.py.orig Sun Mar 30 17:01:05 2003
+++ setup.py Sun Mar 30 17:01:20 2003
@@ -18,9 +18,9 @@
packages = ["BitTorrent"],
--- setup.py.orig Sat Mar 12 10:01:45 2005
+++ setup.py Sat Mar 12 10:14:21 2005
@@ -19,9 +19,9 @@
- scripts = ["btdownloadgui.py", "btdownloadheadless.py", "btdownloadlibrary.py",
+ scripts = ["btdownloadheadless.py", "btdownloadlibrary.py",
"bttrack.py", "btmakemetafile.py", "btlaunchmany.py", "btcompletedir.py",
- "btdownloadcurses.py", "btcompletedirgui.py", "btlaunchmanycurses.py",
+ "btdownloadcurses.py", "btlaunchmanycurses.py",
"btmakemetafile.py", "btreannounce.py", "btrename.py", "btshowmetainfo.py",
"bttest.py"]
)
import glob
-scripts = ["btdownloadgui.py", "btdownloadcurses.py", "btdownloadheadless.py",
- "btmaketorrentgui.py", "btmaketorrent.py",
+scripts = ["btdownloadcurses.py", "btdownloadheadless.py",
+ "btmaketorrent.py",
"btlaunchmany.py", "btlaunchmanycurses.py",
"bttrack.py", "btreannounce.py", "btrename.py", "btshowmetainfo.py",
"bttest.py"]
@@ -28,4 +28,3 @@
img_root, doc_root = BitTorrent.calc_unix_dirs()
-data_files = [ (img_root , glob.glob('images/*png')+['images/bittorrent.ico',]),
- (img_root+'/logo', glob.glob('images/logo/bittorrent_[0-9]*.png') ),
+data_files = [

View File

@ -0,0 +1,8 @@
--- setup.py.bak Mon Mar 7 00:55:50 2005
+++ setup.py Fri Mar 11 22:55:38 2005
@@ -31,5 +31,3 @@
- (doc_root , ['credits.txt', 'LICENSE.txt',
- 'README.txt', 'redirdonate.html'] ),
]
setup(

View File

@ -0,0 +1,18 @@
--- BitTorrent/launchmanycore.py.orig Sat Mar 12 10:00:19 2005
+++ BitTorrent/launchmanycore.py Sat Mar 12 10:00:40 2005
@@ -13,6 +13,15 @@
# Original version written by John Hoffman, heavily modified for different
# multitorrent architecture by Uoti Urpala (over 40% shorter than original)
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
import os
from cStringIO import StringIO
from traceback import print_exc

View File

@ -0,0 +1,18 @@
--- BitTorrent/makemetafile.py.orig Sat Mar 12 09:58:42 2005
+++ BitTorrent/makemetafile.py Sat Mar 12 09:59:06 2005
@@ -12,6 +12,15 @@
# Written by Bram Cohen
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from __future__ import division
import os

View File

@ -1,18 +0,0 @@
--- btcompletedir.py Thu Dec 16 11:03:11 2004
+++ btcompletedir.py Thu Dec 16 11:12:55 2004
@@ -3,6 +3,15 @@
# Written by Bram Cohen
# see LICENSE.txt for license information
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from os.path import join, split
from threading import Event
from traceback import print_exc

View File

@ -1,18 +0,0 @@
--- btcompletedirgui.py Thu Dec 16 11:03:11 2004
+++ btcompletedirgui.py Thu Dec 16 11:13:34 2004
@@ -3,6 +3,15 @@
# Written by Bram Cohen
# see LICENSE.txt for license information
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import argv, version
from btcompletedir import completedir

View File

@ -1,18 +1,18 @@
--- btdownloadcurses.py Thu Dec 16 11:03:11 2004
+++ btdownloadcurses.py Thu Dec 16 11:13:54 2004
@@ -3,6 +3,15 @@
# Written by Henry 'Pi' James
# see LICENSE.txt for license information
--- btdownloadcurses.py.orig Fri Mar 11 23:12:10 2005
+++ btdownloadcurses.py Fri Mar 11 23:13:08 2005
@@ -15,6 +15,15 @@
from __future__ import division
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+ pass
+
from BitTorrent.download import download
from threading import Event
from os.path import abspath
SPEW_SCROLL_RATE = 1
import sys

View File

@ -1,18 +0,0 @@
--- btdownloadgui.py Thu Dec 16 11:03:11 2004
+++ btdownloadgui.py Thu Dec 16 11:14:07 2004
@@ -3,6 +3,15 @@
# Written by Bram Cohen and Myers Carpenter
# see LICENSE.txt for license information
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import argv
from BitTorrent import version
from BitTorrent.download import download

View File

@ -1,18 +1,18 @@
--- btdownloadheadless.py Thu Dec 16 11:03:11 2004
+++ btdownloadheadless.py Thu Dec 16 11:14:16 2004
@@ -3,6 +3,15 @@
# Written by Bram Cohen
# see LICENSE.txt for license information
--- btdownloadheadless.py.orig Fri Mar 11 23:14:21 2005
+++ btdownloadheadless.py Fri Mar 11 23:14:28 2005
@@ -14,6 +14,15 @@
from __future__ import division
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+ pass
+
from BitTorrent.download import download
from threading import Event
from os.path import abspath
import sys
import os
import threading

View File

@ -1,18 +1,18 @@
--- btlaunchmany.py Thu Dec 16 11:03:11 2004
+++ btlaunchmany.py Thu Dec 16 11:14:54 2004
@@ -7,6 +7,15 @@
# fmttime and fmtsize stolen from btdownloadcurses.
# see LICENSE.txt for license information
--- btlaunchmany.py.orig Fri Mar 11 23:14:47 2005
+++ btlaunchmany.py Fri Mar 11 23:14:54 2005
@@ -12,6 +12,15 @@
# Written by John Hoffman
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+ pass
+
from BitTorrent.download import download
from threading import Thread, Event, Lock
from os import listdir
import sys
import os

View File

@ -1,18 +1,18 @@
--- btlaunchmanycurses.py Thu Dec 16 11:03:11 2004
+++ btlaunchmanycurses.py Thu Dec 16 11:14:47 2004
@@ -7,6 +7,15 @@
# fmttime and fmtsize stolen from btdownloadcurses.
# see LICENSE.txt for license information
--- btlaunchmanycurses.py.orig Fri Mar 11 23:15:15 2005
+++ btlaunchmanycurses.py Fri Mar 11 23:15:22 2005
@@ -14,6 +14,15 @@
from __future__ import division
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+ pass
+
from BitTorrent.download import download
from threading import Thread, Event, Lock
from os import listdir
DOWNLOAD_SCROLL_RATE = 1
import sys, os

View File

@ -1,18 +0,0 @@
--- btmakemetafile.py Thu Dec 16 11:03:11 2004
+++ btmakemetafile.py Thu Dec 16 11:15:10 2004
@@ -3,6 +3,15 @@
# Written by Bram Cohen
# see LICENSE.txt for license information
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import argv
from os.path import getsize, split, join, abspath, isdir
from os import listdir

View File

@ -0,0 +1,18 @@
--- btmaketorrent.py.orig Fri Mar 11 23:15:38 2005
+++ btmaketorrent.py Fri Mar 11 23:15:43 2005
@@ -12,6 +12,15 @@
# Written by Bram Cohen
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
import sys
from BitTorrent.makemetafile import make_meta_files
from BitTorrent.parseargs import parseargs, printHelp

View File

@ -0,0 +1,18 @@
--- btreannounce.py.orig Fri Mar 11 23:15:59 2005
+++ btreannounce.py Fri Mar 11 23:16:05 2005
@@ -12,6 +12,15 @@
# Written by Henry 'Pi' James and Bram Cohen
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import argv
from BitTorrent.bencode import bencode, bdecode

View File

@ -0,0 +1,18 @@
--- btrename.py.orig Fri Mar 11 23:16:21 2005
+++ btrename.py Fri Mar 11 23:16:28 2005
@@ -12,6 +12,15 @@
# Written by Henry 'Pi' James
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import *
from os.path import *
from sha import *

View File

@ -0,0 +1,18 @@
--- btshowmetainfo.py.orig Fri Mar 11 23:16:39 2005
+++ btshowmetainfo.py Fri Mar 11 23:16:48 2005
@@ -12,6 +12,15 @@
# Written by Henry 'Pi' James and Loring Holden
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from sys import *
from os.path import *
from sha import *

View File

@ -0,0 +1,18 @@
--- bttest.py.orig Fri Mar 11 23:17:05 2005
+++ bttest.py Fri Mar 11 23:17:12 2005
@@ -12,6 +12,15 @@
# Written by Bram Cohen
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+
from BitTorrent import testtest
import bttrack
import btmakemetafile

View File

@ -1,17 +1,17 @@
--- bttrack.py Thu Dec 16 11:03:11 2004
+++ bttrack.py Thu Dec 16 11:15:33 2004
@@ -3,6 +3,15 @@
--- bttrack.py.orig Fri Mar 11 23:17:26 2005
+++ bttrack.py Fri Mar 11 23:17:31 2005
@@ -12,6 +12,15 @@
# Written by Bram Cohen
# see LICENSE.txt for license information
+from BitTorrent import PSYCO
+if PSYCO.psyco:
+ try:
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ import psyco
+ assert psyco.__version__ >= 0x010300f0
+ psyco.full()
+ except:
+ pass
+ pass
+
from sys import argv
from BitTorrent.track import track

View File

@ -1,30 +0,0 @@
--- BitTorrent/Rerequester.py Sat Apr 3 01:10:23 2004
+++ BitTorrent/Rerequester.py Sun Apr 18 17:03:33 2004
@@ -5,7 +5,7 @@
from btformats import check_peers
from bencode import bdecode
from threading import Thread, Lock
-from socket import error
+from socket import error, gethostbyname
from time import time
from random import randrange
from binascii import b2a_hex
@@ -18,8 +18,7 @@
self.url = ('%s?info_hash=%s&peer_id=%s&port=%s&key=%s' %
(url, quote(infohash), quote(myid), str(port),
b2a_hex(''.join([chr(randrange(256)) for i in xrange(4)]))))
- if ip != '':
- self.url += '&ip=' + quote(ip)
+ self.ip = ip
self.interval = interval
self.last = None
self.trackerid = None
@@ -81,6 +80,8 @@
def rerequest(self, url, set):
try:
+ if self.ip:
+ url += '&ip=' + gethostbyname(self.ip)
h = urlopen(url)
r = h.read()
h.close()

View File

@ -0,0 +1,11 @@
--- BitTorrent/__init__.py.orig Fri Mar 11 22:53:12 2005
+++ BitTorrent/__init__.py Fri Mar 11 22:53:27 2005
@@ -21,7 +21,7 @@
import os
def calc_unix_dirs():
- appdir = '%s-%s'%(app_name, version)
+ appdir = '%s'%(app_name)
ip = os.path.join('share', 'pixmaps', appdir)
dp = os.path.join('share', 'doc' , appdir)
return ip, dp

View File

@ -0,0 +1,11 @@
--- BitTorrent/defaultargs.py.orig Sun Dec 26 08:41:09 2004
+++ BitTorrent/defaultargs.py Sun Dec 26 08:41:16 2004
@@ -83,7 +83,7 @@
'if nonzero, set the TOS option for peer connections to this value'),
('filesystem_encoding', '',
"character encoding used on the local filesystem. If left empty, autodetected. Autodetection doesn't work under python versions older than 2.3"),
- ('enable_bad_libc_workaround', 0,
+ ('enable_bad_libc_workaround', 1,
'enable workaround for a bug in BSD libc that makes file reads very slow.'),
]

View File

@ -1,300 +0,0 @@
--- BitTorrent/track.py Sun Mar 21 16:32:55 2004
+++ BitTorrent/track.py Sun Jun 6 09:33:07 2004
@@ -37,12 +37,15 @@
'minimum time it must have been since the last flush to do another one'),
('allowed_dir', '', 'only allow downloads for .torrents in this dir'),
('parse_allowed_interval', 15, 'minutes between reloading of allowed_dir'),
+ ('show_infopage', 1, "whether to display an info page when the tracker's root dir is loaded"),
+ ('infopage_redirect', '', 'a URL to redirect the info page to'),
('show_names', 1, 'whether to display names from allowed dir'),
('favicon', '', 'file containing x-icon data to return when browser requests favicon.ico'),
('only_local_override_ip', 1, "ignore the ip GET parameter from machines which aren't on local network IPs"),
('logfile', '', 'file to write the tracker logs, use - for stdout (default)'),
('allow_get', 0, 'use with allowed_dir; adds a /file?hash={hash} url that allows users to download the torrent file'),
('keep_dead', 0, 'keep dead torrents after they expire (so they still show up on your /scrape and web page)'),
+ ('scrape_allowed', 'full', 'scrape access allowed (can be none, specific or full)'),
('max_give', 200, 'maximum number of peers to give with any one request'),
]
@@ -124,11 +127,11 @@
favicon = config['favicon']
self.favicon = None
if favicon:
- if isfile(favicon):
+ try:
h = open(favicon, 'rb')
self.favicon = h.read()
h.close()
- else:
+ except:
print "**warning** specified favicon file -- %s -- does not exist." % favicon
self.rawserver = rawserver
self.becache1 = {}
@@ -190,6 +193,130 @@
self.uq_broken = 0
self.keep_dead = config['keep_dead']
+ def get_infopage(self):
+ if not self.config['show_infopage']:
+ return (404, 'Not Found', {'Content-Type': 'text/plain', 'Pragma': 'no-cache'}, alas)
+ red = self.config['infopage_redirect']
+ if red != '':
+ return (302, 'Found', {'Content-Type': 'text/html', 'Location': red},
+ '<A HREF="'+red+'">Click Here</A>')
+
+ s = StringIO()
+ s.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n' \
+ '<html><head><title>BitTorrent download info</title>\n')
+ if self.favicon != None:
+ s.write('<link rel="shortcut icon" href="/favicon.ico" />\n')
+ s.write('</head>\n<body>\n' \
+ '<h3>BitTorrent download info</h3>\n'\
+ '<ul>\n'
+ '<li><strong>tracker version:</strong> %s</li>\n' \
+ '<li><strong>server time:</strong> %s</li>\n' \
+ '</ul>\n' % (version, isotime()))
+ names = self.downloads.keys()
+ if not names:
+ s.write('<p>not tracking any files yet...</p>\n')
+ else:
+ names.sort()
+ tn = 0
+ tc = 0
+ td = 0
+ tt = 0 # Total transferred
+ ts = 0 # Total size
+ nf = 0 # Number of files displayed
+ uc = {}
+ ud = {}
+ if self.allowed != None and self.show_names:
+ s.write('<table summary="files" border="1">\n' \
+ '<tr><th>info hash</th><th>torrent name</th><th align="right">size</th><th align="right">complete</th><th align="right">downloading</th><th align="right">downloaded</th><th align="right">transferred</th></tr>\n')
+ else:
+ s.write('<table summary="files">\n' \
+ '<tr><th>info hash</th><th align="right">complete</th><th align="right">downloading</th><th align="right">downloaded</th></tr>\n')
+ for name in names:
+ l = self.downloads[name]
+ n = self.completed.get(name, 0)
+ tn = tn + n
+ lc = []
+ for i in l.values():
+ if type(i) == DictType:
+ if i['left'] == 0:
+ lc.append(1)
+ uc[i['ip']] = 1
+ else:
+ ud[i['ip']] = 1
+ c = len(lc)
+ tc = tc + c
+ d = len(l) - c
+ td = td + d
+ if self.allowed != None and self.show_names:
+ if self.allowed.has_key(name):
+ nf = nf + 1
+ sz = self.allowed[name]['length'] # size
+ ts = ts + sz
+ szt = sz * n # Transferred for this torrent
+ tt = tt + szt
+ if self.allow_get == 1:
+ linkname = '<a href="/file?info_hash=' + quote(name) + '">' + self.allowed[name]['name'] + '</a>'
+ else:
+ linkname = self.allowed[name]['name']
+ s.write('<tr><td><code>%s</code></td><td>%s</td><td align="right">%s</td><td align="right">%i</td><td align="right">%i</td><td align="right">%i</td><td align="right">%s</td></tr>\n' \
+ % (b2a_hex(name), linkname, size_format(sz), c, d, n, size_format(szt)))
+ else:
+ s.write('<tr><td><code>%s</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td></tr>\n' \
+ % (b2a_hex(name), c, d, n))
+ ttn = 0
+ for i in self.completed.values():
+ ttn = ttn + i
+ if self.allowed != None and self.show_names:
+ s.write('<tr><td align="right" colspan="2">%i files</td><td align="right">%s</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%s</td></tr>\n'
+ % (nf, size_format(ts), len(uc), tc, len(ud), td, tn, ttn, size_format(tt)))
+ else:
+ s.write('<tr><td align="right">%i files</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%i/%i</td></tr>\n'
+ % (nf, len(uc), tc, len(ud), td, tn, ttn))
+ s.write('</table>\n' \
+ '<ul>\n' \
+ '<li><em>info hash:</em> SHA1 hash of the "info" section of the metainfo (*.torrent)</li>\n' \
+ '<li><em>complete:</em> number of connected clients with the complete file (total: unique IPs/total connections)</li>\n' \
+ '<li><em>downloading:</em> number of connected clients still downloading (total: unique IPs/total connections)</li>\n' \
+ '<li><em>downloaded:</em> reported complete downloads (total: current/all)</li>\n' \
+ '<li><em>transferred:</em> torrent size * total downloaded (does not include partial transfers)</li>\n' \
+ '</ul>\n')
+ s.write('</body>\n' \
+ '</html>\n')
+ return (200, 'OK', {'Content-Type': 'text/html; charset=iso-8859-1'}, s.getvalue())
+
+ def scrapedata(self, name, return_name = True):
+ l = self.downloads[name]
+ n = self.completed.get(name, 0)
+ c = len([1 for i in l.values() if i['left'] == 0])
+ d = len(l) - c
+ f = {'complete': c, 'incomplete': d, 'downloaded': n}
+ if ( return_name and self.show_names
+ and self.allowed is not None and self.allowed.has_key(name) ):
+ f['name'] = self.allowed[name]['name']
+ return (f)
+
+ def get_scrape(self, paramslist):
+ fs = {}
+ if paramslist.has_key('info_hash'):
+ if self.config['scrape_allowed'] not in ['specific', 'full']:
+ return (400, 'Not Authorized', {'Content-Type': 'text/plain', 'Pragma': 'no-cache'},
+ bencode({'failure reason':
+ 'specific scrape function is not available with this tracker.'}))
+ for infohash in paramslist['info_hash']:
+ if infohash in self.downloads.keys():
+ fs[infohash] = self.scrapedata(infohash)
+ else:
+ if self.config['scrape_allowed'] != 'full':
+ return (400, 'Not Authorized', {'Content-Type': 'text/plain', 'Pragma': 'no-cache'},
+ bencode({'failure reason':
+ 'full scrape function is not available with this tracker.'}))
+ names = self.downloads.keys()
+ names.sort()
+ for name in names:
+ fs[name] = self.scrapedata(name)
+
+ return (200, 'OK', {'Content-Type': 'text/plain'}, bencode({'files': fs}))
+
def get(self, connection, path, headers):
try:
(scheme, netloc, path, pars, query, fragment) = urlparse(path)
@@ -197,117 +324,22 @@
path = path.replace('+',' ')
query = query.replace('+',' ')
path = unquote(path)[1:]
+ paramslist = {}
params = {}
for s in query.split('&'):
if s != '':
i = s.index('=')
- params[unquote(s[:i])] = unquote(s[i+1:])
+ kw = unquote(s[:i])
+ key, value = unquote(s[:i]), unquote(s[i+1:])
+ paramslist.setdefault(key, []).append(value)
+ params[key] = value
except ValueError, e:
return (400, 'Bad Request', {'Content-Type': 'text/plain'},
'you sent me garbage - ' + str(e))
if path == '' or path == 'index.html':
- s = StringIO()
- s.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n' \
- '<html><head><title>BitTorrent download info</title>\n')
- if self.favicon != None:
- s.write('<link rel="shortcut icon" href="/favicon.ico" />\n')
- s.write('</head>\n<body>\n' \
- '<h3>BitTorrent download info</h3>\n'\
- '<ul>\n'
- '<li><strong>tracker version:</strong> %s</li>\n' \
- '<li><strong>server time:</strong> %s</li>\n' \
- '</ul>\n' % (version, isotime()))
- names = self.downloads.keys()
- if names:
- names.sort()
- tn = 0
- tc = 0
- td = 0
- tt = 0 # Total transferred
- ts = 0 # Total size
- nf = 0 # Number of files displayed
- uc = {}
- ud = {}
- if self.allowed != None and self.show_names:
- s.write('<table summary="files" border="1">\n' \
- '<tr><th>info hash</th><th>torrent name</th><th align="right">size</th><th align="right">complete</th><th align="right">downloading</th><th align="right">downloaded</th><th align="right">transferred</th></tr>\n')
- else:
- s.write('<table summary="files">\n' \
- '<tr><th>info hash</th><th align="right">complete</th><th align="right">downloading</th><th align="right">downloaded</th></tr>\n')
- for name in names:
- l = self.downloads[name]
- n = self.completed.get(name, 0)
- tn = tn + n
- lc = []
- for i in l.values():
- if type(i) == DictType:
- if i['left'] == 0:
- lc.append(1)
- uc[i['ip']] = 1
- else:
- ud[i['ip']] = 1
- c = len(lc)
- tc = tc + c
- d = len(l) - c
- td = td + d
- if self.allowed != None and self.show_names:
- if self.allowed.has_key(name):
- nf = nf + 1
- sz = self.allowed[name]['length'] # size
- ts = ts + sz
- szt = sz * n # Transferred for this torrent
- tt = tt + szt
- if self.allow_get == 1:
- linkname = '<a href="/file?info_hash=' + quote(name) + '">' + self.allowed[name]['name'] + '</a>'
- else:
- linkname = self.allowed[name]['name']
- s.write('<tr><td><code>%s</code></td><td>%s</td><td align="right">%s</td><td align="right">%i</td><td align="right">%i</td><td align="right">%i</td><td align="right">%s</td></tr>\n' \
- % (b2a_hex(name), linkname, size_format(sz), c, d, n, size_format(szt)))
- else:
- s.write('<tr><td><code>%s</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td><td align="right"><code>%i</code></td></tr>\n' \
- % (b2a_hex(name), c, d, n))
- ttn = 0
- for i in self.completed.values():
- ttn = ttn + i
- if self.allowed != None and self.show_names:
- s.write('<tr><td align="right" colspan="2">%i files</td><td align="right">%s</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%s</td></tr>\n'
- % (nf, size_format(ts), len(uc), tc, len(ud), td, tn, ttn, size_format(tt)))
- else:
- s.write('<tr><td align="right">%i files</td><td align="right">%i/%i</td><td align="right">%i/%i</td><td align="right">%i/%i</td></tr>\n'
- % (nf, len(uc), tc, len(ud), td, tn, ttn))
- s.write('</table>\n' \
- '<ul>\n' \
- '<li><em>info hash:</em> SHA1 hash of the "info" section of the metainfo (*.torrent)</li>\n' \
- '<li><em>complete:</em> number of connected clients with the complete file (total: unique IPs/total connections)</li>\n' \
- '<li><em>downloading:</em> number of connected clients still downloading (total: unique IPs/total connections)</li>\n' \
- '<li><em>downloaded:</em> reported complete downloads (total: current/all)</li>\n' \
- '<li><em>transferred:</em> torrent size * total downloaded (does not include partial transfers)</li>\n' \
- '</ul>\n')
- else:
- s.write('<p>not tracking any files yet...</p>\n')
- s.write('</body>\n' \
- '</html>\n')
- return (200, 'OK', {'Content-Type': 'text/html; charset=iso-8859-1'}, s.getvalue())
+ return self.get_infopage()
elif path == 'scrape':
- fs = {}
- names = []
- if params.has_key('info_hash'):
- if self.downloads.has_key(params['info_hash']):
- names = [ params['info_hash'] ]
- # else return nothing
- else:
- names = self.downloads.keys()
- names.sort()
- for name in names:
- l = self.downloads[name]
- n = self.completed.get(name, 0)
- c = len([1 for i in l.values() if type(i) == DictType and i['left'] == 0])
- d = len(l) - c
- fs[name] = {'complete': c, 'incomplete': d, 'downloaded': n}
- if (self.allowed is not None) and self.allowed.has_key(name) and self.show_names:
- fs[name]['name'] = self.allowed[name]['name']
- r = {'files': fs}
- return (200, 'OK', {'Content-Type': 'text/plain'}, bencode(r))
+ return self.get_scrape(paramslist)
elif (path == 'file') and (self.allow_get == 1) and params.has_key('info_hash') and self.allowed.has_key(params['info_hash']):
hash = params['info_hash']
fname = self.allowed[hash]['file']
@@ -506,9 +538,9 @@
r = str(s) + 'B'
elif (s < 1048576):
r = str(int(s/1024)) + 'KiB'
- elif (s < 1073741824l):
+ elif (s < 1073741824L):
r = str(int(s/1048576)) + 'MiB'
- elif (s < 1099511627776l):
+ elif (s < 1099511627776L):
r = str(int((s/1073741824.0)*100.0)/100.0) + 'GiB'
else:
r = str(int((s/1099511627776.0)*100.0)/100.0) + 'TiB'

View File

@ -1,18 +0,0 @@
--- BitTorrent/zurllib.py.orig Thu Dec 9 10:36:43 2004
+++ BitTorrent/zurllib.py Thu Dec 9 10:38:19 2004
@@ -35,7 +35,14 @@
if DEBUG:
pprint.pprint(headers.dict)
url = fp.url
- return addinfourldecompress(fp, headers, url)
+ resp = addinfourldecompress(fp, headers, url)
+ # As of Python 2.4 http_open response also has 'code' and 'msg'
+ # members, and HTTPErrorProcessor breaks if they don't exist.
+ if 'code' in dir(fp):
+ resp.code = fp.code
+ if 'msg' in dir(fp):
+ resp.msg = fp.msg
+ return resp
class addinfourldecompress(addinfourl):

View File

@ -1,12 +0,0 @@
diff -ruN BitTorrent-3.4.2/btcompletedir.py BitTorrent.cvs/btcompletedir.py
--- btcompletedir.py Wed Mar 3 14:44:06 2004
+++ btcompletedir.py Sun May 23 04:31:44 2004
@@ -30,6 +30,8 @@
subtotal[0] += x
vc(float(subtotal[0]) / total)
for i in togen:
+ if flag.isSet():
+ break
t = split(i)
if t[1] == '':
i = t[0]

View File

@ -1,61 +0,0 @@
# Written by John Hoffman
# see LICENSE.txt for license information
from httplib import HTTPConnection
from urlparse import urlparse
import socket
from gzip import GzipFile
from StringIO import StringIO
from urllib import quote, unquote
from __init__ import version
MAX_REDIRECTS = 10
class urlopen:
def __init__(self, url):
self.tries = 0
self._open(url)
def _open(self, url):
self.tries += 1
if self.tries > MAX_REDIRECTS:
raise IOError, ('http error', 500,
"Internal Server Error: Redirect Recursion")
(scheme, netloc, path, pars, query, fragment) = urlparse(url)
if scheme != 'http':
raise IOError, ('url error', 'unknown url type', scheme, url)
url = path
if pars:
url += ';'+pars
if query:
url += '?'+query
# if fragment:
self.connection = HTTPConnection(netloc)
self.connection.request('GET', url, None,
{ 'User-Agent': 'BitTorrent/' + version,
'Accept-Encoding': 'gzip' } )
self.response = self.connection.getresponse()
status = self.response.status
if status in (301,302):
try:
self.connection.close()
except:
pass
self._open(self.response.getheader('Location'))
return
if status != 200:
raise IOError, ('http error', status, self.response.reason)
def read(self):
data = self.response.read()
if self.response.getheader('Content-Encoding','').find('gzip') >= 0:
try:
compressed = StringIO(data)
f = GzipFile(fileobj = compressed)
data = f.read()
except:
raise IOError, ('http error', 'got corrupt response')
return data
def close(self):
self.connection.close()

View File

@ -1,10 +1,8 @@
bin/btcompletedir.py
bin/btdownloadcurses.py
bin/btdownloadheadless.py
bin/btdownloadlibrary.py
bin/btlaunchmany.py
bin/btlaunchmanycurses.py
bin/btmakemetafile.py
bin/btmaketorrent.py
bin/btreannounce.py
bin/btrename.py
bin/btshowmetainfo.py
@ -13,30 +11,48 @@ bin/bttrack.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Choker.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Choker.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Choker.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/ClientIdentifier.py
%%PYTHON_SITELIBDIR%%/BitTorrent/ClientIdentifier.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/ClientIdentifier.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Connecter.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Connecter.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Connecter.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/ConvertedMetainfo.py
%%PYTHON_SITELIBDIR%%/BitTorrent/ConvertedMetainfo.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/ConvertedMetainfo.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/CurrentRateMeasure.py
%%PYTHON_SITELIBDIR%%/BitTorrent/CurrentRateMeasure.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/CurrentRateMeasure.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Desktop.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Desktop.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Desktop.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Downloader.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Downloader.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Downloader.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/DownloaderFeedback.py
%%PYTHON_SITELIBDIR%%/BitTorrent/DownloaderFeedback.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/DownloaderFeedback.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Encrypter.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Encrypter.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Encrypter.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Encoder.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Encoder.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Encoder.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/GUI.py
%%PYTHON_SITELIBDIR%%/BitTorrent/GUI.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/GUI.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/HTTPHandler.py
%%PYTHON_SITELIBDIR%%/BitTorrent/HTTPHandler.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/HTTPHandler.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/NatCheck.py
%%PYTHON_SITELIBDIR%%/BitTorrent/NatCheck.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/NatCheck.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/OpenPath.py
%%PYTHON_SITELIBDIR%%/BitTorrent/OpenPath.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/OpenPath.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/PiecePicker.py
%%PYTHON_SITELIBDIR%%/BitTorrent/PiecePicker.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/PiecePicker.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/RateLimiter.py
%%PYTHON_SITELIBDIR%%/BitTorrent/RateLimiter.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/RateLimiter.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/RateMeasure.py
%%PYTHON_SITELIBDIR%%/BitTorrent/RateMeasure.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/RateMeasure.pyo
@ -52,6 +68,9 @@ bin/bttrack.py
%%PYTHON_SITELIBDIR%%/BitTorrent/StorageWrapper.py
%%PYTHON_SITELIBDIR%%/BitTorrent/StorageWrapper.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/StorageWrapper.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/TorrentQueue.py
%%PYTHON_SITELIBDIR%%/BitTorrent/TorrentQueue.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/TorrentQueue.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/Uploader.py
%%PYTHON_SITELIBDIR%%/BitTorrent/Uploader.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/Uploader.pyo
@ -67,15 +86,33 @@ bin/bttrack.py
%%PYTHON_SITELIBDIR%%/BitTorrent/btformats.py
%%PYTHON_SITELIBDIR%%/BitTorrent/btformats.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/btformats.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/configfile.py
%%PYTHON_SITELIBDIR%%/BitTorrent/configfile.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/configfile.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/controlsocket.py
%%PYTHON_SITELIBDIR%%/BitTorrent/controlsocket.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/controlsocket.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/defaultargs.py
%%PYTHON_SITELIBDIR%%/BitTorrent/defaultargs.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/defaultargs.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/download.py
%%PYTHON_SITELIBDIR%%/BitTorrent/download.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/download.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/fakeopen.py
%%PYTHON_SITELIBDIR%%/BitTorrent/fakeopen.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/fakeopen.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/launchmanycore.py
%%PYTHON_SITELIBDIR%%/BitTorrent/launchmanycore.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/launchmanycore.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/makemetafile.py
%%PYTHON_SITELIBDIR%%/BitTorrent/makemetafile.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/makemetafile.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/obsoletepythonsupport.py
%%PYTHON_SITELIBDIR%%/BitTorrent/obsoletepythonsupport.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/obsoletepythonsupport.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/parseargs.py
%%PYTHON_SITELIBDIR%%/BitTorrent/parseargs.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/parseargs.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/parsedir.py
%%PYTHON_SITELIBDIR%%/BitTorrent/parsedir.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/parsedir.pyo
%%PYTHON_SITELIBDIR%%/BitTorrent/selectpoll.py
%%PYTHON_SITELIBDIR%%/BitTorrent/selectpoll.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/selectpoll.pyo
@ -88,6 +125,7 @@ bin/bttrack.py
%%PYTHON_SITELIBDIR%%/BitTorrent/zurllib.py
%%PYTHON_SITELIBDIR%%/BitTorrent/zurllib.pyc
%%PYTHON_SITELIBDIR%%/BitTorrent/zurllib.pyo
@unexec rmdir %D/share/pixmaps 2>/dev/null || true
@dirrm %%PYTHON_SITELIBDIR%%/BitTorrent
@unexec rmdir %D/%%PYTHON_SITELIBDIR%% 2>/dev/null || true
@unexec rmdir %D/%%PYTHON_LIBDIR%% 2>/dev/null || true