Skip to content

Commit

Permalink
- Fixes for eta
Browse files Browse the repository at this point in the history
  • Loading branch information
arno committed Nov 2, 2007
1 parent 615b5b7 commit 42d7449
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 55 deletions.
2 changes: 1 addition & 1 deletion BitTornado/BT1/DownloaderFeedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def gather(self, displayfunc = None, getpeerlist=False):
s['time'] = 0
s['vod_prebuf_frac'] = 1.0
s['vod_playable'] = True
s['vod_playable_after'] = 0.0
s['vod_playable_after'] = 0.481
return s
s['down'] = self.downfunc()
obtained, desired, have = self.leftfunc()
Expand Down
7 changes: 1 addition & 6 deletions BitTornado/download_bt1.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,7 @@ def __init__(self, statusfunc, finfunc, errorfunc, excfunc, logerrorfunc, donefl
self.coordinator = None
self.rate_predictor = None
if self.config['role'] == 'coordinator':
if self.config['helpers_file'] == '':
self.coordinator = Coordinator(self.infohash, self.len_pieces)
else:
self.coordinator = Coordinator(self.infohash, self.len_pieces, self.config['helpers_file'])
self.coordinator = Coordinator(self.infohash, self.len_pieces)
if self.config['role'] == 'coordinator' or self.config['role'] == 'helper':
self.helper = Helper(self.infohash, self.len_pieces, self.config['coordinator_permid'], coordinator = self.coordinator)
self.config['role'] = ''
Expand Down Expand Up @@ -654,8 +651,6 @@ def _init_stats(self):
self.rerequest_lastfailed, self.filedatflag)
if self.info.has_key('files'):
self.statistics.set_dirstats(self.files, self.info['piece length'])
if self.config['spew']:
self.spewflag.set()

def autoStats(self, displayfunc = None):
if not displayfunc:
Expand Down
6 changes: 2 additions & 4 deletions Tribler/API/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@
'in order to get around stupid ISP manipulation'),
('snub_time', 30.0,
"seconds to wait for data to come in over a connection before assuming it's semi-permanently choked"),
('spew', 0,
"whether to display diagnostic info to stdout"),
# ('spew', 0,
# "whether to display diagnostic info to stdout"),
('rarest_first_cutoff', 2,
"number of downloads at which to switch from random to rarest first"),
('rarest_first_priority_cutoff', 5,
Expand Down Expand Up @@ -232,8 +232,6 @@
#
('role', '', # 'helper', 'coordinator' # MARKED FOR DELETION
"role of the peer in the download"),
('helpers_file', '', # MARKED FOR DELETION
"file with the list of friends"),
('coordinator_permid', '', # MARKED FOR DELETION
"PermID of the cooperative download coordinator"),
('exclude_ips', '', # MARKED FOR DELETION
Expand Down
2 changes: 1 addition & 1 deletion Tribler/API/launchmanycore.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def __init__(self, statusfunc, finfunc, errorfunc, excfunc, doneflag,

def save_as(self,name,length,saveas,isdir):
""" Return the local filename to which to save the file 'name' in the torrent """
print >>sys.stderr,"SingleDownload: save_as(",name,length,saveas,isdir,")"
print >>sys.stderr,"SingleDownload: save_as(",`name`,length,`saveas`,isdir,")"
try:
if not os.access(saveas,os.F_OK):
os.mkdir(saveas)
Expand Down
17 changes: 9 additions & 8 deletions Tribler/Video/VideoOnDemand.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,23 +1035,24 @@ def expected_playback_time(self):

if pieces_to_play <= 0:
return 0.0

bitrate = self.movieselector.bitrate

assert bitrate, "Bitrate should have been set by now"

return pieces_to_play * self.movieselector.piece_length / bitrate
if self.movieselector.bitrate is None or self.movieselector.bitrate == 0.0:
return float(2 ** 31)
return pieces_to_play * self.movieselector.piece_length / self.movieselector.bitrate

def expected_buffering_time(self):
""" Expected time required for buffering. """

return max( 0.0, self.expected_download_time() - self.expected_playback_time() )
#print >>sys.stderr,"EXPECT",self.expected_download_time(),self.expected_playback_time()
# Infinite minus infinite is still infinite
if self.expected_download_time() > float(2 ** 30) and self.expected_playback_time() > float(2 ** 30):
return float(2 ** 31)
return abs(self.expected_download_time() - self.expected_playback_time() )

def enough_buffer(self):
""" Returns True if we can safely start playback without expecting to run out of
buffer. """

return self.expected_buffering_time() == 0.0
return max(0.0,self.expected_download_time() - self.expected_playback_time() ) == 0.0

def tick_second(self):
self.rawserver.add_task( self.tick_second, 1.0 )
Expand Down
15 changes: 9 additions & 6 deletions Tribler/Video/VideoServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ def do_GET(self):
print >>sys.stderr,"videoserv: do_GET: Done sending data"

movie.stop()
#if self.server.statuscallback is not None:
# self.server.statuscallback("Done")
if self.server.statuscallback is not None:
self.server.statuscallback("Done")
#f.close()

except Exception,e:
Expand All @@ -334,10 +334,13 @@ def do_GET(self):
##f = open("/tmp/videoserv.log","w")
print_exc()
self.error(e,self.path)

##f.close()

def error(self,e,url):
if self.server.errorcallback is not None:
self.server.errorcallback(e,url)
else:
print_exc()
if self.server.errorcallback is not None:
self.server.errorcallback(e,url)
else:
print_exc()
if self.server.statuscallback is not None:
self.server.statuscallback("Error playing video")
26 changes: 1 addition & 25 deletions Tribler/toofastbt/Coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,14 @@

class Coordinator:

def __init__(self, torrent_hash, num_pieces, helpers_file = None):
def __init__(self, torrent_hash, num_pieces):
self.reserved_pieces = [False] * num_pieces
self.torrent_hash = torrent_hash
self.asked_helpers = []
# optimization
self.reserved = []
self.secure_overlay = SecureOverlay.getInstance()

# read helpers from file
if helpers_file is not None:

print >> sys.stderr,"Reading helpers from file currently not supported"

f = open(helpers_file, 'r')
while 1:
lines = f.readlines(100000)
if not lines:
break
for line in lines:
line = line.strip()
#-- exclude comment and empty lines
if (len(line) > 0) and (line[0] != '#'):
[ip, port] = line.split()
port = int(port)
# Add a peer comparable to those from cachedb2.py
peer = {}
peer['name'] = 'John Doe'
peer['permid'] = None
peer['ip'] = ip
peer['port'] = port
f.close()

def is_helper_permid(self, permid):
""" Used by HelperMessageHandler to check if RESERVE_PIECES is from good source """
for peer in self.asked_helpers:
Expand Down
1 change: 0 additions & 1 deletion abcengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def __init__(self, torrent, myid):
self.errormsgCallback( msg, "status")
else:
btconfig['role'] = 'coordinator'
btconfig['helpers_file'] = ''
# _2fastbt

# # TODO: setting check_hashes doesn't seem to work quite right
Expand Down
5 changes: 3 additions & 2 deletions p2player.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ def state_callback(self,ds):
m, s = divmod(t, 60.0)
if h == 0.0:
if m == 0.0:
intime = "%02ds" % (s)
intime = "%ds" % (s)
else:
intime = "%02dm:%02ds" % (m,s)
intime = "%dm:%02ds" % (m,s)
else:
intime = "%dh:%02dm:%02ds" % (h,m,s)

Expand All @@ -172,6 +172,7 @@ def state_callback(self,ds):
msg = "Prebuffering "+pstr+"% done, eta "+intime
elif playable:
msg = "Starting playback..."
print_stack()
else:
msg = "Waiting for sufficient download speed... "+intime
self.videoFrame.set_player_status(msg)
Expand Down
2 changes: 1 addition & 1 deletion triblerAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -1986,7 +1986,7 @@ def get_vod_playable(self):

def get_vod_playable_after(self):
if self.stats is None:
return False
return float(2 ** 31)
else:
return self.stats['vod_playable_after']

Expand Down

0 comments on commit 42d7449

Please sign in to comment.