r168 - in /debtorrent/trunk: DebTorrent/download_bt1.py DebTorrent/launchmanycore.py debtorrent-client.py

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Mon Jul 16 00:01:08 UTC 2007


Author: camrdale-guest
Date: Mon Jul 16 00:01:08 2007
New Revision: 168

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=168
Log:
Remove the Output displayer and all status messages.

Modified:
    debtorrent/trunk/DebTorrent/download_bt1.py
    debtorrent/trunk/DebTorrent/launchmanycore.py
    debtorrent/trunk/debtorrent-client.py

Modified: debtorrent/trunk/DebTorrent/download_bt1.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/download_bt1.py?rev=168&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/download_bt1.py (original)
+++ debtorrent/trunk/DebTorrent/download_bt1.py Mon Jul 16 00:01:08 2007
@@ -69,7 +69,10 @@
     ('download_dir', '',
         'directory to save the download in, blank indicates use the user\'s ' +
         'home directory'),
-    # saveas_style is in defaults_many below
+    ( 'saveas_style', 1,
+        'How to name torrent download directory ' + 
+        '(1 = <mirror>_dists_<suite>_<section>_binary-<arch>, ' +
+        '2 = <mirror> (caution: experimental))' ),
     ('cache_dir', '', 'the directory to use to get/store cache files, if not ' + 
         'specified then a .DebTorrent directory in the user\'s home directory ' +
         'will be used'),
@@ -116,7 +119,32 @@
     ('crypto_stealth', 0,
         'whether to prevent all non-encrypted connection attempts; ' +
         'will result in an effectively firewalled state on older trackers'),
-    # APT Requests are in defaults_many below
+    # APT Requests
+    ('apt_port', 9988, 'port to listen for apt on'),
+    ('show_infopage', 1, 'whether to display an info page when the ' +
+        'APT requester\'s root directory is loaded'),
+    ('infopage_redirect', '', 'a URL to redirect the info page to'),
+    ('favicon', '', 
+        'file containing x-icon data to return when browser requests favicon.ico'),
+    ('display_path', 0,
+        'whether to display the full path or the torrent contents for each torrent'),
+    ('allow_get', 0, 
+        'adds a /file?infohash={hash} url that allows users to download the ' +
+        'dtorrent file'),
+    ('logfile', '', 
+        'file to write the APT request listener logs to (default is stdout)'),
+    ('min_time_between_log_flushes', 3.0,
+        'minimum time it must have been since the last flush to do another one'),
+    ('hupmonitor', 0, 
+        'whether to reopen the log file upon receipt of HUP signal'),
+    ('allowed_ips', '', 
+        'only allow connections from IPs specified in the given file; '+
+        'file contains subnet data in the format: aa.bb.cc.dd/len'),
+    ('banned_ips', '', 
+        'don\'t allow connections from IPs specified in the given file; ' +
+        'file contains IP range data in the format: xxx:xxx:ip1-ip2'),
+    ('parse_ip_files', 60, 
+        'seconds between reloading of allowed_ips and banned_ips lists for apt'),
     # Backup HTTP Downloader
     ('disable_http_downloader', 0, 
         '(for testing purposes only) whether to disable the backup HTTP downloader'),
@@ -202,40 +230,6 @@
 
     ('display_interval', .5,
         'time between updates of displayed information'),
-    ]
-
-defaults_many = [
-    # Locations
-    ( 'saveas_style', 1,
-      "How to name torrent download directory " + 
-      "(1 = <mirror>_dists_<suite>_<section>_binary-<arch>, " +
-      "2 = <mirror> (caution: experimental))" ),
-    # APT Requests
-    ('apt_port', 9988, 'port to listen for apt on'),
-    ('show_infopage', 1, 'whether to display an info page when the ' +
-        'APT requester\'s root directory is loaded'),
-    ('infopage_redirect', '', 'a URL to redirect the info page to'),
-    ('favicon', '', 
-        'file containing x-icon data to return when browser requests favicon.ico'),
-    ('display_path', 0,
-        'whether to display the full path or the torrent contents for each torrent'),
-    ('allow_get', 0, 
-        'adds a /file?infohash={hash} url that allows users to download the ' +
-        'dtorrent file'),
-    ('logfile', '', 
-        'file to write the APT request listener logs to (default is stdout)'),
-    ('min_time_between_log_flushes', 3.0,
-        'minimum time it must have been since the last flush to do another one'),
-    ('hupmonitor', 0, 
-        'whether to reopen the log file upon receipt of HUP signal'),
-    ('allowed_ips', '', 
-        'only allow connections from IPs specified in the given file; '+
-        'file contains subnet data in the format: aa.bb.cc.dd/len'),
-    ('banned_ips', '', 
-        'don\'t allow connections from IPs specified in the given file; ' +
-        'file contains IP range data in the format: xxx:xxx:ip1-ip2'),
-    ('parse_ip_files', 60, 
-        'seconds between reloading of allowed_ips and banned_ips lists for apt'),
     ]
 
 argslistheader = 'Arguments are:\n\n'

Modified: debtorrent/trunk/DebTorrent/launchmanycore.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/launchmanycore.py?rev=168&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/launchmanycore.py (original)
+++ debtorrent/trunk/DebTorrent/launchmanycore.py Mon Jul 16 00:01:08 2007
@@ -284,8 +284,6 @@
     
     @type config: C{dictionary}
     @ivar config: the configuration parameters
-    @type Output: unknown
-    @ivar Output: the displayer instance to use
     @type configdir: L{ConfigDir.ConfigDir}
     @ivar configdir: the configuration and cache directory manager
     @type torrent_cache: C{dictionary}
@@ -321,13 +319,11 @@
     
     """
     
-    def __init__(self, config, Output, configdir):
+    def __init__(self, config, configdir):
         """Initialize the instance.
         
         @type config: C{dictionary}
         @param config: the configuration parameters
-        @type Output: unknown
-        @param Output: the displayer instance to use
         @type configdir: L{ConfigDir.ConfigDir}
         @param configdir: the configuration and cache directory manager
         
@@ -335,7 +331,6 @@
         
         try:
             self.config = config
-            self.Output = Output
             self.configdir = configdir
 
             self.torrent_cache = {}
@@ -354,14 +349,11 @@
             self.rawserver = RawServer(self.doneflag, config['timeout_check_interval'],
                               config['timeout'], ipv6_enable = config['ipv6_enabled'],
                               failfunc = self.failed, errorfunc = self.exchandler)
-            try:
-                self.listen_port = self.rawserver.find_and_bind(
-                                config['minport'], config['maxport'], config['bind'],
-                                ipv6_socket_style = config['ipv6_binds_v4'],
-                                randomizer = config['random_port'])
-            except socketerror, e:
-                self.failed("Couldn't listen - " + str(e))
-                return
+
+            self.listen_port = self.rawserver.find_and_bind(
+                            config['minport'], config['maxport'], config['bind'],
+                            ipv6_socket_style = config['ipv6_binds_v4'],
+                            randomizer = config['random_port'])
 
             self.aptlistener = AptListener(self, config, self.rawserver)
             self.rawserver.bind(config['apt_port'], config['bind'],
@@ -378,7 +370,6 @@
 
             self.handler = MultiHandler(self.rawserver, self.doneflag, config)
             seed(createPeerID())
-            self.rawserver.add_task(self.stats, 0)
 
             # Restore the previous state of the downloads
             self.unpickle(self.configdir.getState())
@@ -388,26 +379,19 @@
             # Save the current state of the downloads
             self.configdir.saveState(self.pickle())
 
-            self.Output.message('shutting down')
+            print 'shutting down'
             self.hashcheck_queue = []
             for hash in self.torrent_list:
-                self.Output.message('dropped "'+self.torrent_cache[hash]['path']+'"')
+                print 'dropped "'+self.torrent_cache[hash]['path']+'"'
                 self.downloads[hash].shutdown()
             self.rawserver.shutdown()
 
         except:
             data = StringIO()
             print_exc(file = data)
-            Output.exception(data.getvalue())
-
-
-    def stats(self):
-        """Call the Output display with the currently running torrents' statistics."""
-        self.rawserver.add_task(self.stats, self.stats_period)
-        data = self.gather_stats()
-        stop = self.Output.display(data)
-        if stop:
-            self.doneflag.set()
+            print 'SYSTEM ERROR - EXCEPTION GENERATED'
+            print data.getvalue()
+
 
     def gather_stats(self):
         """Gather the statistics for the currently running torrents.
@@ -673,7 +657,7 @@
         """
         
         if self.torrent_cache.has_key(hash):
-            self.Output.message('DIED: "'+self.torrent_cache[hash]['path']+'"')
+            print 'DIED: "'+self.torrent_cache[hash]['path']+'"'
         
     def has_torrent(self, hash):
         """Determine whether there is a downloader for the torrent.
@@ -712,7 +696,7 @@
         
         """
         
-        self.Output.message('FAILURE: '+s)
+        print 'FAILURE: '+s
 
     def exchandler(self, s):
         """Indicate to the Output that an exception has occurred.
@@ -722,7 +706,8 @@
         
         """
         
-        self.Output.exception(s)
+        print 'SYSTEM ERROR - EXCEPTION GENERATED'
+        print s
 
     def pickle(self):
         """Save the current state of the downloads to a writable state.

Modified: debtorrent/trunk/debtorrent-client.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/debtorrent-client.py?rev=168&op=diff
==============================================================================
--- debtorrent/trunk/debtorrent-client.py (original)
+++ debtorrent/trunk/debtorrent-client.py Mon Jul 16 00:01:08 2007
@@ -24,95 +24,12 @@
         pass
 
 from DebTorrent.launchmanycore import LaunchMany
-from DebTorrent.download_bt1 import defaults, defaults_many, get_usage
+from DebTorrent.download_bt1 import defaults, get_usage
 from DebTorrent.parseargs import parseargs
 from sys import argv, exit
 import os
 from DebTorrent import version, report_email
 from DebTorrent.ConfigDir import ConfigDir
-
-def hours(n):
-    """Formats seconds into a human-readable time.
-    
-    Formats a given number of seconds into a human-readable time appropriate
-    for display to the user.
-    
-    @type n: C{int}
-    @param n: the number of seconds
-    @rtype: C{string}
-    @return: a displayable representation of the number of seconds
-    
-    """
-    
-    if n == 0:
-        return 'complete!'
-    try:
-        n = int(n)
-        assert n >= 0 and n < 5184000  # 60 days
-    except:
-        return '<unknown>'
-    m, s = divmod(n, 60)
-    h, m = divmod(m, 60)
-    if h > 0:
-        return '%d hour %02d min %02d sec' % (h, m, s)
-    else:
-        return '%d min %02d sec' % (m, s)
-
-
-Exceptions = []
-
-class HeadlessDisplayer:
-    """Displays on the command-line the status of the downloads.
-    
-    Implements a displayer for showing in text format the current status
-    of the downloads.
-
-    """
-    
-    def display(self, data):
-        """Displays the current status of the downloads.
-        
-        Writes a status update to standard output.
-        
-        @type data: C{list} of C{tuple}
-        @param data: a tuple per download, containing the current status of the download
-        @rtype: C{boolean}
-        @return: False
-        
-        """
-
-        print ''
-        if not data:
-            self.message('no torrents')
-        for x in data:
-            ( name, hash, status, progress, peers, seeds, seedsmsg, dist,
-              uprate, dnrate, upamt, dnamt, size, t, msg ) = x
-            print '"%s": "%s" (%s) - %sP%s%s%.3fD u%0.1fK/s-d%0.1fK/s u%dK-d%dK "%s"' % (
-                        name, status, progress, peers, seeds, seedsmsg, dist,
-                        uprate/1000, dnrate/1000, upamt/1024, dnamt/1024, msg)
-        return False
-            
-    def message(self, s):
-        """Prints a message to standard output.
-        
-        @type s: C{string}
-        @param s: the message to print to standard output
-        
-        """
-        
-        print "### "+s
-
-    def exception(self, s):
-        """Saves a new exception and alerts the user.
-        
-        @type s: C{string}
-        @param s: the exception that occurred
-        
-        """
-        
-        Exceptions.append(s)
-        self.message('SYSTEM ERROR - EXCEPTION GENERATED')
-
 
 def run(params):
     """Runs the downloader.
@@ -124,7 +41,6 @@
     
     """
     
-    defaults.extend(defaults_many)
     configdefaults = {}
     try:
         configdir = ConfigDir('debtorrent-client')
@@ -148,11 +64,7 @@
         print 'error: ' + str(e) + '\n'
         exit(2)
 
-    LaunchMany(config, HeadlessDisplayer(), configdir)
-    if Exceptions:
-        print '\nEXCEPTION:'
-        print Exceptions[0]
-        print 'please report this to '+report_email
+    LaunchMany(config, configdir)
 
 if __name__ == '__main__':
     if argv[1:2] == ['--version']:




More information about the Debtorrent-commits mailing list