r102 - in /debtorrent/trunk: ./ DebTorrent/BT1/track.py DebTorrent/download_bt1.py DebTorrent/launchmanycore.py DebTorrent/parsedir.py btdownloadheadless.py

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Wed Jun 13 21:25:02 UTC 2007


Author: camrdale-guest
Date: Wed Jun 13 21:25:02 2007
New Revision: 102

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=102
Log:
Reverted changes r51 and r53 to remove dpkg status parsing.

Modified:
    debtorrent/trunk/   (props changed)
    debtorrent/trunk/DebTorrent/BT1/track.py
    debtorrent/trunk/DebTorrent/download_bt1.py
    debtorrent/trunk/DebTorrent/launchmanycore.py
    debtorrent/trunk/DebTorrent/parsedir.py
    debtorrent/trunk/btdownloadheadless.py

Propchange: debtorrent/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jun 13 21:25:02 2007
@@ -1,3 +1,1 @@
 *.pyc
-.project
-.pydevproject

Modified: debtorrent/trunk/DebTorrent/BT1/track.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/track.py?rev=102&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/track.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/track.py Wed Jun 13 21:25:02 2007
@@ -1030,7 +1030,7 @@
                           self.allowed_dir_files, self.allowed_dir_blocked,
                           [".dtorrent"] )
             ( self.allowed, self.allowed_dir_files, self.allowed_dir_blocked,
-                added, garbage2, garbage3 ) = r
+                added, garbage2 ) = r
             
             self.state['allowed'] = self.allowed
             self.state['allowed_dir_files'] = self.allowed_dir_files

Modified: debtorrent/trunk/DebTorrent/download_bt1.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/download_bt1.py?rev=102&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/download_bt1.py (original)
+++ debtorrent/trunk/DebTorrent/download_bt1.py Wed Jun 13 21:25:02 2007
@@ -39,7 +39,7 @@
 from bencode import bencode, bdecode
 from natpunch import UPnP_test
 from sha import sha
-from os import path, makedirs, listdir, system
+from os import path, makedirs, listdir
 from parseargs import parseargs, formatDefinitions, defaultargs
 from socket import error as socketerror
 from random import seed
@@ -64,8 +64,6 @@
 except:
     True = 1
     False = 0
-
-DEBUG = True
 
 defaults = [
     ('max_uploads', 7,
@@ -193,10 +191,6 @@
         "minutes between automatic flushes to disk (0 = disabled)"),
     ('dedicated_seed_id', '',
         "code to send to tracker identifying as a dedicated seed"),
-    ('status_to_download', 0,
-        'determines which packages to download based on /var/lib/dpkg/status ' +
-        '(0 = disabled [download all or use --priority], 1 = download updated versions of installed packages, ' +
-         '2 = download all installed packages)'),
     ]
 
 argslistheader = 'Arguments are:\n\n'
@@ -269,14 +263,14 @@
         failed("Couldn't listen - " + str(e))
         return
 
-    (response, status_priority) = get_response(config['responsefile'], config['url'], failed)
+    response = get_response(config['responsefile'], config['url'], failed)
     if not response:
         return
 
     infohash = sha(bencode(response['info'])).digest()
 
     d = BT1Download(statusfunc, finfunc, errorfunc, exchandler, doneflag,
-                    config, response, infohash, myid, rawserver, listen_port, status_priority)
+                    config, response, infohash, myid, rawserver, listen_port)
 
     if not d.saveAs(filefunc):
         return
@@ -358,7 +352,7 @@
     return (argslistheader + formatDefinitions(defaults, cols, presets))
 
 
-def get_response(file, url, status_to_download, errorfunc):
+def get_response(file, url, errorfunc):
     """Get the response data from a metainfo or Packages file.
     
     First checks to see if the data is in the Packages file format, and
@@ -382,14 +376,14 @@
     
     """
     
-    (response, priority) = get_packages(file, url, status_to_download)
+    response = get_packages(file, url, errorfunc)
     if response:
         try:
             check_message(response)
         except ValueError, e:
             errorfunc("got bad file info - " + str(e))
-            return (None, None)
-        return (response, priority)
+            return None
+        return response
     try:
         if file:
             h = open(file, 'rb')
@@ -400,7 +394,7 @@
                 int(front[1:])
             except:
                 errorfunc(file+' is not a valid responsefile')
-                return (None, None)
+                return None
             try:
                 h.seek(0)
             except:
@@ -414,12 +408,12 @@
                 h = urlopen(url)
             except:
                 errorfunc(url+' bad url')
-                return (None, None)
+                return None
         response = h.read()
     
     except IOError, e:
         errorfunc('problem getting response info - ' + str(e))
-        return (None, None)
+        return None
     try:    
         h.close()
     except:
@@ -433,11 +427,11 @@
         check_message(response)
     except ValueError, e:
         errorfunc("got bad file info - " + str(e))
-        return (None, None)
-
-    return (response, None)
-
-def get_packages(file, url, status_to_download):
+        return None
+
+    return response
+
+def get_packages(file, url, errorfunc):
     """Extract the response data from a Packages file.
     
     @type file: C{string}
@@ -462,39 +456,6 @@
         encoding = ENCODING
     if not encoding:
         encoding = 'ascii'
-        
-    get_priority = False
-    installed_versions = {}
-    priority = None
-    if status_to_download > 0:
-        try:
-            status = open("/var/lib/dpkg/status")
-    
-            p = [None, None, None]
-            for line in status:
-                line = line.rstrip()
-                if line == "":
-                    if (p[0] and p[1] and p[2]):
-                        if (p[2] == "install ok installed"):
-                            installed_versions[p[0]] = p[1]
-                        p = [None, None, None]
-                if line[:8] == "Package:":
-                    p[0] = line[9:]
-                if line[:8] == "Version:":
-                    p[1] = line[9:]
-                if line[:7] == "Status:":
-                    p[2] = line[8:]
-        except:
-            installed_versions = {}
-
-        try:
-            status.close()
-        except:
-            pass
-        
-        if installed_versions:
-            get_priority = True
-            priority = {}
 
     try:
         if file:
@@ -507,7 +468,7 @@
                 assert line[:8] == "Package:"
             except:
 #                errorfunc(file+' is not a valid Packages file')
-                return (None, None)
+                return None
             try:
                 h.seek(0)
             except:
@@ -534,43 +495,31 @@
                 h = data.split('\n')
             except:
 #                errorfunc(url+' bad url')
-                return (None, None)
+                return None
 
         pieces = []
         lengths = []
         fs = []
         
-        p = [None, None, None, None, None]
+        p = [None, None, None]
         for line in h:
             line = line.rstrip()
             if line == "":
                 if (p[0] and p[1] and p[2]):
-                    file_path = []
-                    temp = p[1]
+                    path = []
                     while p[1]:
                         p[1],d = split(p[1])
-                        file_path.insert(0,d)
-                    fs.append({'length': p[0], 'path': uniconvertl(file_path, encoding)})
+                        path.insert(0,d)
+                    fs.append({'length': p[0], 'path': uniconvertl(path, encoding)})
                     lengths.append(p[0])
                     pieces.append(p[2])
-                    if (get_priority and p[3] and installed_versions.has_key(p[3])):
-                        if status_to_download == 2:
-                            priority[temp] = 1
-                        elif (status_to_download == 1 and p[4]):
-                            ret = system('dpkg --compare-versions "' + installed_versions[p[3]] + '" lt "' + p[4] + '"')
-                            if ret == 0:
-                                priority[temp] = 1
-                p = [None, None, None, None, None]
+                p = [None, None, None]
             if line[:9] == "Filename:":
                 p[1] = line[10:]
             if line[:5] == "Size:":
                 p[0] = long(line[6:])
             if line[:5] == "SHA1:":
                 p[2] = binascii.a2b_hex(line[6:])
-            if line[:8] == "Package:":
-                p[3] = line[9:]
-            if line[:8] == "Version:":
-                p[4] = line[9:]
         
         response = {'info': {'pieces': ''.join(pieces),
             'piece lengths': lengths, 'files': fs },
@@ -579,13 +528,13 @@
     
     except IOError, e:
 #        errorfunc('problem getting Packages info - ' + str(e))
-        return (None, None)
+        return None
     try:    
         h.close()
     except:
         pass
 
-    return (response, priority)
+    return response
 
 
 class BT1Download:    
@@ -701,7 +650,7 @@
     
     def __init__(self, statusfunc, finfunc, errorfunc, excfunc, doneflag,
                  config, response, infohash, id, rawserver, port,
-                 status_priority = None, appdataobj = None):
+                 appdataobj = None):
         """Initialize the instance.
         
         @type statusfunc: C{method}
@@ -751,7 +700,6 @@
                        for x in xrange(0, len(self.info['pieces']), 20)]
         self.piece_lengths = self.info['piece lengths']
         self.len_pieces = len(self.pieces)
-        self.status_priority = status_priority
         self.argslistheader = argslistheader
         self.unpauseflag = Event()
         self.unpauseflag.set()
@@ -983,23 +931,6 @@
 
         disabled_files = None
         if self.selector_enabled:
-            if self.status_priority is not None:
-                if DEBUG:
-                    print 'original priority:', str(self.status_priority)
-                if len(self.status_priority) == 0:
-                    self._failed('Nothing to download')
-                    if self.doneflag.isSet():
-                        return None
-                updated_priority = {}
-                for k, v in self.status_priority.items():
-                    updated_priority[path.join(self.filename,k)] = v
-                if DEBUG:
-                    print 'updated priority:', str(updated_priority)
-                self.status_priority = []
-                for file, length in self.files:
-                    self.status_priority.append(updated_priority.get(file, -1))
-                if DEBUG:
-                    print 'final priority:', str(self.status_priority)
             self.priority = self.config['priority']
             if self.priority:
                 try:
@@ -1011,9 +942,7 @@
                         assert p <= 2
                 except:
                     self.errorfunc('bad priority list given, ignored')
-                    self.priority = self.status_priority
-            else:
-                self.priority = self.status_priority
+                    self.priority = None
 
             data = self.appdataobj.getTorrentData(self.infohash)
             try:

Modified: debtorrent/trunk/DebTorrent/launchmanycore.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/launchmanycore.py?rev=102&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/launchmanycore.py (original)
+++ debtorrent/trunk/DebTorrent/launchmanycore.py Wed Jun 13 21:25:02 2007
@@ -49,7 +49,7 @@
     return '%d:%02d:%02d' % (h, m, s)
 
 class SingleDownload:
-    def __init__(self, controller, hash, response, config, myid, status_priority = None):
+    def __init__(self, controller, hash, response, config, myid):
         self.controller = controller
         self.hash = hash
         self.response = response
@@ -71,8 +71,7 @@
 
         d = BT1Download(self.display, self.finished, self.error,
                         controller.exchandler, self.doneflag, config, response,
-                        hash, myid, self.rawserver, controller.listen_port,
-                        status_priority)
+                        hash, myid, self.rawserver, controller.listen_port)
         self.d = d
 
     def start(self):
@@ -218,18 +217,17 @@
                                 
         r = parsedir(self.torrent_dir, self.torrent_cache,
                      self.file_cache, self.blocked_files,
-                     return_metainfo = True, errfunc = self.Output.message, 
-                     status_to_download = self.config['status_to_download'])
+                     return_metainfo = True, errfunc = self.Output.message)
 
         ( self.torrent_cache, self.file_cache, self.blocked_files,
-            added, removed, status_priorities ) = r
+            added, removed ) = r
 
         for hash, data in removed.items():
             self.Output.message('dropped "'+data['path']+'"')
             self.remove(hash)
         for hash, data in added.items():
             self.Output.message('added "'+data['path']+'"')
-            self.add(hash, data, status_priorities.get(hash, None))
+            self.add(hash, data)
 
     def stats(self):            
         self.rawserver.add_task(self.stats, self.stats_period)
@@ -302,7 +300,7 @@
         self.downloads[hash].shutdown()
         del self.downloads[hash]
         
-    def add(self, hash, data, status_priority = None):
+    def add(self, hash, data):
         c = self.counter
         self.counter += 1
         x = ''
@@ -310,8 +308,7 @@
             x = mapbase64[c & 0x3F]+x
             c >>= 6
         peer_id = createPeerID(x)
-        d = SingleDownload(self, hash, data['metainfo'], self.config, 
-                           peer_id, status_priority)
+        d = SingleDownload(self, hash, data['metainfo'], self.config, peer_id)
         self.torrent_list.append(hash)
         self.downloads[hash] = d
         d.start()

Modified: debtorrent/trunk/DebTorrent/parsedir.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/parsedir.py?rev=102&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/parsedir.py (original)
+++ debtorrent/trunk/DebTorrent/parsedir.py Wed Jun 13 21:25:02 2007
@@ -23,7 +23,7 @@
 
 def parsedir(directory, parsed, files, blocked,
              exts = ['dtorrent','Packages'], 
-             return_metainfo = False, errfunc = _errfunc, status_to_download = 0):
+             return_metainfo = False, errfunc = _errfunc):
     if NOISY:
         errfunc('checking dir')
     dirs_to_check = [directory]
@@ -54,7 +54,6 @@
     to_add = []
     added = {}
     removed = {}
-    status_priorities = {}
     # files[path] = [(modification_time, size), hash], hash is 0 if the file
     # has not been successfully parsed
     for p,v in new_files.items():   # re-add old items and check for changes
@@ -93,7 +92,7 @@
         if NOISY:
             errfunc('adding '+p)
         try:
-            (d, status_priority) = get_response(p, '', status_to_download, errfunc)
+            d = get_response(p, '', errfunc)
             h = sha(bencode(d['info'])).digest()
             new_file[1] = h
             if new_parsed.has_key(h):
@@ -137,7 +136,6 @@
             errfunc('... successful')
         new_parsed[h] = a
         added[h] = a
-        status_priorities[h] = status_priority
 
     for p,v in files.items():       # and finally, mark removed torrents
         if not new_files.has_key(p) and not blocked.has_key(p):
@@ -147,5 +145,5 @@
 
     if NOISY:
         errfunc('done checking')
-    return (new_parsed, new_files, new_blocked, added, removed, status_priorities)
+    return (new_parsed, new_files, new_blocked, added, removed)
 

Modified: debtorrent/trunk/btdownloadheadless.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/btdownloadheadless.py?rev=102&op=diff
==============================================================================
--- debtorrent/trunk/btdownloadheadless.py (original)
+++ debtorrent/trunk/btdownloadheadless.py Wed Jun 13 21:25:02 2007
@@ -295,7 +295,7 @@
                 h.failed()
                 return
 
-        (response, status_priority) = get_response(config['responsefile'], config['url'], config['status_to_download'], h.error)
+        response = get_response(config['responsefile'], config['url'], h.error)
         if not response:
             break
 
@@ -303,7 +303,7 @@
 
         dow = BT1Download(h.display, h.finished, h.error, disp_exception, doneflag,
                         config, response, infohash, myid, rawserver, listen_port,
-                        status_priority, configdir)
+                        configdir)
         
         if not dow.saveAs(h.chooseFile, h.newpath):
             break




More information about the Debtorrent-commits mailing list