r146 - in /debtorrent/trunk: DebTorrent/BT1/AptListener.py DebTorrent/download_bt1.py config.debtorrent.ini
camrdale-guest at users.alioth.debian.org
camrdale-guest at users.alioth.debian.org
Tue Jul 10 23:21:01 UTC 2007
Author: camrdale-guest
Date: Tue Jul 10 23:21:01 2007
New Revision: 146
URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=146
Log:
Remove the state file from AptListener.
Modified:
debtorrent/trunk/DebTorrent/BT1/AptListener.py
debtorrent/trunk/DebTorrent/download_bt1.py
debtorrent/trunk/config.debtorrent.ini
Modified: debtorrent/trunk/DebTorrent/BT1/AptListener.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/AptListener.py?rev=146&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/AptListener.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/AptListener.py Tue Jul 10 23:21:01 2007
@@ -56,47 +56,6 @@
VERSION = product_name+'/'+version_short
-def statefiletemplate(x):
- """Check the saved state file for corruption.
-
- @type x: C{dictionary}
- @param x: the dictionary of information retrieved from the state file
- @raise ValueError: if the state file info is corrupt
-
- """
-
- if type(x) != DictType:
- raise ValueError
- for cname, cinfo in x.items():
- if cname == 'peers':
- for y in cinfo.values(): # The 'peers' key is a dictionary of SHA hashes (torrent ids)
- if type(y) != DictType: # ... for the active torrents, and each is a dictionary
- raise ValueError
- for id, info in y.items(): # ... of client ids interested in that torrent
- if (len(id) != 20):
- raise ValueError
- if type(info) != DictType: # ... each of which is also a dictionary
- raise ValueError # ... which has an IP, a Port, and a Bytes Left count for that client for that torrent
- if type(info.get('ip', '')) != StringType:
- raise ValueError
- port = info.get('port')
- if type(port) not in (IntType,LongType) or port < 0:
- raise ValueError
- left = info.get('left')
- if type(left) not in (IntType,LongType) or left < 0:
- raise ValueError
- if type(info.get('supportcrypto')) not in (IntType,LongType):
- raise ValueError
- if type(info.get('requirecrypto')) not in (IntType,LongType):
- raise ValueError
- elif cname == 'completed':
- if (type(cinfo) != DictType): # The 'completed' key is a dictionary of SHA hashes (torrent ids)
- raise ValueError # ... for keeping track of the total completions per torrent
- for y in cinfo.values(): # ... each torrent has an integer value
- if type(y) not in (IntType,LongType):
- raise ValueError # ... for the number of reported completions for that torrent
-
-
alas = 'your file may exist elsewhere in the universe\nbut alas, not here\n'
@@ -122,11 +81,9 @@
@ivar handler: the download handler to use
@type config: C{dictionary}
@ivar config: the configuration parameters
- @type dfile: C{string}
- @ivar dfile: the state file to use when saving the current state
@type parse_dir_interval: C{int}
- @ivar parse_dir_interval: seconds between reloading of the allowed
- directory or file, and the lists of allowed and banned IPs
+ @ivar parse_dir_interval: seconds between reloading of the
+ lists of allowed and banned IPs
@type favicon: C{string}
@ivar favicon: file containing x-icon data
@type rawserver: L{DebTorrent.RawServer}
@@ -145,8 +102,6 @@
@ivar banned_ip_mtime: unknown
@type trackerid: unknown
@ivar trackerid: unknown
- @type save_dfile_interval: C{int}
- @ivar save_dfile_interval: seconds between saving the state file
@type prevtime: unknown
@ivar prevtime: unknown
@type logfile: unknown
@@ -189,7 +144,6 @@
self.handler = handler
self.config = config
- self.dfile = config['dfile']
favicon = config['favicon']
self.parse_dir_interval = config['apt_parse_dir_interval']
self.favicon = None
@@ -211,24 +165,9 @@
self.banned_ip_mtime = 0
self.read_ip_lists()
- if exists(self.dfile):
- try:
- h = open(self.dfile, 'rb')
- ds = h.read()
- h.close()
- tempstate = bdecode(ds)
- if not tempstate.has_key('peers'):
- tempstate = {'peers': tempstate}
- statefiletemplate(tempstate)
- self.state = tempstate
- except:
- print '**warning** statefile '+self.dfile+' corrupt; resetting'
-
self.trackerid = createPeerID('-T-')
seed(self.trackerid)
- self.save_dfile_interval = config['save_dfile_interval']
- #rawserver.add_task(self.save_state, self.save_dfile_interval)
self.prevtime = clock()
self.logfile = None
self.log = None
@@ -745,22 +684,6 @@
'you sent me garbage - ' + str(e))
- def remove_from_state(self, *l):
- """Remove all the input parameter names from the current state."""
- for s in l:
- try:
- del self.state[s]
- except:
- pass
-
- def save_state(self):
- """Save the state file to disk."""
- self.rawserver.add_task(self.save_state, self.save_dfile_interval)
- h = open(self.dfile, 'wb')
- h.write(bencode(self.state))
- h.close()
-
-
def read_ip_lists(self):
"""Periodically parse the allowed and banned IPs lists."""
self.rawserver.add_task(self.read_ip_lists,self.parse_dir_interval)
Modified: debtorrent/trunk/DebTorrent/download_bt1.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/download_bt1.py?rev=146&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/download_bt1.py (original)
+++ debtorrent/trunk/DebTorrent/download_bt1.py Tue Jul 10 23:21:01 2007
@@ -185,8 +185,6 @@
"minutes between automatic flushes to disk (0 = disabled)"),
('dedicated_seed_id', '',
"code to send to tracker identifying as a dedicated seed"),
- ('dfile', '', 'file to store recent apt downloader info in'),
- ('save_dfile_interval', 5 * 60, 'seconds between saving dfile'),
('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'),
Modified: debtorrent/trunk/config.debtorrent.ini
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/config.debtorrent.ini?rev=146&op=diff
==============================================================================
--- debtorrent/trunk/config.debtorrent.ini (original)
+++ debtorrent/trunk/config.debtorrent.ini Tue Jul 10 23:21:01 2007
@@ -171,15 +171,6 @@
# ipv6_binds_v4 = 0
#
-# Expire Cache Data
-#
-# The number of days after which you wish to expire old cache data
-# (0 = disabled).
-#
-
-# expire_cache_data = 10
-
-#
# Timeout
#
# Time to wait between closing sockets which nothing has been received on
@@ -230,6 +221,14 @@
#
# max_initiate = 40
+
+#
+# Maximum Connections
+#
+# The absolute maximum number of peers to connect with (0 = no limit).
+#
+
+# max_connections = 0
#
# HTTP Timeout
@@ -332,6 +331,80 @@
#
###############################################################################
#
+# KeepAlive Interval
+#
+# The number of seconds to pause between sending keepalive message to peers.
+#
+
+# keepalive_interval = 120.0
+
+#
+# Download Slice Size
+#
+# The number of bytes to ask a peer for in a request.
+#
+
+# download_slice_size = 16384
+
+#
+# Maximum Message Length
+#
+# The maximum length (in bytes) prefix encoding you'll accept over the wire.
+# Larger values get the connection dropped.
+#
+
+# max_message_length = 8388608
+
+#
+# Maximum Slice Length
+#
+# The maximum length slice to send to peers, in bytes, larger requests are
+# ignored.
+#
+
+# max_slice_length = 131072
+
+#
+# Rarest First Cutoff
+#
+# The number of downloaded pieces at which to switch from random piece
+# selection to a rarest first piece policy.
+#
+
+# rarest_first_cutoff = 2
+
+#
+# Rarest First Priority Cutoff
+#
+# The number of peers which need to have a piece before completing other
+# partial pieces takes priority over the rarest first piece policy.
+#
+
+# rarest_first_priority_cutoff = 5
+
+#
+# Breakup Seed Bitfield
+#
+# Whether to send an incomplete bitfield and then fill it in with have
+# messages, instead of sending a complete (all 1's) bitfield. This is used
+# in order to get around some stupid ISP manipulations.
+#
+
+# breakup_seed_bitfield = 1
+
+#
+# Snub Time
+#
+# The number of seconds to wait for data to come in over a connection before
+# assuming it's semi-permanently choked.
+#
+
+# snub_time = 30.0
+
+###############################################################################
+# I N C E N T I V E M E C H A N I S M
+###############################################################################
+#
# Max Uploads
#
# The maximum number of peers to upload to at once.
@@ -340,77 +413,6 @@
# max_uploads = 7
#
-# KeepAlive Interval
-#
-# The number of seconds to pause between sending keepalive message to peers.
-#
-
-# keepalive_interval = 120.0
-
-#
-# Download Slice Size
-#
-# The number of bytes to ask a peer for in a request.
-#
-
-# download_slice_size = 16384
-
-#
-# Maximum Message Length
-#
-# The maximum length (in bytes) prefix encoding you'll accept over the wire.
-# Larger values get the connection dropped.
-#
-
-# max_message_length = 8388608
-
-#
-# Maximum Slice Length
-#
-# The maximum length slice to send to peers, in bytes, larger requests are
-# ignored.
-#
-
-# max_slice_length = 131072
-
-#
-# Rarest First Cutoff
-#
-# The number of downloaded pieces at which to switch from random piece
-# selection to a rarest first piece policy.
-#
-
-# rarest_first_cutoff = 2
-
-#
-# Rarest First Priority Cutoff
-#
-# The number of peers which need to have a piece before completing other
-# partial pieces takes priority over the rarest first piece policy.
-#
-
-# rarest_first_priority_cutoff = 5
-
-#
-# Breakup Seed Bitfield
-#
-# Whether to send an incomplete bitfield and then fill it in with have
-# messages, instead of sending a complete (all 1's) bitfield. This is used
-# in order to get around some stupid ISP manipulations.
-#
-
-# breakup_seed_bitfield = 1
-
-#
-# Snub Time
-#
-# The number of seconds to wait for data to come in over a connection before
-# assuming it's semi-permanently choked.
-#
-
-# snub_time = 30.0
-
-#
# Minimum Uploads
#
# The number of uploads to fill out to with extra optimistic unchokes.
@@ -433,14 +435,6 @@
#
# security = 1
-
-#
-# Maximum Connections
-#
-# The absolute maximum number of peers to connect with (0 = no limit).
-#
-
-# max_connections = 0
#
# Auto Kick
@@ -528,6 +522,15 @@
#
# auto_flush = 0
+
+#
+# Expire Cache Data
+#
+# The number of days after which you wish to expire old cache data
+# (0 = disabled).
+#
+
+# expire_cache_data = 10
###############################################################################
# A D V A N C E D B I T T O R R E N T S T U F F
@@ -608,22 +611,6 @@
# min_time_between_log_flushes = 3.0
#
-# dfile
-#
-# The file to store recent apt downloader state in.
-#
-
-# dfile = ""
-
-#
-# Save dfile Interval
-#
-# The number of seconds between saving the dfile.
-#
-
-# save_dfile_interval = 300
-
-#
# HUP Monitor
#
# Whether to reopen the log file upon receipt of a HUP signal.
More information about the Debtorrent-commits
mailing list