def _on_get_session_status(self, status): self.download_rate = fspeed( status['payload_download_rate'], precision=0, shortform=True ) self.upload_rate = fspeed( status['payload_upload_rate'], precision=0, shortform=True ) self.download_protocol_rate = ( status['download_rate'] - status['payload_download_rate'] ) // 1024 self.upload_protocol_rate = ( status['upload_rate'] - status['payload_upload_rate'] ) // 1024 self.num_connections = status['num_peers'] self.update_download_label() self.update_upload_label() self.update_traffic_label() self.update_connections_label() if 'dht_nodes' in status: self.dht_nodes = status['dht_nodes'] self.update_dht_label() if 'has_incoming_connections' in status: self.health = status['has_incoming_connections'] if self.health: self.remove_item(self.health_item)
def show_peer_info(self, torrent_id, status): if len(status['peers']) == 0: self.console.write(' None') else: s = '' for peer in status['peers']: if peer['seed']: s += '%sSeed\t{!input!}' % colors.state_color['Seeding'] else: s += '%sPeer\t{!input!}' % colors.state_color['Downloading'] s += peer['country'] + '\t' if peer['ip'].count(':') == 1: # IPv4 s += peer['ip'] else: # IPv6 s += '[%s]:%s' % (':'.join(peer['ip'].split(':')[:-1]), peer['ip'].split(':')[-1]) c = peer['client'] s += '\t' + c if len(c) < 16: s += '\t\t' else: s += '\t' s += '%s%s\t%s%s' % ( colors.state_color['Seeding'], fspeed(peer['up_speed']), colors.state_color['Downloading'], fspeed(peer['down_speed'])) s += '\n' self.console.write(s[:-1])
def show_peer_info(self, torrent_id, status): if len(status["peers"]) == 0: self.console.write(" None") else: s = "" for peer in status["peers"]: if peer["seed"]: s += "%sSeed\t{!input!}" % colors.state_color["Seeding"] else: s += "%sPeer\t{!input!}" % colors.state_color["Downloading"] s += peer["country"] + "\t" if peer["ip"].count(":") == 1: # IPv4 s += peer["ip"] else: # IPv6 s += "[%s]:%s" % (":".join( peer["ip"].split(":")[:-1]), peer["ip"].split(":")[-1]) c = peer["client"] s += "\t" + c if len(c) < 16: s += "\t\t" else: s += "\t" s += "%s%s\t%s%s" % (colors.state_color["Seeding"], common.fspeed(peer["up_speed"]), colors.state_color["Downloading"], common.fspeed(peer["down_speed"])) s += "\n" self.console.write(s[:-1])
def show_peer_info(self, torrent_id, status): if len(status["peers"]) == 0: self.console.write(" None") else: s = "" for peer in status["peers"]: if peer["seed"]: s += "%sSeed\t{!input!}" % colors.state_color["Seeding"] else: s += "%sPeer\t{!input!}" % colors.state_color["Downloading"] s += peer["country"] + "\t" if peer["ip"].count(":") == 1: # IPv4 s += peer["ip"] else: # IPv6 s += "[%s]:%s" % (":".join(peer["ip"].split(":")[:-1]), peer["ip"].split(":")[-1]) c = peer["client"] s += "\t" + c if len(c) < 16: s += "\t\t" else: s += "\t" s += "%s%s\t%s%s" % ( colors.state_color["Seeding"], common.fspeed(peer["up_speed"]), colors.state_color["Downloading"], common.fspeed(peer["down_speed"])) s += "\n" self.console.write(s[:-1])
def print_status(self, *args): self.console.set_batch_write(True) if self.raw: self.console.write('{!info!}Total upload: %f' % self.status['payload_upload_rate']) self.console.write('{!info!}Total download: %f' % self.status['payload_download_rate']) else: self.console.write('{!info!}Total upload: %s' % fspeed(self.status['payload_upload_rate'])) self.console.write('{!info!}Total download: %s' % fspeed(self.status['payload_download_rate'])) self.console.write('{!info!}DHT Nodes: %i' % self.status['dht_nodes']) if isinstance(self.torrents, int): if self.torrents == -2: self.console.write('{!error!}Error getting torrent info') else: self.console.write('{!info!}Total torrents: %i' % len(self.torrents)) state_counts = {} for state in TORRENT_STATE: state_counts[state] = 0 for t in self.torrents: s = self.torrents[t] state_counts[s['state']] += 1 for state in TORRENT_STATE: self.console.write('{!info!} %s: %i' % (state, state_counts[state])) self.console.set_batch_write(False)
def _on_get_session_status(status): download_rate = fspeed(status['payload_download_rate'], precision=0, shortform=True) upload_rate = fspeed(status['payload_upload_rate'], precision=0, shortform=True) self.window.set_title( _('D: %s U: %s - Deluge' % (download_rate, upload_rate)))
def _on_get_session_status(status): download_rate = fspeed(status['payload_download_rate'], precision=0, shortform=True) upload_rate = fspeed(status['payload_upload_rate'], precision=0, shortform=True) self.window.set_title( _('D: {download_rate} U: {upload_rate} - Deluge').format( download_rate=download_rate, upload_rate=upload_rate))
def log_rpc_stats(self): """Log RPC statistics for thinclient mode.""" if not client.connected(): return t = time.time() recv = client.get_bytes_recv() sent = client.get_bytes_sent() delta_time = t - self.daemon_bps[0] delta_sent = sent - self.daemon_bps[1] delta_recv = recv - self.daemon_bps[2] self.daemon_bps = (t, sent, recv) sent_rate = fspeed(delta_sent / delta_time) recv_rate = fspeed(delta_recv / delta_time) log.debug('RPC: Sent %s (%s) Recv %s (%s)', fsize(sent), sent_rate, fsize(recv), recv_rate)
def _on_get_session_status(self, status): self.download_rate = fspeed(status['payload_download_rate'], precision=0, shortform=True) self.upload_rate = fspeed(status['payload_upload_rate'], precision=0, shortform=True) self.download_protocol_rate = (status['download_rate'] - status['payload_download_rate']) // 1024 self.upload_protocol_rate = (status['upload_rate'] - status['payload_upload_rate']) // 1024 self.num_connections = status['num_peers'] self.update_download_label() self.update_upload_label() self.update_traffic_label() self.update_connections_label() if 'dht_nodes' in status: self.dht_nodes = status['dht_nodes'] self.update_dht_label() if 'has_incoming_connections' in status: self.health = status['has_incoming_connections'] if self.health: self.remove_item(self.health_item)
def cell_data_speed(cell, model, row, data): """Display value as a speed, eg. 2 KiB/s""" speed = model.get_value(row, data) if speed > 0: speed_str = common.fspeed(speed, shortform=True) cell.set_property( 'markup', '{0} <small>{1}</small>'.format(*tuple(speed_str.split()))) else: cell.set_property('text', '')
def show_peer_info(self, torrent_id, status): if len(status['peers']) == 0: self.console.write(' None') else: s = '' for peer in status['peers']: if peer['seed']: s += '%sSeed\t{!input!}' % colors.state_color['Seeding'] else: s += '%sPeer\t{!input!}' % colors.state_color['Downloading'] s += peer['country'] + '\t' if peer['ip'].count(':') == 1: # IPv4 s += peer['ip'] else: # IPv6 s += '[%s]:%s' % ( ':'.join(peer['ip'].split(':')[:-1]), peer['ip'].split(':')[-1], ) c = peer['client'] s += '\t' + c if len(c) < 16: s += '\t\t' else: s += '\t' s += '%s%s\t%s%s' % ( colors.state_color['Seeding'], fspeed(peer['up_speed']), colors.state_color['Downloading'], fspeed(peer['down_speed']), ) s += '\n' self.console.write(s[:-1])
def cell_data_speed_limit(cell, model, row, data, cache_key): """Display value as a speed, eg. 2 KiB/s""" speed = model.get_value(row, data) if func_last_value[cache_key] == speed: return func_last_value[cache_key] = speed if speed > 0: speed_str = common.fspeed(speed * 1024, shortform=True) cell.set_property('markup', '{0} <small>{1}</small>'.format(*tuple(speed_str.split()))) else: cell.set_property('text', '')
def cell_data_speed_limit(cell, model, row, data, cache_key): """Display value as a speed, eg. 2 KiB/s""" speed = model.get_value(row, data) if func_last_value[cache_key] == speed: return func_last_value[cache_key] = speed if speed > 0: speed_str = common.fspeed(speed * 1024, shortform=True) cell.set_property( 'markup', '{0} <small>{1}</small>'.format(*tuple(speed_str.split()))) else: cell.set_property('text', '')
def cell_data_speed(cell, model, row, data, cache_key): """Display value as a speed, eg. 2 KiB/s""" try: speed = model.get_value(row, data) except AttributeError: print('AttributeError') import traceback traceback.print_exc() if func_last_value[cache_key] == speed: return func_last_value[cache_key] = speed if speed > 0: speed_str = common.fspeed(speed, shortform=True) cell.set_property('markup', '{0} <small>{1}</small>'.format(*tuple(speed_str.split()))) else: cell.set_property('text', '')
def cell_data_speed(cell, model, row, data, cache_key): """Display value as a speed, eg. 2 KiB/s""" try: speed = model.get_value(row, data) except AttributeError: print('AttributeError') import traceback traceback.print_exc() if func_last_value[cache_key] == speed: return func_last_value[cache_key] = speed if speed > 0: speed_str = common.fspeed(speed, shortform=True) cell.set_property( 'markup', '{0} <small>{1}</small>'.format(*tuple(speed_str.split()))) else: cell.set_property('text', '')
def fspeed_shortform(value): return fspeed(value, shortform=True)
def show_info(self, torrent_id, status, verbose=False): """ Writes out the torrents information to the screen. :param torrent_id: str, the torrent_id :param status: dict, the torrents status, this should have the same keys as status_keys :param verbose: bool, if true, we print out more information about the the torrent """ self.console.set_batch_write(True) self.console.write(" ") self.console.write("{!info!}Name: {!input!}%s" % (status["name"])) self.console.write("{!info!}ID: {!input!}%s" % (torrent_id)) s = "{!info!}State: %s%s" % (colors.state_color[status["state"]], status["state"]) # Only show speed if active if status["state"] in ("Seeding", "Downloading"): if status["state"] != "Seeding": s += " {!info!}Down Speed: {!input!}%s" % common.fspeed( status["download_payload_rate"]) s += " {!info!}Up Speed: {!input!}%s" % common.fspeed( status["upload_payload_rate"]) if common.ftime(status["eta"]): s += " {!info!}ETA: {!input!}%s" % common.ftime(status["eta"]) self.console.write(s) if status["state"] in ("Seeding", "Downloading", "Queued"): s = "{!info!}Seeds: {!input!}%s (%s)" % (status["num_seeds"], status["total_seeds"]) s += " {!info!}Peers: {!input!}%s (%s)" % (status["num_peers"], status["total_peers"]) s += " {!info!}Availability: {!input!}%.2f" % status[ "distributed_copies"] self.console.write(s) s = "{!info!}Size: {!input!}%s/%s" % (common.fsize( status["total_done"]), common.fsize(status["total_size"])) s += " {!info!}Ratio: {!input!}%.3f" % status["ratio"] self.console.write(s) s = "{!info!}Seed time: {!input!}%s" % format_time( status["seeding_time"]) s += " {!info!}Active: {!input!}%s" % format_time( status["active_time"]) self.console.write(s) self.console.write("{!info!}Tracker status: {!input!}%s" % status["tracker_status"]) if not status["is_finished"]: if hasattr(self.console, "screen"): cols = self.console.screen.cols else: cols = 80 pbar = format_progressbar( status["progress"], cols - (13 + len("%.2f%%" % status["progress"]))) s = "{!info!}Progress: {!input!}%.2f%% %s" % (status["progress"], pbar) self.console.write(s) if verbose: self.console.write(" {!info!}::Files") for i, f in enumerate(status["files"]): s = " {!input!}%s (%s)" % (f["path"], common.fsize( f["size"])) s += " {!info!}Progress: {!input!}%.2f%%" % ( status["file_progress"][i] * 100) s += " {!info!}Priority:" fp = common.FILE_PRIORITY[status["file_priorities"] [i]].replace("Priority", "") if fp == "Do Not Download": s += "{!error!}" else: s += "{!success!}" s += " %s" % (fp) # Check if this is too long for the screen and reduce the path # if necessary if hasattr(self.console, "screen"): cols = self.console.screen.cols slen = colors.get_line_length(s, self.console.screen.encoding) if slen > cols: s = s.replace(f["path"], f["path"][slen - cols + 1:]) self.console.write(s) self.console.write(" {!info!}::Peers") if len(status["peers"]) == 0: self.console.write(" None") else: s = "" for peer in status["peers"]: if peer["seed"]: s += "%sSeed\t{!input!}" % colors.state_color["Seeding"] else: s += "%sPeer\t{!input!}" % colors.state_color[ "Downloading"] s += peer["country"] + "\t" if peer["ip"].count(":") == 1: # IPv4 s += peer["ip"] else: # IPv6 s += "[%s]:%s" % (":".join(peer["ip"].split(":")[:-1]), peer["ip"].split(":")[-1]) c = peer["client"] s += "\t" + c if len(c) < 16: s += "\t\t" else: s += "\t" s += "%s%s\t%s%s" % (colors.state_color["Seeding"], common.fspeed(peer["up_speed"]), colors.state_color["Downloading"], common.fspeed(peer["down_speed"])) s += "\n" self.console.write(s[:-1]) self.console.set_batch_write(False)
def test_fspeed(self): self.assertTrue(fspeed(43134) == '42.1 KiB/s')
def writeOutput(self): try: self.logInfo("Proceeding with torrent data interpretation...") torrentDataList = [] torrentItemList = ["num_peers","num_seeds","name","state","total_done","total_size","total_wanted","progress","files","eta","download_payload_rate","upload_payload_rate","total_peers","total_seeds","ratio","queue"] highesteta = 0 # summary variables summary_notorrent = 0 summary_totaldone = 0 summary_totalsize = 0 summary_totaldownloadrate = 0.0 summary_totaluploadrate = 0.0 summary_totaleta = 0 summary_currentpeers = 0 summary_currentseeds = 0 summary_totalpeers = 0 summary_totalseeds = 0 summary_totalratio = 0.0 self.logInfo("Preparing templates...") if self.options.summarytemplate == None: # create default summary template summarytemplate = "Total Torrents Queued:[notorrents] \n[totaldone]/[totalsize] - [totalprogress]\n" + "DL: [totaldownloadrate] UL: [totaluploadrate]\n" else: # load the template file contents try: #fileinput = open(self.options.summarytemplate) fileinput = codecs.open(os.path.expanduser(self.options.summarytemplate), encoding='utf-8') summarytemplate = fileinput.read() fileinput.close() except: self.logError("Summary Template file no found!") sys.exit(2) if self.options.torrenttemplate == None: # create default template torrenttemplate = "[name]\n[state]\n[totaldone]/[totalsize] - [progress]\n" + "DL: [downloadrate] UL: [uploadrate] ETA:[eta]\n" else: # load the template file contents try: #fileinput = open(self.options.torrenttemplate) fileinput = codecs.open(os.path.expanduser(self.options.torrenttemplate), encoding='utf-8') torrenttemplate = fileinput.read() fileinput.close() except: self.logError("Torrent Template file no found!") sys.exit(2) if len(self.torrents_status) > 0: self.logInfo("Processing %s torrent(s)..."%str(len(self.torrents_status))) for torrentid in self.torrents_status: torrent_status = self.torrents_status[torrentid] if torrent_status != None: if self.options.activeonly == True: active = False # check for activity if "num_peers" in torrent_status: if torrent_status["num_peers"] > 0: active = True if "num_seeds" in torrent_status: if torrent_status["num_seeds"] > 0: active = True # output details if all required or if active if self.options.activeonly == False or active == True: if "name" in torrent_status: name = torrent_status["name"] else: name = "Unknown" if "state" in torrent_status: state = torrent_status["state"] if state == "Downloading": statecode = self.STATE_DOWNLOADING elif state == "Seeding": statecode = self.STATE_SEEDING elif state == "Queued": statecode = self.STATE_QUEUED elif state == "Paused": statecode = self.STATE_PAUSED else: statecode = self.STATE_UNKNOWN else: state = "Unknown" statecode = self.STATE_UNKNOWN if "total_done" in torrent_status: totaldone = fsize(torrent_status["total_done"]) summary_totaldone = summary_totaldone + int(torrent_status["total_done"]) else: totaldone = "??.? KiB" if "total_size" in torrent_status: totalsize = fsize(torrent_status["total_wanted"]) summary_totalsize = summary_totalsize + int(torrent_status["total_wanted"]) else: totalsize = "??.? KiB" if "progress" in torrent_status: progress = str(round(torrent_status["progress"],2))+"%" else: progress = "?.?%" if "files" in torrent_status: nofiles = str(len(torrent_status["files"])) else: nofiles = "?" if "eta" in torrent_status: eta = torrent_status["eta"] if eta > highesteta: highesteta = eta etatext = ftime(eta) else: eta = None etatext = "Unknown" if "download_payload_rate" in torrent_status: downloadrate = float(torrent_status["download_payload_rate"]) summary_totaldownloadrate = summary_totaldownloadrate + downloadrate downloadtext = fspeed(downloadrate) else: downloadrate = 0 downloadtext = "?.? KiB/s" if "upload_payload_rate" in torrent_status: uploadrate = float(torrent_status["upload_payload_rate"]) summary_totaluploadrate = summary_totaluploadrate + uploadrate uploadtext = fspeed(uploadrate) else: uploadrate = 0 uploadtext = "?.? KiB/s" if "num_peers" in torrent_status: currentpeers = str(torrent_status["num_peers"]) summary_currentpeers = summary_currentpeers + int(torrent_status["num_peers"]) else: currentpeers = "?" if "num_seeds" in torrent_status: currentseeds = str(torrent_status["num_seeds"]) summary_currentseeds = summary_currentseeds + int(torrent_status["num_seeds"]) else: currentseeds = "?" if "total_peers" in torrent_status: totalpeers = str(torrent_status["total_peers"]) summary_totalpeers = summary_totalpeers + int(torrent_status["total_peers"]) else: totalpeers = "?" if "total_seeds" in torrent_status: totalseeds = str(torrent_status["total_seeds"]) summary_totalseeds = summary_totalseeds + int(torrent_status["total_seeds"]) else: totalseeds = "?" if "ratio" in torrent_status: ratio = str(round(torrent_status["ratio"],3)).ljust(5,"0") else: ratio = "?.???" # for sorting in the same way as progress, we need to order from high to low if "queue" in torrent_status: queueorder = torrent_status["queue"] else: queueorder = -1 sortby = self.options.sortby summary_notorrent = summary_notorrent + 1 # add torrent data to list torrentData = TorrentData(name, state, statecode, totaldone, totalsize, progress, nofiles, downloadrate, downloadtext, uploadrate, uploadtext, eta, etatext, currentpeers, currentseeds, totalpeers, totalseeds, ratio, queueorder, sortby) torrentDataList.append(torrentData) else: self.logInfo("No torrent status data available for torrentid: "+torrentid) if summary_notorrent > 0: output = u"" if self.options.showsummary == True: # sort out summary data for output summary_notorrent = str(summary_notorrent) summary_totalprogress = str(round((float(summary_totaldone) / float(summary_totalsize)) *100,2))+"%" summary_totaldone = fsize(summary_totaldone) summary_totalsize = fsize(summary_totalsize) summary_totaldownloadrate = fspeed(summary_totaldownloadrate) summary_totaluploadrate = fspeed(summary_totaluploadrate) summary_totaleta = ftime(highesteta) summary_currentpeers = str(summary_currentpeers) summary_currentseeds = str(summary_currentseeds) summary_totalpeers = str(summary_totalpeers) summary_totalseeds = str(summary_totalseeds) summary_totalratio = "?.???" output = self.getSummaryTemplateOutput(summarytemplate, summary_notorrent, summary_totalprogress, summary_totaldone, summary_totalsize, summary_totaldownloadrate, summary_totaluploadrate, summary_totaleta, summary_currentpeers, summary_currentseeds, summary_totalpeers, summary_totalseeds, summary_totalratio) if self.options.hidetorrentdetail == False: outputCount = 0 # sort list, eta based self.logInfo("Sorting torrent list using: %s"%self.options.sortby) torrentDataList.sort(reverse = True) # output torrent data using the template for torrentData in torrentDataList: # keep a tally of torrent output, if past the limit then exit if self.options.limit <> 0: outputCount = outputCount + 1 if outputCount > self.options.limit: break output = output + self.getTorrentTemplateOutput(torrenttemplate, torrentData.name, torrentData.state, torrentData.totaldone, torrentData.totalsize, torrentData.progress, torrentData.nofiles, torrentData.downloadtext, torrentData.uploadtext, torrentData.etatext, torrentData.currentpeers, torrentData.currentseeds, torrentData.totalpeers, torrentData.totalseeds, torrentData.ratio)+"\n" print output.encode("utf-8") else: print u"No torrent info to display" else: self.logInfo("No torrents found") except Exception,e: self.logError("writeOutput:Unexpected error:" + e.__str__())
def show_info(self, torrent_id, status, verbose=False, detailed=False): """ Writes out the torrents information to the screen. Format depends on switches given. """ self.console.set_batch_write(True) if hasattr(self.console, "screen"): cols = self.console.screen.cols else: cols = 80 if verbose or detailed: self.console.write(" ") self.console.write("{!info!}Name: {!input!}%s" % (status["name"])) self.console.write("{!info!}ID: {!input!}%s" % (torrent_id)) s = "{!info!}State: %s%s" % (colors.state_color[status["state"]], status["state"]) # Only show speed if active if status["state"] in ("Seeding", "Downloading"): if status["state"] != "Seeding": s += " {!info!}Down Speed: {!input!}%s" % common.fspeed( status["download_payload_rate"]) s += " {!info!}Up Speed: {!input!}%s" % common.fspeed( status["upload_payload_rate"]) if common.ftime(status["eta"]): s += " {!info!}ETA: {!input!}%s" % common.ftime( status["eta"]) self.console.write(s) if status["state"] in ("Seeding", "Downloading", "Queued"): s = "{!info!}Seeds: {!input!}%s (%s)" % (status["num_seeds"], status["total_seeds"]) s += " {!info!}Peers: {!input!}%s (%s)" % ( status["num_peers"], status["total_peers"]) s += " {!info!}Availibility: {!input!}%.2f" % status[ "distributed_copies"] self.console.write(s) total_done = common.fsize(status["total_done"]) total_size = common.fsize(status["total_size"]) if total_done == total_size: s = "{!info!}Size: {!input!}%s" % (total_size) else: s = "{!info!}Size: {!input!}%s/%s" % (total_done, total_size) s += " {!info!}Ratio: {!input!}%.3f" % status["ratio"] s += " {!info!}Uploaded: {!input!}%s" % common.fsize( status["ratio"] * status["total_done"]) self.console.write(s) s = "{!info!}Tracker: {!input!}%s" % status["tracker"] self.console.write(s) if not status["is_finished"]: pbar = format_progressbar( status["progress"], cols - (13 + len("%.2f%%" % status["progress"]))) s = "{!info!}Progress: {!input!}%.2f%% %s" % ( status["progress"], pbar) self.console.write(s) s = "{!info!}Download location: {!input!}%s" % status["save_path"] self.console.write(s) if detailed: self.console.write("{!info!}Files in torrent") self.show_file_info(torrent_id, status) self.console.write("{!info!}Connected peers") self.show_peer_info(torrent_id, status) else: self.console.write(" ") up_color = colors.state_color["Seeding"] down_color = colors.state_color["Downloading"] s = "%s%s" % (colors.state_color[status["state"]], "[" + status["state"][0] + "]") s += " {!info!}" + ("%.2f%%" % status["progress"]).ljust(7, " ") s += " {!input!}%s" % (status["name"]) #Shorten the ID if it's necessary. Pretty hacky #I _REALLY_ should make a nice function for it that can partition and shorten stuff space_left = cols - strwidth("[s] 100.00% " + status["name"] + " " * 3) - 2 if space_left >= len(torrent_id) - 2: #There's enough space, print it s += " {!cyan!}%s" % torrent_id else: #Shorten the ID a = int(space_left * 2 / 3.0) b = space_left - a if a < 8: b = b - (8 - a) a = 8 if b < 0: a += b b = 0 if a > 8: #Print the shortened ID s += " {!cyan!}%s" % (torrent_id[0:a] + ".." + torrent_id[-b - 1:-1]) else: #It has wrapped over to the second row anyway s += " {!cyan!}%s" % torrent_id self.console.write(s) dl_info = "{!info!}DL: {!input!}" dl_info += "%s" % common.fsize(status["total_done"]) if status["total_done"] != status["total_size"]: dl_info += "/%s" % common.fsize(status["total_size"]) if status["download_payload_rate"] > 0: dl_info += " @ %s%s" % ( down_color, common.fspeed(status["download_payload_rate"])) ul_info = " {!info!}UL: {!input!}" ul_info += "%s" % common.fsize( status["ratio"] * status["total_done"]) if status["upload_payload_rate"] > 0: ul_info += " @ %s%s" % ( up_color, common.fspeed(status["upload_payload_rate"])) eta = "" if common.ftime(status["eta"]): eta = " {!info!}ETA: {!magenta!}%s" % common.ftime( status["eta"]) self.console.write(" " + dl_info + ul_info + eta) self.console.set_batch_write(False)
def show_info(self, torrent_id, status, verbose=False, detailed=False): """ Writes out the torrents information to the screen. Format depends on switches given. """ self.console.set_batch_write(True) if hasattr(self.console, "screen"): cols = self.console.screen.cols else: cols = 80 if verbose or detailed: self.console.write(" ") self.console.write("{!info!}Name: {!input!}%s" % (status["name"])) self.console.write("{!info!}ID: {!input!}%s" % (torrent_id)) s = "{!info!}State: %s%s" % (colors.state_color[status["state"]], status["state"]) # Only show speed if active if status["state"] in ("Seeding", "Downloading"): if status["state"] != "Seeding": s += " {!info!}Down Speed: {!input!}%s" % common.fspeed(status["download_payload_rate"]) s += " {!info!}Up Speed: {!input!}%s" % common.fspeed(status["upload_payload_rate"]) if common.ftime(status["eta"]): s += " {!info!}ETA: {!input!}%s" % common.ftime(status["eta"]) self.console.write(s) if status["state"] in ("Seeding", "Downloading", "Queued"): s = "{!info!}Seeds: {!input!}%s (%s)" % (status["num_seeds"], status["total_seeds"]) s += " {!info!}Peers: {!input!}%s (%s)" % (status["num_peers"], status["total_peers"]) s += " {!info!}Availibility: {!input!}%.2f" % status["distributed_copies"] self.console.write(s) total_done = common.fsize(status["total_done"]) total_size = common.fsize(status["total_size"]) if total_done == total_size: s = "{!info!}Size: {!input!}%s" % (total_size) else: s = "{!info!}Size: {!input!}%s/%s" % (total_done, total_size) s += " {!info!}Ratio: {!input!}%.3f" % status["ratio"] s += " {!info!}Uploaded: {!input!}%s" % common.fsize(status["ratio"] * status["total_done"]) self.console.write(s) s = "{!info!}Tracker: {!input!}%s" % status["tracker"] self.console.write(s) if not status["is_finished"]: pbar = format_progressbar(status["progress"], cols - (13 + len("%.2f%%" % status["progress"]))) s = "{!info!}Progress: {!input!}%.2f%% %s" % (status["progress"], pbar) self.console.write(s) s = "{!info!}Download location: {!input!}%s" % status["save_path"] self.console.write(s) if detailed: self.console.write("{!info!}Files in torrent") self.show_file_info(torrent_id, status) self.console.write("{!info!}Connected peers") self.show_peer_info(torrent_id, status) else: self.console.write(" ") up_color = colors.state_color["Seeding"] down_color = colors.state_color["Downloading"] s = "%s%s" % (colors.state_color[status["state"]], "[" + status["state"][0] + "]") s+= " {!info!}" + ("%.2f%%" % status["progress"]).ljust(7, " ") s+= " {!input!}%s" % (status["name"]) #Shorten the ID if it's necessary. Pretty hacky #I _REALLY_ should make a nice function for it that can partition and shorten stuff space_left = cols - strwidth("[s] 100.00% " + status["name"] + " "*3) - 2 if space_left >= len(torrent_id) - 2: #There's enough space, print it s += " {!cyan!}%s" % torrent_id else: #Shorten the ID a = int(space_left * 2/3.0) b = space_left - a if a < 8: b = b - (8-a) a = 8 if b < 0: a+= b b = 0 if a > 8: #Print the shortened ID s += " {!cyan!}%s" % (torrent_id[0:a] + ".." + torrent_id[-b-1:-1]) else: #It has wrapped over to the second row anyway s += " {!cyan!}%s" % torrent_id self.console.write(s) dl_info = "{!info!}DL: {!input!}" dl_info+= "%s" % common.fsize(status["total_done"]) if status["total_done"] != status["total_size"]: dl_info+= "/%s" % common.fsize(status["total_size"]) if status["download_payload_rate"] > 0: dl_info += " @ %s%s" % (down_color, common.fspeed(status["download_payload_rate"])) ul_info = " {!info!}UL: {!input!}" ul_info+= "%s" % common.fsize(status["ratio"] * status["total_done"]) if status["upload_payload_rate"] > 0: ul_info += " @ %s%s" % (up_color, common.fspeed(status["upload_payload_rate"])) eta = "" if common.ftime(status["eta"]): eta = " {!info!}ETA: {!magenta!}%s" % common.ftime(status["eta"]) self.console.write(" " + dl_info + ul_info + eta) self.console.set_batch_write(False)
def show_info(self, torrent_id, status, verbose=False, detailed=False): """ Writes out the torrents information to the screen. Format depends on switches given. """ self.console.set_batch_write(True) if hasattr(self.console, 'screen'): cols = self.console.screen.cols else: cols = 80 sep = ' ' if verbose or detailed: self.console.write('{!info!}Name: {!input!}%s' % (status['name'])) self.console.write('{!info!}ID: {!input!}%s' % (torrent_id)) s = '{!info!}State: %s%s' % (colors.state_color[status['state']], status['state']) # Only show speed if active if status['state'] in ('Seeding', 'Downloading'): if status['state'] != 'Seeding': s += sep s += '{!info!}Down Speed: {!input!}%s' % fspeed( status['download_payload_rate'], shortform=True) s += sep s += '{!info!}Up Speed: {!input!}%s' % fspeed( status['upload_payload_rate'], shortform=True) self.console.write(s) if status['state'] in ('Seeding', 'Downloading', 'Queued'): s = '{!info!}Seeds: {!input!}%s (%s)' % (status['num_seeds'], status['total_seeds']) s += sep s += '{!info!}Peers: {!input!}%s (%s)' % (status['num_peers'], status['total_peers']) s += sep s += '{!info!}Availability: {!input!}%.2f' % status['distributed_copies'] s += sep s += '{!info!}Seed Rank: {!input!}%s' % f_seedrank_dash( status['seed_rank'], status['seeding_time']) self.console.write(s) total_done = fsize(status['total_done'], shortform=True) total_size = fsize(status['total_size'], shortform=True) if total_done == total_size: s = '{!info!}Size: {!input!}%s' % (total_size) else: s = '{!info!}Size: {!input!}%s/%s' % (total_done, total_size) s += sep s += '{!info!}Downloaded: {!input!}%s' % fsize(status['all_time_download'], shortform=True) s += sep s += '{!info!}Uploaded: {!input!}%s' % fsize(status['total_uploaded'], shortform=True) s += sep s += '{!info!}Share Ratio: {!input!}%.2f' % status['ratio'] self.console.write(s) s = '{!info!}ETA: {!input!}%s' % format_time(status['eta']) s += sep s += '{!info!}Seeding: {!input!}%s' % format_time(status['seeding_time']) s += sep s += '{!info!}Active: {!input!}%s' % format_time(status['active_time']) self.console.write(s) s = '{!info!}Last Transfer: {!input!}%s' % format_time(status['time_since_transfer']) s += sep s += '{!info!}Complete Seen: {!input!}%s' % format_date_never( status['last_seen_complete']) self.console.write(s) s = '{!info!}Tracker: {!input!}%s' % status['tracker_host'] self.console.write(s) self.console.write('{!info!}Tracker status: {!input!}%s' % status['tracker_status']) if not status['is_finished']: pbar = f_progressbar(status['progress'], cols - (13 + len('%.2f%%' % status['progress']))) s = '{!info!}Progress: {!input!}%.2f%% %s' % (status['progress'], pbar) self.console.write(s) s = '{!info!}Download Folder: {!input!}%s' % status['download_location'] self.console.write(s + '\n') if detailed: self.console.write('{!info!}Files in torrent') self.show_file_info(torrent_id, status) self.console.write('{!info!}Connected peers') self.show_peer_info(torrent_id, status) else: up_color = colors.state_color['Seeding'] down_color = colors.state_color['Downloading'] s = '%s%s' % (colors.state_color[status['state']], '[' + status['state'][0] + ']') s += ' {!info!}' + format_progress(status['progress']).rjust(6, ' ') s += ' {!input!}%s' % (status['name']) # Shorten the ID if it's necessary. Pretty hacky # XXX: should make a nice function for it that can partition and shorten stuff space_left = cols - strwidth('[S] 99.99% ' + status['name']) if self.console.interactive and space_left >= len(sep + torrent_id): # Not enough line space so shorten the hash (for interactive mode). torrent_id = shorten_hash(torrent_id, space_left) s += sep s += '{!cyan!}%s' % torrent_id self.console.write(s) dl_info = '{!info!}DL: {!input!}' dl_info += '%s' % ftotal_sized(status['all_time_download'], status['total_payload_download']) if status['download_payload_rate'] > 0: dl_info += ' @ %s%s' % (down_color, fspeed( status['download_payload_rate'], shortform=True)) ul_info = ' {!info!}UL: {!input!}' ul_info += '%s' % ftotal_sized(status['total_uploaded'], status['total_payload_upload']) if status['upload_payload_rate'] > 0: ul_info += ' @ %s%s' % (up_color, fspeed( status['upload_payload_rate'], shortform=True)) eta = ' {!info!}ETA: {!magenta!}%s' % format_time(status['eta']) self.console.write(' ' + dl_info + ul_info + eta + '\n') self.console.set_batch_write(False)
def writeOutput(self): try: self.logInfo("Proceeding with torrent data interpretation...") torrentDataList = [] torrentItemList = [ "num_peers", "num_seeds", "name", "state", "total_done", "total_size", "total_wanted", "progress", "files", "eta", "download_payload_rate", "upload_payload_rate", "total_peers", "total_seeds", "ratio", "queue" ] highesteta = 0 # summary variables summary_notorrent = 0 summary_totaldone = 0 summary_totalsize = 0 summary_totaldownloadrate = 0.0 summary_totaluploadrate = 0.0 summary_totaleta = 0 summary_currentpeers = 0 summary_currentseeds = 0 summary_totalpeers = 0 summary_totalseeds = 0 summary_totalratio = 0.0 self.logInfo("Preparing templates...") if self.options.summarytemplate == None: # create default summary template summarytemplate = "Total Torrents Queued:[notorrents] \n[totaldone]/[totalsize] - [totalprogress]\n" + "DL: [totaldownloadrate] UL: [totaluploadrate]\n" else: # load the template file contents try: #fileinput = open(self.options.summarytemplate) fileinput = codecs.open( os.path.expanduser(self.options.summarytemplate), encoding='utf-8') summarytemplate = fileinput.read() fileinput.close() except: self.logError("Summary Template file no found!") sys.exit(2) if self.options.torrenttemplate == None: # create default template torrenttemplate = "[name]\n[state]\n[totaldone]/[totalsize] - [progress]\n" + "DL: [downloadrate] UL: [uploadrate] ETA:[eta]\n" else: # load the template file contents try: #fileinput = open(self.options.torrenttemplate) fileinput = codecs.open( os.path.expanduser(self.options.torrenttemplate), encoding='utf-8') torrenttemplate = fileinput.read() fileinput.close() except: self.logError("Torrent Template file no found!") sys.exit(2) if len(self.torrents_status) > 0: self.logInfo("Processing %s torrent(s)..." % str( len(self.torrents_status))) for torrentid in self.torrents_status: torrent_status = self.torrents_status[torrentid] if torrent_status != None: if self.options.activeonly == True: active = False # check for activity if "num_peers" in torrent_status: if torrent_status["num_peers"] > 0: active = True if "num_seeds" in torrent_status: if torrent_status["num_seeds"] > 0: active = True # output details if all required or if active if self.options.activeonly == False or active == True: if "name" in torrent_status: name = torrent_status["name"] else: name = "Unknown" if "state" in torrent_status: state = torrent_status["state"] if state == "Downloading": statecode = self.STATE_DOWNLOADING elif state == "Seeding": statecode = self.STATE_SEEDING elif state == "Queued": statecode = self.STATE_QUEUED elif state == "Paused": statecode = self.STATE_PAUSED else: statecode = self.STATE_UNKNOWN else: state = "Unknown" statecode = self.STATE_UNKNOWN if "total_done" in torrent_status: totaldone = fsize(torrent_status["total_done"]) summary_totaldone = summary_totaldone + int( torrent_status["total_done"]) else: totaldone = "??.? KiB" if "total_size" in torrent_status: totalsize = fsize( torrent_status["total_wanted"]) summary_totalsize = summary_totalsize + int( torrent_status["total_wanted"]) else: totalsize = "??.? KiB" if "progress" in torrent_status: progress = str( round(torrent_status["progress"], 2)) + "%" else: progress = "?.?%" if "files" in torrent_status: nofiles = str(len(torrent_status["files"])) else: nofiles = "?" if "eta" in torrent_status: eta = torrent_status["eta"] if eta > highesteta: highesteta = eta etatext = ftime(eta) else: eta = None etatext = "Unknown" if "download_payload_rate" in torrent_status: downloadrate = float( torrent_status["download_payload_rate"]) summary_totaldownloadrate = summary_totaldownloadrate + downloadrate downloadtext = fspeed(downloadrate) else: downloadrate = 0 downloadtext = "?.? KiB/s" if "upload_payload_rate" in torrent_status: uploadrate = float( torrent_status["upload_payload_rate"]) summary_totaluploadrate = summary_totaluploadrate + uploadrate uploadtext = fspeed(uploadrate) else: uploadrate = 0 uploadtext = "?.? KiB/s" if "num_peers" in torrent_status: currentpeers = str(torrent_status["num_peers"]) summary_currentpeers = summary_currentpeers + int( torrent_status["num_peers"]) else: currentpeers = "?" if "num_seeds" in torrent_status: currentseeds = str(torrent_status["num_seeds"]) summary_currentseeds = summary_currentseeds + int( torrent_status["num_seeds"]) else: currentseeds = "?" if "total_peers" in torrent_status: totalpeers = str(torrent_status["total_peers"]) summary_totalpeers = summary_totalpeers + int( torrent_status["total_peers"]) else: totalpeers = "?" if "total_seeds" in torrent_status: totalseeds = str(torrent_status["total_seeds"]) summary_totalseeds = summary_totalseeds + int( torrent_status["total_seeds"]) else: totalseeds = "?" if "ratio" in torrent_status: ratio = str(round(torrent_status["ratio"], 3)).ljust(5, "0") else: ratio = "?.???" # for sorting in the same way as progress, we need to order from high to low if "queue" in torrent_status: queueorder = torrent_status["queue"] else: queueorder = -1 sortby = self.options.sortby summary_notorrent = summary_notorrent + 1 # add torrent data to list torrentData = TorrentData( name, state, statecode, totaldone, totalsize, progress, nofiles, downloadrate, downloadtext, uploadrate, uploadtext, eta, etatext, currentpeers, currentseeds, totalpeers, totalseeds, ratio, queueorder, sortby) torrentDataList.append(torrentData) else: self.logInfo( "No torrent status data available for torrentid: " + torrentid) if summary_notorrent > 0: output = u"" if self.options.showsummary == True: # sort out summary data for output summary_notorrent = str(summary_notorrent) summary_totalprogress = str( round((float(summary_totaldone) / float(summary_totalsize)) * 100, 2)) + "%" summary_totaldone = fsize(summary_totaldone) summary_totalsize = fsize(summary_totalsize) summary_totaldownloadrate = fspeed( summary_totaldownloadrate) summary_totaluploadrate = fspeed( summary_totaluploadrate) summary_totaleta = ftime(highesteta) summary_currentpeers = str(summary_currentpeers) summary_currentseeds = str(summary_currentseeds) summary_totalpeers = str(summary_totalpeers) summary_totalseeds = str(summary_totalseeds) summary_totalratio = "?.???" output = self.getSummaryTemplateOutput( summarytemplate, summary_notorrent, summary_totalprogress, summary_totaldone, summary_totalsize, summary_totaldownloadrate, summary_totaluploadrate, summary_totaleta, summary_currentpeers, summary_currentseeds, summary_totalpeers, summary_totalseeds, summary_totalratio) if self.options.hidetorrentdetail == False: outputCount = 0 # sort list, eta based self.logInfo("Sorting torrent list using: %s" % self.options.sortby) torrentDataList.sort(reverse=True) # output torrent data using the template for torrentData in torrentDataList: # keep a tally of torrent output, if past the limit then exit if self.options.limit <> 0: outputCount = outputCount + 1 if outputCount > self.options.limit: break output = output + self.getTorrentTemplateOutput( torrenttemplate, torrentData.name, torrentData.state, torrentData.totaldone, torrentData.totalsize, torrentData.progress, torrentData.nofiles, torrentData.downloadtext, torrentData.uploadtext, torrentData.etatext, torrentData.currentpeers, torrentData.currentseeds, torrentData.totalpeers, torrentData.totalseeds, torrentData.ratio) + "\n" print output.encode("utf-8") else: print u"No torrent info to display" else: self.logInfo("No torrents found") except Exception, e: self.logError("writeOutput:Unexpected error:" + e.__str__())
def show_info(self, torrent_id, status, verbose=False): """ Writes out the torrents information to the screen. :param torrent_id: str, the torrent_id :param status: dict, the torrents status, this should have the same keys as status_keys :param verbose: bool, if true, we print out more information about the the torrent """ self.console.set_batch_write(True) self.console.write(" ") self.console.write("{!info!}Name: {!input!}%s" % (status["name"])) self.console.write("{!info!}ID: {!input!}%s" % (torrent_id)) s = "{!info!}State: %s%s" % (colors.state_color[status["state"]], status["state"]) # Only show speed if active if status["state"] in ("Seeding", "Downloading"): if status["state"] != "Seeding": s += " {!info!}Down Speed: {!input!}%s" % common.fspeed(status["download_payload_rate"]) s += " {!info!}Up Speed: {!input!}%s" % common.fspeed(status["upload_payload_rate"]) if common.ftime(status["eta"]): s += " {!info!}ETA: {!input!}%s" % common.ftime(status["eta"]) self.console.write(s) if status["state"] in ("Seeding", "Downloading", "Queued"): s = "{!info!}Seeds: {!input!}%s (%s)" % (status["num_seeds"], status["total_seeds"]) s += " {!info!}Peers: {!input!}%s (%s)" % (status["num_peers"], status["total_peers"]) s += " {!info!}Availibility: {!input!}%.2f" % status["distributed_copies"] self.console.write(s) s = "{!info!}Size: {!input!}%s/%s" % (common.fsize(status["total_done"]), common.fsize(status["total_size"])) s += " {!info!}Ratio: {!input!}%.3f" % status["ratio"] self.console.write(s) if not status["is_finished"]: if hasattr(self.console, "screen"): cols = self.console.screen.cols else: cols = 80 pbar = format_progressbar(status["progress"], cols - (13 + len("%.2f%%" % status["progress"]))) s = "{!info!}Progress: {!input!}%.2f%% %s" % (status["progress"], pbar) self.console.write(s) if verbose: self.console.write(" {!info!}::Files") for i, f in enumerate(status["files"]): s = " {!input!}%s (%s)" % (f["path"], common.fsize(f["size"])) s += " {!info!}Progress: {!input!}%.2f%%" % (status["file_progress"][i] * 100) s += " {!info!}Priority:" fp = common.FILE_PRIORITY[status["file_priorities"][i]].replace("Priority", "") if fp == "Do Not Download": s += "{!error!}" else: s += "{!success!}" s += " %s" % (fp) # Check if this is too long for the screen and reduce the path # if necessary if hasattr(self.console, "screen"): cols = self.console.screen.cols slen = colors.get_line_length(s, self.console.screen.encoding) if slen > cols: s = s.replace(f["path"], f["path"][slen - cols + 1:]) self.console.write(s) self.console.write(" {!info!}::Peers") if len(status["peers"]) == 0: self.console.write(" None") else: s = "" for peer in status["peers"]: if peer["seed"]: s += "%sSeed\t{!input!}" % colors.state_color["Seeding"] else: s += "%sPeer\t{!input!}" % colors.state_color["Downloading"] s += peer["country"] + "\t" s += peer["ip"] c = peer["client"] s += "\t" + c if len(c) < 16: s += "\t\t" else: s += "\t" s += "%s%s\t%s%s" % ( colors.state_color["Seeding"], common.fspeed(peer["up_speed"]), colors.state_color["Downloading"], common.fspeed(peer["down_speed"])) s += "\n" self.console.write(s[:-1]) self.console.set_batch_write(False)
def fspeed_max(value, max_value=-1): value = fspeed(value, shortform=True) return '%s (%s %s)' % (value, max_value, _('K/s')) if max_value > -1 else value
def show_info(self, torrent_id, status, verbose=False, detailed=False): """ Writes out the torrents information to the screen. Format depends on switches given. """ self.console.set_batch_write(True) if hasattr(self.console, 'screen'): cols = self.console.screen.cols else: cols = 80 sep = ' ' if verbose or detailed: self.console.write('{!info!}Name: {!input!}%s' % (status['name'])) self.console.write('{!info!}ID: {!input!}%s' % (torrent_id)) s = '{!info!}State: %s%s' % ( colors.state_color[status['state']], status['state'], ) # Only show speed if active if status['state'] in ('Seeding', 'Downloading'): if status['state'] != 'Seeding': s += sep s += '{!info!}Down Speed: {!input!}%s' % fspeed( status['download_payload_rate'], shortform=True) s += sep s += '{!info!}Up Speed: {!input!}%s' % fspeed( status['upload_payload_rate'], shortform=True) self.console.write(s) if status['state'] in ('Seeding', 'Downloading', 'Queued'): s = '{!info!}Seeds: {!input!}%s (%s)' % ( status['num_seeds'], status['total_seeds'], ) s += sep s += '{!info!}Peers: {!input!}%s (%s)' % ( status['num_peers'], status['total_peers'], ) s += sep s += ('{!info!}Availability: {!input!}%.2f' % status['distributed_copies']) s += sep s += '{!info!}Seed Rank: {!input!}%s' % f_seedrank_dash( status['seed_rank'], status['seeding_time']) self.console.write(s) total_done = fsize(status['total_done'], shortform=True) total_size = fsize(status['total_size'], shortform=True) if total_done == total_size: s = '{!info!}Size: {!input!}%s' % (total_size) else: s = '{!info!}Size: {!input!}%s/%s' % (total_done, total_size) s += sep s += '{!info!}Downloaded: {!input!}%s' % fsize( status['all_time_download'], shortform=True) s += sep s += '{!info!}Uploaded: {!input!}%s' % fsize( status['total_uploaded'], shortform=True) s += sep s += '{!info!}Share Ratio: {!input!}%.2f' % status['ratio'] self.console.write(s) s = '{!info!}ETA: {!input!}%s' % format_time(status['eta']) s += sep s += '{!info!}Seeding: {!input!}%s' % format_time( status['seeding_time']) s += sep s += '{!info!}Active: {!input!}%s' % format_time( status['active_time']) self.console.write(s) s = '{!info!}Last Transfer: {!input!}%s' % format_time( status['time_since_transfer']) s += sep s += '{!info!}Complete Seen: {!input!}%s' % format_date_never( status['last_seen_complete']) self.console.write(s) s = '{!info!}Tracker: {!input!}%s' % status['tracker_host'] self.console.write(s) self.console.write('{!info!}Tracker status: {!input!}%s' % status['tracker_status']) if not status['is_finished']: pbar = f_progressbar( status['progress'], cols - (13 + len('%.2f%%' % status['progress']))) s = '{!info!}Progress: {!input!}%.2f%% %s' % ( status['progress'], pbar) self.console.write(s) s = '{!info!}Download Folder: {!input!}%s' % status[ 'download_location'] self.console.write(s + '\n') if detailed: self.console.write('{!info!}Files in torrent') self.show_file_info(torrent_id, status) self.console.write('{!info!}Connected peers') self.show_peer_info(torrent_id, status) else: up_color = colors.state_color['Seeding'] down_color = colors.state_color['Downloading'] s = '%s%s' % ( colors.state_color[status['state']], '[' + status['state'][0] + ']', ) s += ' {!info!}' + format_progress(status['progress']).rjust( 6, ' ') s += ' {!input!}%s' % (status['name']) # Shorten the ID if it's necessary. Pretty hacky # XXX: should make a nice function for it that can partition and shorten stuff space_left = cols - strwidth('[S] 99.99% ' + status['name']) if self.console.interactive and space_left >= len(sep + torrent_id): # Not enough line space so shorten the hash (for interactive mode). torrent_id = shorten_hash(torrent_id, space_left) s += sep s += '{!cyan!}%s' % torrent_id self.console.write(s) dl_info = '{!info!}DL: {!input!}' dl_info += '%s' % ftotal_sized(status['all_time_download'], status['total_payload_download']) if status['download_payload_rate'] > 0: dl_info += ' @ %s%s' % ( down_color, fspeed(status['download_payload_rate'], shortform=True), ) ul_info = ' {!info!}UL: {!input!}' ul_info += '%s' % ftotal_sized(status['total_uploaded'], status['total_payload_upload']) if status['upload_payload_rate'] > 0: ul_info += ' @ %s%s' % ( up_color, fspeed(status['upload_payload_rate'], shortform=True), ) eta = ' {!info!}ETA: {!magenta!}%s' % format_time(status['eta']) self.console.write(' ' + dl_info + ul_info + eta + '\n') self.console.set_batch_write(False)
def _on_get_session_status(status): download_rate = fspeed(status['payload_download_rate'], precision=0, shortform=True) upload_rate = fspeed(status['payload_upload_rate'], precision=0, shortform=True) self.window.set_title(_('D: %s U: %s - Deluge' % (download_rate, upload_rate)))
def _on_get_session_status(self, status): self.download_rate = fspeed(status['payload_download_rate'], shortform=True) self.upload_rate = fspeed(status['payload_upload_rate'], shortform=True)