r341 - in /debtorrent/trunk: DebTorrent/BT1/Rerequester.py DebTorrent/BT1/track.py DebTorrent/download_bt1.py TODO debian/changelog test.py

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Wed Jan 23 00:16:37 UTC 2008


Author: camrdale-guest
Date: Wed Jan 23 00:16:36 2008
New Revision: 341

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=341
Log:
Add torrent names to the tracker display

Modified:
    debtorrent/trunk/DebTorrent/BT1/Rerequester.py
    debtorrent/trunk/DebTorrent/BT1/track.py
    debtorrent/trunk/DebTorrent/download_bt1.py
    debtorrent/trunk/TODO
    debtorrent/trunk/debian/changelog
    debtorrent/trunk/test.py

Modified: debtorrent/trunk/DebTorrent/BT1/Rerequester.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/Rerequester.py?rev=341&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/Rerequester.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/Rerequester.py Wed Jan 23 00:16:36 2008
@@ -178,7 +178,7 @@
                   sched, externalsched, errorfunc, connect,
                   howmany, amount_left, up, down, upratefunc, downratefunc,
                   doneflag, unpauseflag = fakeflag(True),
-                  seededfunc = None, force_rapid_update = False ):
+                  seededfunc = None, force_rapid_update = False, name = ''):
         """Initialize the instance.
         
         @type port: C{int}
@@ -222,6 +222,9 @@
         @type force_rapid_update: C{boolean}
         @param force_rapid_update: whether to do quick tracker updates when 
             requested (optional, defaults to False)
+        @type name: C{string}
+        @param name: the name of the torrent to send to the tracker
+            (optional, defaults to not sending anything)
         
         """
 
@@ -277,6 +280,8 @@
             self.url += '&seed_id='+quote(seed_id)
         if self.seededfunc:
             self.url += '&check_seeded=1'
+        if name:
+            self.url += '&name='+quote(name)
 
         self.last = None
         self.trackerid = None

Modified: debtorrent/trunk/DebTorrent/BT1/track.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/track.py?rev=341&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/track.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/track.py Wed Jan 23 00:16:36 2008
@@ -282,6 +282,36 @@
     except:
         s = ''  # not a valid IP, must be a domain name
     return s
+
+def clean_name(name):
+    """Clean up the name of the torrent to remove mirror info.
+    
+    @type name: C{string}
+    @param name: the torrent name
+    @rtype: C{string}
+    @return: the cleaned name
+    
+    """
+    
+    if not name:
+        return ''
+    
+    safe_name = name
+    try:
+        # remove the mirror name
+        safe_name = safe_name.split('_', 1)[1]
+    except:
+        pass
+    try:
+        # remove everything to the last 'dists'
+        safe_name = safe_name[safe_name.rindex('dists_'):]
+    except:
+        try:
+            # remove everything to the last 'debian'
+            safe_name = safe_name[safe_name.rindex('debian_')+7:]
+        except:
+            pass
+    return safe_name
 
 class Tracker:
     """Track a download swarm.
@@ -427,6 +457,7 @@
         self.times = {}
         self.state = {}
         self.seedcount = {}
+        self.torrent_names = {}
 
         self.allowed_IPs = None
         self.banned_IPs = None
@@ -463,6 +494,8 @@
         else:
             self.cache_default_len = 5
         for infohash, ds in self.downloads.items():
+            torrent_name = []
+            self.torrent_names[infohash] = torrent_name
             self.seedcount[infohash] = 0
             for x,y in ds.items():
                 ip = y['ip']
@@ -472,6 +505,9 @@
                     continue
                 if not y['left']:
                     self.seedcount[infohash] += 1
+                name = clean_name(y.get('name', ''))
+                if name and name not in torrent_name:
+                    torrent_name.append(name)
                 if y.get('nat',-1):
                     continue
                 gip = y.get('given_ip')
@@ -638,7 +674,10 @@
                     names = [ (None,hash)
                               for hash in self.allowed.keys() ]
             else:
-                names = [ (None,hash) for hash in self.downloads.keys() ]
+                if self.show_names:
+                    names = [ ('\n<br>'.join(self.torrent_names[hash]),hash) for hash in self.downloads.keys() ]
+                else:
+                    names = [ (None,hash) for hash in self.downloads.keys() ]
             if not names:
                 s.write('<p>not tracking any files yet...</p>\n')
             else:
@@ -651,10 +690,10 @@
                 nf = 0  # Number of files displayed
                 if self.config['allowed_dir'] 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')
+                        '<tr><th>torrent name<br><code>info hash</code></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')
+                        '<tr><th>torrent name<br><code>info hash</code></th><th align="right">complete</th><th align="right">downloading</th><th align="right">downloaded</th></tr>\n')
                 for name,hash in names:
                     l = self.downloads[hash]
                     n = self.completed.get(hash, 0)
@@ -674,13 +713,16 @@
                                 linkname = '<a href="/file?info_hash=' + quote(hash) + '">' + name + '</a>'
                             else:
                                 linkname = 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(hash), linkname, size_format(sz), c, d, n, size_format(szt)))
+                            s.write('<tr><td>%s<br><code>%s</code></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' \
+                                % (linkname, b2a_hex(hash), 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' \
+                        s.write('<tr><td>')
+                        if name:
+                            s.write('%s<br>' % name)
+                        s.write('<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(hash), c, d, n))
                 if self.config['allowed_dir'] and self.show_names:
-                    s.write('<tr><td align="right" colspan="2">%i files</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'
+                    s.write('<tr><td align="right">%i files</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'
                             % (nf, size_format(ts), tc, td, tn, size_format(tt)))
                 else:
                     s.write('<tr><td align="right">%i files</td><td align="right">%i</td><td align="right">%i</td><td align="right">%i</td></tr>\n'
@@ -856,6 +898,7 @@
         ts = self.times.setdefault(infohash, {})
         self.completed.setdefault(infohash, 0)
         self.seedcount.setdefault(infohash, 0)
+        torrent_name = self.torrent_names.setdefault(infohash, [])
 
         def params(key, default = None, l = paramslist):
             """Get the user parameter, or the default.
@@ -887,6 +930,7 @@
         port = long(port)
         if port < 0 or port > 65535:
             raise ValueError, 'invalid port'
+        name = params('name')
         left = long(params('left',''))
         if left < 0:
             raise ValueError, 'invalid amount left'
@@ -935,6 +979,11 @@
                 peer['key'] = mykey
             if gip:
                 peer['given ip'] = gip
+            if name:
+                peer['name'] = name
+                safe_name = clean_name(name)
+                if safe_name and safe_name not in torrent_name:
+                    torrent_name.append(safe_name)
             if port:
                 if not self.natcheck or islocal:
                     peer['nat'] = 0

Modified: debtorrent/trunk/DebTorrent/download_bt1.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/download_bt1.py?rev=341&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/download_bt1.py (original)
+++ debtorrent/trunk/DebTorrent/download_bt1.py Wed Jan 23 00:16:36 2008
@@ -1204,7 +1204,8 @@
             self.storagewrapper.get_amount_left, 
             self.upmeasure.get_total, self.downmeasure.get_total,
             self.upmeasure.get_rate, self.downmeasure.get_rate,
-            self.doneflag, self.unpauseflag, seededfunc, force_rapid_update )
+            self.doneflag, self.unpauseflag, seededfunc, force_rapid_update,
+            self.response.get('name', ''))
 
         self.rerequest.start()
 

Modified: debtorrent/trunk/TODO
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/TODO?rev=341&op=diff
==============================================================================
--- debtorrent/trunk/TODO (original)
+++ debtorrent/trunk/TODO Wed Jan 23 00:16:36 2008
@@ -12,6 +12,14 @@
 tracker also needs to keep it's numbers over restarts, and should show 
 more info on how much all peers have downloaded/uploaded for each 
 torrent.
+
+
+Use python-debian for parsing RFC 822 files.
+
+There are already routines available in python-debian for parsing
+Packages files, so use them instead of writing new ones. The torrent
+creation routines and the hippy and uniquely programs proably need
+changes for this. 
 
 
 Investigate using other archives

Modified: debtorrent/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/debian/changelog?rev=341&op=diff
==============================================================================
--- debtorrent/trunk/debian/changelog (original)
+++ debtorrent/trunk/debian/changelog Wed Jan 23 00:16:36 2008
@@ -1,3 +1,14 @@
+debtorrent (0.1.6) unstable; urgency=low
+
+  * Add support for unique piece numbers
+    - increases duration of oft-updated torrents so that more peers can
+      participate
+    - currently supported only by debian testing and unstable
+    - see http://wiki.debian.org/DebTorrent/UniquePieces for more info
+  * Add torrent names to the tracker display
+
+ -- Cameron Dale <camrdale at gmail.com>  Tue, 22 Jan 2008 16:15:37 -0800
+
 debtorrent (0.1.5) unstable; urgency=low
 
   * Update to support apt debtorrent transport version 0.2

Modified: debtorrent/trunk/test.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/test.py?rev=341&op=diff
==============================================================================
--- debtorrent/trunk/test.py (original)
+++ debtorrent/trunk/test.py Wed Jan 23 00:16:36 2008
@@ -148,11 +148,11 @@
                ' that they can all see each other.',
                {1: []},
                {1: (1, [], {'suites': 'contrib non-free'}),
-                2: (1, [], {'suites': 'contrib non-free'}),
-                3: (1, [], {'suites': 'contrib non-free'}),
-                4: (1, [], {'suites': 'contrib non-free'}),
-                5: (1, [], {'suites': 'contrib non-free'}),
-                6: (1, [], {'suites': 'contrib non-free'})},
+                2: (1, [], {'suites': 'contrib non-free', 'mirror': 'debian.mirror.iweb.ca/debian'}),
+                3: (1, [], {'suites': 'contrib non-free', 'mirror': 'debian.sth.sze.hu'}),
+                4: (1, [], {'suites': 'contrib non-free', 'mirror': 'ftp.monash.edu.au/pub/linux/debian'}),
+                5: (1, [], {'suites': 'contrib non-free', 'mirror': 'mmc.igeofcu.unam.mx/debian'}),
+                6: (1, [], {'suites': 'contrib non-free', 'mirror': 'debian.revolsys.fr/debian'})},
                [(1, ['update']),
                 (2, ['update']),
                 (3, ['update']),




More information about the Debtorrent-commits mailing list