r198 - in /debtorrent/trunk: ./ DebTorrent/ DebTorrent/BT1/
camrdale-guest at users.alioth.debian.org
camrdale-guest at users.alioth.debian.org
Sat Aug 4 23:02:04 UTC 2007
Author: camrdale-guest
Date: Sat Aug 4 23:02:03 2007
New Revision: 198
URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=198
Log:
Remove all superfluous status/error functions in favor of logging directly.
Modified:
debtorrent/trunk/DebTorrent/BT1/AptListener.py
debtorrent/trunk/DebTorrent/BT1/HTTPDownloader.py
debtorrent/trunk/DebTorrent/BT1/Rerequester.py
debtorrent/trunk/DebTorrent/BT1/StorageWrapper.py
debtorrent/trunk/DebTorrent/BT1/T2T.py
debtorrent/trunk/DebTorrent/RawServer.py
debtorrent/trunk/DebTorrent/download_bt1.py
debtorrent/trunk/DebTorrent/inifile.py
debtorrent/trunk/DebTorrent/launchmanycore.py
debtorrent/trunk/DebTorrent/parsedir.py
debtorrent/trunk/debtorrent-client.py
Modified: debtorrent/trunk/DebTorrent/BT1/AptListener.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/AptListener.py?rev=198&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/AptListener.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/AptListener.py Sat Aug 4 23:02:03 2007
@@ -248,7 +248,7 @@
'uploaded</th>\n' \
'<th align="right">size</th>\n' \
'<th align="right">time remaining</th>\n' \
- '<th>error message</th>\n' \
+ '<th>last error message</th>\n' \
'</tr>\n')
# Get the data from the statistics gatherer
Modified: debtorrent/trunk/DebTorrent/BT1/HTTPDownloader.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/HTTPDownloader.py?rev=198&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/HTTPDownloader.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/HTTPDownloader.py Sat Aug 4 23:02:03 2007
@@ -119,14 +119,17 @@
try:
(scheme, self.netloc, path, params, query, fragment) = urlparse(url)
except:
+ logger.exception('cannot parse http seed address: '+url)
self.downloader.errorfunc('cannot parse http seed address: '+url)
return
if scheme != 'http':
+ logger.error('http seed url not http: '+url)
self.downloader.errorfunc('http seed url not http: '+url)
return
try:
self.connection = HTTPConnection(self.netloc)
except:
+ logger.exception('cannot connect to http seed: '+url)
self.downloader.errorfunc('cannot connect to http seed: '+url)
return
self.seedurl = path
@@ -275,6 +278,7 @@
self.active = False
if self.error is not None:
if self.goodseed:
+ logger.warning(self.error)
self.downloader.errorfunc(self.error)
self.errorcount += 1
if self.received_data:
@@ -307,6 +311,7 @@
self._retry_period = 1
if len(self.received_data) != self.request_size:
if self.goodseed:
+ logger.warning('corrupt data from http seed - redownloading')
self.downloader.errorfunc('corrupt data from http seed - redownloading')
return False
self.measure.update_rate(len(self.received_data))
Modified: debtorrent/trunk/DebTorrent/BT1/Rerequester.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/Rerequester.py?rev=198&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/Rerequester.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/Rerequester.py Sat Aug 4 23:02:03 2007
@@ -119,8 +119,6 @@
@ivar externalsched: method to call to schedule future invocation of other functions
@type errorfunc: C{method}
@ivar errorfunc: method to call when an error occurs
- @type excfunc: C{method}
- @ivar excfunc: method to call when an exception occurs
@type connect: C{method}
@ivar connect: method to call to start connections to new peers
@type howmany: C{method}
@@ -183,7 +181,7 @@
"""
def __init__( self, port, myid, infohash, trackerlist, config,
- sched, externalsched, errorfunc, excfunc, connect,
+ sched, externalsched, errorfunc, connect,
howmany, amount_left, up, down, upratefunc, downratefunc,
doneflag, unpauseflag = fakeflag(True),
seededfunc = None, force_rapid_update = False ):
@@ -205,8 +203,6 @@
@param externalsched: method to call to schedule future invocation of other functions
@type errorfunc: C{method}
@param errorfunc: method to call when an error occurs
- @type excfunc: C{method}
- @param excfunc: method to call when an exception occurs
@type connect: C{method}
@param connect: method to call to start connections to new peers
@type howmany: C{method}
@@ -238,7 +234,6 @@
self.sched = sched
self.externalsched = externalsched
self.errorfunc = errorfunc
- self.excfunc = excfunc
self.connect = connect
self.howmany = howmany
self.amount_left = amount_left
@@ -489,7 +484,8 @@
# no success from any tracker
self.externalsched(fail)
except:
- self.exception(callback)
+ logger.exception('Error occurred while trying list of trackers')
+ self.externalsched(callback)
def _fail(self, callback):
@@ -508,6 +504,7 @@
break
else:
r = 'Problem connecting to tracker - unspecified error'
+ logger.error(r)
self.errorfunc(r)
self.last_failed = True
@@ -631,7 +628,8 @@
self.postrequest(r, callback)
self.externalsched(add)
except:
- self.exception(callback)
+ logger.exception('Error occurred performing request to single tracker')
+ self.externalsched(callback)
def postrequest(self, r, callback):
@@ -645,7 +643,8 @@
"""
if r.has_key('warning message'):
- self.errorfunc('warning from tracker - ' + r['warning message'])
+ logger.warning('warning from tracker - ' + r['warning message'])
+ self.errorfunc('warning from tracker - ' + r['warning message'])
self.announce_interval = r.get('interval', self.announce_interval)
self.interval = r.get('min interval', self.interval)
self.trackerid = r.get('tracker id', self.trackerid)
@@ -690,24 +689,6 @@
self.connect(peers)
callback()
- def exception(self, callback):
- """Process an exception that occurred during the request..
-
- @type callback: C{method}
- @param callback: the method to call when the request is complete
-
- """
-
- data = StringIO()
- print_exc(file = data)
- def r(s = data.getvalue(), callback = callback):
- if self.excfunc:
- self.excfunc(s)
- else:
- logger.error(s)
- callback()
- self.externalsched(r)
-
class SuccessLock:
"""Locks to synchronize threaded requests to trackers.
Modified: debtorrent/trunk/DebTorrent/BT1/StorageWrapper.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/StorageWrapper.py?rev=198&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/StorageWrapper.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/StorageWrapper.py Sat Aug 4 23:02:03 2007
@@ -295,8 +295,6 @@
initial fraction done, method to call to initialize the task, and the task
@type initialize_done: C{method}
@ivar initialize_done: method to call when the background initialization is complete
- @type initialize_status: C{method}
- @ivar initialize_status: method to call to report the status of the initialization
@type initialize_next: C{method}
@ivar initialize_next: current method to call in the initialization tasks
@type check_list: C{list} of C{int}
@@ -483,21 +481,15 @@
return True
- def initialize(self, donefunc, statusfunc = None):
+ def initialize(self, donefunc):
"""Schedule the background initialization of the storage.
@type donefunc: C{method}
@param donefunc: method to call when the initialization is complete
- @type statusfunc: C{method}
- @param statusfunc: method to call to report the status of the initialization
- (optional, defaults to using L{statusfunc})
"""
self.initialize_done = donefunc
- if statusfunc is None:
- statusfunc = self.statusfunc
- self.initialize_status = statusfunc
self.initialize_next = None
self.backfunc(self._initialize)
@@ -513,7 +505,7 @@
if x is None:
self.initialize_next = None
else:
- self.initialize_status(fractionDone = x)
+ self.statusfunc(fractionDone = x)
else:
if not self.initialize_tasks:
self.initialize_done()
@@ -521,7 +513,7 @@
return
msg, done, init, next = self.initialize_tasks.pop(0)
if init():
- self.initialize_status(activity = msg, fractionDone = done)
+ self.statusfunc(activity = msg, fractionDone = done)
self.initialize_next = next
self.backfunc(self._initialize)
Modified: debtorrent/trunk/DebTorrent/BT1/T2T.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/T2T.py?rev=198&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/T2T.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/T2T.py Sat Aug 4 23:02:03 2007
@@ -29,16 +29,6 @@
False = 0
logger = logging.getLogger('DebTorrent.BT1.T2T')
-
-def excfunc(x):
- """Log an exception that occurred.
-
- @type x: C{string}
- @param x: the error message to log
-
- """
-
- logger.error(x)
R_0 = lambda: 0
R_1 = lambda: 1
@@ -133,7 +123,7 @@
'rerequest_interval': interval,
'http_timeout': timeout }
self.rerequester = Rerequester( 0, myid, hash, [[tracker]], cfg,
- rawserver.add_task, rawserver.add_task, self.errorfunc, excfunc,
+ rawserver.add_task, rawserver.add_task, self.errorfunc,
self.addtolist, R_0, R_1, R_0, R_0, R_0, R_0,
Event() )
Modified: debtorrent/trunk/DebTorrent/RawServer.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/RawServer.py?rev=198&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/RawServer.py (original)
+++ debtorrent/trunk/DebTorrent/RawServer.py Sat Aug 4 23:02:03 2007
@@ -78,12 +78,6 @@
@ivar dead_from_write: not used
@type doneflag: C{threading.Event}
@ivar doneflag: flag to indicate the program is to be shutdown
- @type noisy: C{boolean}
- @ivar noisy: whether to report exceptions in running the task
- @type failfunc: C{method}
- @ivar failfunc: method to call to report failures
- @type errorfunc: C{method}
- @ivar errorfunc: method to call to report exceptions
@type exccount: C{int}
@ivar exccount: number of exceptions that have occurred
@type funcs: C{list} of (C{float}, C{method}, unknown)
@@ -102,9 +96,8 @@
"""
- def __init__(self, doneflag, timeout_check_interval, timeout, noisy = True,
- ipv6_enable = True, failfunc = lambda x: None, errorfunc = None,
- sockethandler = None, excflag = Event()):
+ def __init__(self, doneflag, timeout_check_interval, timeout,
+ ipv6_enable = True, sockethandler = None, excflag = Event()):
"""Initialize the instance and start the socket handler.
@type doneflag: C{threading.Event}
@@ -115,18 +108,9 @@
@type timeout: C{float}
@param timeout: seconds to wait between closing sockets on which
nothing has been received on
- @type noisy: C{boolean}
- @param noisy: whether to report exceptions in running the task
- (optional, defaults to True)
@type ipv6_enable: C{boolean}
@param ipv6_enable: allow the client to connect to peers via IPv6
(optional, defaults to True)
- @type failfunc: C{method}
- @param failfunc: method to call to report failures
- (optional, defaults to not reporting)
- @type errorfunc: C{method}
- @param errorfunc: method to call to report exceptions
- (optional, defaults to not reporting)
@type sockethandler: L{SocketHandler.SocketHandler}
@param sockethandler: the handler to use to manage all open sockets
(optional, defaults to creating a new one)
@@ -142,9 +126,6 @@
self.single_sockets = {}
self.dead_from_write = []
self.doneflag = doneflag
- self.noisy = noisy
- self.failfunc = failfunc
- self.errorfunc = errorfunc
self.exccount = 0
self.funcs = []
self.externally_added = []
@@ -310,6 +291,7 @@
@param signalnum: the signal that was received
@type frame: C{frame}
@param frame: the current stack frame (not used)
+ @raise KeyboardInterrupt: always
"""
@@ -348,22 +330,21 @@
# logger.debug(func.func_name)
func()
except (SystemError, MemoryError), e:
- self.failfunc(str(e))
+ logger.exception('Occurred while running '+func.__name__)
return
except KeyboardInterrupt:
signal(SIGINT, SIG_DFL)
# self.exception(True)
return
except:
- if self.noisy:
- self.exception()
+ self.exception()
self.sockethandler.close_dead()
self.sockethandler.handle_events(events)
if self.doneflag.isSet():
return
self.sockethandler.close_dead()
except (SystemError, MemoryError), e:
- self.failfunc(str(e))
+ logger.exception('Occurred while processing queued functions')
return
except error:
if self.doneflag.isSet():
@@ -426,14 +407,7 @@
if not kbint:
self.excflag.set()
self.exccount += 1
- if self.errorfunc is None:
- logger.exception('RawServer exception occurred')
- else:
- data = StringIO()
- print_exc(file = data)
-# print data.getvalue() # report exception here too
- if not kbint: # don't report here if it's a keyboard interrupt
- self.errorfunc(data.getvalue())
+ logger.exception('RawServer exception occurred')
def set_handler(self, handler, port = None):
"""Set the handler to use for a port (or the default handler).
Modified: debtorrent/trunk/DebTorrent/download_bt1.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/download_bt1.py?rev=198&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/download_bt1.py (original)
+++ debtorrent/trunk/DebTorrent/download_bt1.py Sat Aug 4 23:02:03 2007
@@ -6,6 +6,8 @@
"""Manage a single download.
+ at type logger: C{logging.Logger}
+ at var logger: the logger to send all log messages to for this module
@type defaults: C{list} of (C{string}, unknown, C{string})
@var defaults: the default configuration variables, including descriptions
@type argslistheader: C{string}
@@ -47,13 +49,15 @@
from BT1.makemetafile import getpieces, getsubpieces, uniconvert, convert_all
from gzip import GzipFile
from StringIO import StringIO
-import binascii
+import binascii, logging
try:
True
except:
True = 1
False = 0
+
+logger = logging.getLogger('DebTorrent.download_bt1')
defaults = [
# Not in the config file
@@ -278,7 +282,7 @@
return (argslistheader + formatDefinitions(defaults, cols, presets))
-def get_response(file, url, errorfunc, separate_all = 0,
+def get_response(file, url, separate_all = 0,
default_tracker = 'http://dttracker.debian.net:6969/announce'):
"""Get the response data from a metainfo or Packages file.
@@ -291,8 +295,6 @@
to be used
@type url: C{string}
@param url: the URL to download the metainfo file from
- @type errorfunc: C{function}
- @param errorfunc: the function to use to print any error messages
@type separate_all: C{int}
@param separate_all: whether to separate the architecture:all packages into
a separate torrent (optional, defaults to no)
@@ -309,14 +311,14 @@
try:
check_message(response)
except ValueError, e:
- errorfunc("got bad file info - " + str(e))
+ logger.exception("got bad file info")
return (None, None)
return (response, response_all)
if response_all:
try:
check_message(response_all)
except ValueError, e:
- errorfunc("got bad file info - " + str(e))
+ logger.exception("got bad file info")
return (None, None)
return (response, response_all)
try:
@@ -328,7 +330,7 @@
assert front[0] == 'd'
int(front[1:])
except:
- errorfunc(file+' is not a valid responsefile')
+ logger.exception(file+' is not a valid responsefile')
return (None, None)
try:
h.seek(0)
@@ -342,12 +344,12 @@
try:
h = urlopen(url)
except:
- errorfunc(url+' bad url')
+ logger.exception(url+' bad url')
return (None, None)
response = h.read()
except IOError, e:
- errorfunc('problem getting response info - ' + str(e))
+ logger.eexception('problem getting response info')
return (None, None)
try:
h.close()
@@ -357,11 +359,11 @@
try:
response = bdecode(response)
except:
- errorfunc("warning: bad data in responsefile")
+ logger.warning("bad data in responsefile, switching to sloppy decoding")
response = bdecode(response, sloppy=1)
check_message(response)
except ValueError, e:
- errorfunc("got bad file info - " + str(e))
+ logger.exception("got bad file info")
return (None, None)
return (response, None)
@@ -396,7 +398,7 @@
break
assert line[:8] == "Package:"
except:
-# errorfunc(file+' is not a valid Packages file')
+ logger.warning(file+' is not a valid Packages file')
return (None, None)
try:
h.seek(0)
@@ -423,7 +425,7 @@
assert data[:8] == "Package:"
h = data.split('\n')
except:
-# errorfunc(url+' bad url')
+ logger.warning(url+' bad url')
return (None, None)
sub_pieces = getsubpieces(name)
@@ -443,7 +445,7 @@
'name': uniconvert(convert_all(name))}
except IOError, e:
-# errorfunc('problem getting Packages info - ' + str(e))
+ logger.exception('problem getting Packages info')
return (None, None)
try:
h.close()
@@ -462,8 +464,6 @@
@ivar finfunc: the method to call when the download is completed
@type errorfunc: C{method}
@ivar errorfunc: the method to call when an error occurs
- @type excfunc: C{method}
- @ivar excfunc: the method to call when an exception occurs
@type doneflag: C{threading.Event}
@ivar doneflag: the flag that indicates when the program is to be shutdown
@type config: C{dictionary}
@@ -556,7 +556,7 @@
"""
- def __init__(self, statusfunc, finfunc, errorfunc, excfunc, doneflag,
+ def __init__(self, statusfunc, finfunc, errorfunc, doneflag,
config, response, infohash, id, rawserver, port,
appdataobj):
"""Initialize the instance.
@@ -567,8 +567,6 @@
@param finfunc: the method to call when the download is completed
@type errorfunc: C{method}
@param errorfunc: the method to call when an error occurs
- @type excfunc: C{method}
- @param excfunc: the method to call when an exception occurs
@type doneflag: C{threading.Event}
@param doneflag: the flag that indicates when the program is to be shutdown
@type config: C{dictionary}
@@ -591,7 +589,6 @@
self.statusfunc = statusfunc
self.finfunc = finfunc
self.errorfunc = errorfunc
- self.excfunc = excfunc
self.doneflag = doneflag
self.config = config
self.response = response
@@ -705,6 +702,7 @@
existing = 0
if path.exists(file):
if not path.isdir(file):
+ logger.error(file + 'is not a dir')
self.errorfunc(file + 'is not a dir')
return None
# Don't create a directory with the default name within it
@@ -718,6 +716,7 @@
# if file[-8:] == '.dtorrent':
# file = file[:-8]
# if path.exists(file) and not path.isdir(file):
+# logger.error("Can't create dir - " + self.response['name'])
# self.errorfunc("Can't create dir - " + self.response['name'])
# return None
make(file, True)
@@ -735,6 +734,7 @@
#Move directory creation to Storage
#make(n)
except OSError, e:
+ logger.exception("Couldn't allocate dir")
self.errorfunc("Couldn't allocate dir - " + str(e))
return None
@@ -767,6 +767,7 @@
try:
self.storage.set_readonly()
except (IOError, OSError), e:
+ logger.exception('trouble setting readonly at end')
self.errorfunc('trouble setting readonly at end - ' + str(e))
if self.superseedflag.isSet():
self._set_super_seed()
@@ -789,6 +790,7 @@
self.ratemeasure_datarejected(amount)
if not self.doneflag.isSet():
+ logger.warning('piece %d failed hash check, re-downloading it', index)
self.errorfunc('piece %d failed hash check, re-downloading it' % index)
def _failed(self, reason):
@@ -802,10 +804,11 @@
self.failed = True
self.doneflag.set()
if reason is not None:
+ logger.critical(reason)
self.errorfunc(reason)
- def initFiles(self, old_style = False, statusfunc = None):
+ def initFiles(self, old_style = False):
"""Initialize the files for the download.
Initialize the priorities, then create the Storage, StorageWrapper,
@@ -814,9 +817,6 @@
@type old_style: C{boolean}
@param old_style: whether to use the old-style StorageWrapper
initialization (optional, defaults to False)
- @type statusfunc: C{method}
- @param statusfunc: the method to use to diplay status updates
- (optional, defaults to using L{statusfunc}
@rtype: C{boolean}
@return: whether the initialization was successful
@@ -824,8 +824,6 @@
if self.doneflag.isSet():
return None
- if not statusfunc:
- statusfunc = self.statusfunc
disabled_files = None
data = self.appdataobj.getTorrentData(self.infohash)
@@ -841,6 +839,7 @@
self.storage = Storage(self.files, self.piece_lengths,
self.doneflag, self.config, disabled_files)
except IOError, e:
+ logger.exception('trouble accessing files')
self.errorfunc('trouble accessing files - ' + str(e))
return None
if self.doneflag.isSet():
@@ -848,7 +847,7 @@
self.storagewrapper = StorageWrapper(self.storage, self.config['download_slice_size'],
self.pieces, self.piece_lengths, self.datalength, self._finished, self._failed,
- statusfunc, self.doneflag, self.config['check_hashes'],
+ self.statusfunc, self.doneflag, self.config['check_hashes'],
self._data_flunked, self.rawserver.add_task,
self.config, self.unpauseflag)
@@ -991,7 +990,7 @@
self.downloader.requeue_piece_download(pieces)
- def startEngine(self, ratelimiter = None, statusfunc = None):
+ def startEngine(self, ratelimiter = None):
"""Start various downloader engines.
Starts the upload and download L{CurrentRateMeasure.Measure},
@@ -1002,9 +1001,6 @@
@type ratelimiter: L{RateLimiter.RateLimiter}
@param ratelimiter: the RateLimiter instance to use
(optional, defaults to starting a new one)
- @type statusfunc: C{method}
- @param statusfunc: the method to call to report the current status
- (optional, defaults to L{statusfunc}
@rtype: C{boolean}
@return: whether the engines were started
@@ -1012,13 +1008,12 @@
if self.doneflag.isSet():
return False
- if not statusfunc:
- statusfunc = self.statusfunc
self.checking = False
if not CRYPTO_OK:
if self.config['crypto_allowed']:
+ logger.warning('crypto library not installed')
self.errorfunc('warning - crypto library not installed')
self.config['crypto_allowed'] = 0
self.config['crypto_only'] = 0
@@ -1126,7 +1121,7 @@
self.rerequest = Rerequester(self.port, self.myid, self.infohash,
trackerlist, self.config,
self.rawserver.add_task, self.rawserver.add_task,
- self.errorfunc, self.excfunc,
+ self.errorfunc,
self.encoder.start_connections,
self.connecter.how_many_connections,
self.storagewrapper.get_amount_left,
@@ -1479,8 +1474,10 @@
"""Change the upload into super-seed mode."""
if not self.super_seeding_active:
self.super_seeding_active = True
- self.errorfunc(' ** SUPER-SEED OPERATION ACTIVE **\n' +
- ' please set Max uploads so each peer gets 6-8 kB/s')
+ logger.info('SUPER-SEED OPERATION ACTIVE: ' +
+ 'please set Max uploads so each peer gets 6-8 kB/s')
+ self.errorfunc('SUPER-SEED OPERATION ACTIVE: ' +
+ 'please set Max uploads so each peer gets 6-8 kB/s')
def s(self = self):
"""Worker function to actually change to super-seed.
Modified: debtorrent/trunk/DebTorrent/inifile.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/inifile.py?rev=198&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/inifile.py (original)
+++ debtorrent/trunk/DebTorrent/inifile.py Sat Aug 4 23:02:03 2007
@@ -134,14 +134,11 @@
logger.error('('+str(lineno)+') '+err+': '+line)
-def ini_read(f, errfunc = errfunc):
+def ini_read(f):
"""Read the ini file.
@type f: C{string}
@param f: the file name to read
- @type errfunc: C{function}
- @param errfunc: the function to call when an error occurs
- (optional, default is to log an error message)
@rtype: C{dictionary}
@return: the data read from the ini file
Modified: debtorrent/trunk/DebTorrent/launchmanycore.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/launchmanycore.py?rev=198&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/launchmanycore.py (original)
+++ debtorrent/trunk/DebTorrent/launchmanycore.py Sat Aug 4 23:02:03 2007
@@ -144,8 +144,8 @@
self.rawserver = controller.handler.newRawServer(hash, self.doneflag)
- d = BT1Download(self.display, self.finished, self.error,
- controller.exchandler, self.doneflag, config, response,
+ d = BT1Download(self.update_status, self.finished, self.error,
+ self.doneflag, config, response,
hash, myid, self.rawserver, controller.listen_port,
self.controller.configdir)
self.d = d
@@ -246,8 +246,8 @@
self.controller.died(self.hash)
- def display(self, activity = None, fractionDone = None):
- """Update the current activity's status for later display.
+ def update_status(self, activity = None, fractionDone = None):
+ """Update the current activity's status.
Really only used by StorageWrapper now.
@@ -348,8 +348,7 @@
self.hashcheck_current = None
self.rawserver = RawServer(self.doneflag, config['timeout_check_interval'],
- config['timeout'], ipv6_enable = config['ipv6_enabled'],
- failfunc = self.failed, errorfunc = self.exchandler)
+ config['timeout'], ipv6_enable = config['ipv6_enabled'])
self.listen_port = self.rawserver.find_and_bind(
config['minport'], config['maxport'], config['bind'],
@@ -734,26 +733,6 @@
if self.hashcheck_queue:
self._hashcheck_start()
- def failed(self, s):
- """Indicate to the Output that a failure has occurred.
-
- @type s: C{string}
- @param s: the failure message
-
- """
-
- logger.error('FAILURE: '+s)
-
- def exchandler(self, s):
- """Indicate to the Output that an exception has occurred.
-
- @type s: C{string}
- @param s: the exception that occurred
-
- """
-
- logger.error('SYSTEM ERROR - EXCEPTION GENERATED\n'+s)
-
def pickle(self):
"""Save the current state of the downloads to a writable state.
Modified: debtorrent/trunk/DebTorrent/parsedir.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/parsedir.py?rev=198&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/parsedir.py (original)
+++ debtorrent/trunk/DebTorrent/parsedir.py Sat Aug 4 23:02:03 2007
@@ -25,19 +25,9 @@
logger = logging.getLogger('DebTorrent.parsedir')
-def _errfunc(x):
- """The default output printing function to use.
-
- @type x: C{string}
- @param x: the output message to print
-
- """
-
- logger.error(":: "+x)
-
def parsedir(directory, parsed, files, blocked,
exts = ['dtorrent'],
- return_metainfo = False, errfunc = _errfunc):
+ return_metainfo = False):
"""Parse a directory for torrent files.
Only works for .dtorrent files, it will not find or properly parse
@@ -57,9 +47,6 @@
@type return_metainfo: C{boolean}
@param return_metainfo: whether to return the torrent metainfo
(optional, defaults to False)
- @type errfunc: C{method}
- @param errfunc: the method to call to print status/warning/error messages
- (optional, defaults to the L{_errfunc} function)
@rtype: (C{dictionary}, C{dictionary}, C{dictionary}, C{dictionary}, C{dictionary})
@return: the cache of all torrents ever found, all the files found, all
the files blocked, the new torrents that were found, the torrents
@@ -67,8 +54,7 @@
"""
- if NOISY:
- errfunc('checking dir')
+ logger.info('checking dir')
dirs_to_check = [directory]
new_files = {}
new_blocked = {}
@@ -116,8 +102,7 @@
new_blocked[p] = 1 # same broken unparseable file
continue
if parsed.has_key(h) and not blocked.has_key(p):
- if NOISY:
- errfunc('removing '+p+' (will re-add)')
+ logger.debug('removing '+p+' (will re-add)')
removed[h] = parsed[h]
to_add.append(p)
@@ -127,20 +112,17 @@
v,h = new_file
if new_parsed.has_key(h): # duplicate
if not blocked.has_key(p) or files[p][0] != v:
- errfunc('**warning** '+
- p +' is a duplicate torrent for '+new_parsed[h]['path'])
+ logger.warning(p+' is a duplicate torrent for '+new_parsed[h]['path'])
new_blocked[p] = 1
continue
- if NOISY:
- errfunc('adding '+p)
+ logger.debug('adding '+p)
try:
- (d, garbage) = get_response(p, '', errfunc)
+ (d, garbage) = get_response(p, '')
h = sha(bencode(d['info'])).digest()
new_file[1] = h
if new_parsed.has_key(h):
- errfunc('**warning** '+
- p +' is a duplicate torrent for '+new_parsed[h]['path'])
+ logger.warning(p+' is a duplicate torrent for '+new_parsed[h]['path'])
new_blocked[p] = 1
continue
@@ -185,21 +167,18 @@
if return_metainfo:
a['metainfo'] = d
except:
- errfunc('**warning** '+p+' has errors')
+ logger.exception(p+' has errors')
new_blocked[p] = 1
continue
- if NOISY:
- errfunc('... successful')
+ logger.debug('... successful')
new_parsed[h] = a
added[h] = a
for p,v in files.items(): # and finally, mark removed torrents
if not new_files.has_key(p) and not blocked.has_key(p):
- if NOISY:
- errfunc('removing '+p)
+ logger.info('removing '+p)
removed[v[1]] = parsed[v[1]]
- if NOISY:
- errfunc('done checking')
+ logger.info('done checking')
return (new_parsed, new_files, new_blocked, added, removed)
Modified: debtorrent/trunk/debtorrent-client.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/debtorrent-client.py?rev=198&op=diff
==============================================================================
--- debtorrent/trunk/debtorrent-client.py (original)
+++ debtorrent/trunk/debtorrent-client.py Sat Aug 4 23:02:03 2007
@@ -36,7 +36,7 @@
def run(params):
"""Runs the downloader.
- The main function used to create the displayer and start the download.
+ The main function used to initialize the environment and create the controller.
@type params: C{list} of C{strings}
@param params: a list of the command-line arguments given to the script
More information about the Debtorrent-commits
mailing list