示例#1
0
 def display_history(self, history):
     for t in history:
         print "%(name)s" % t
         file_size = ""
         if 'total_size' in t:
             file_size = "%s" % filesizeformat(t['total_size'])
             if len(t['files']) > 1:
                 file_size += " in %d files" % len(t['files'])
         if 'finished' in t:
             print "   %s%sCompleted %s" % (file_size, " - " if file_size else '', as_age(t['finished']))
         elif 'inserted_new' in t:
             print "   %s%sStarted %s" % (file_size, " - " if file_size else '', as_age(t['inserted_new']))
         elif file_size:
             print "   %s" % file_size
示例#2
0
 def do_list(self, args):
     "List current torrents"
     torrents, _ = RTorrent().today()
     for t in torrents:
         print "%s (%s)" % (t.name, "%s..%s" % (t.hash[:5], t.hash[-5:]))
         print "  %5s %3d%%" % (t.status.upper(), t.percent),
         if t.complete:
             print "%s" % filesizeformat(t.size),
         else:
             print "%s of %s" % (filesizeformat(t.completed), filesizeformat(t.size)),
         if hasattr(t, 'files') and len(t.files) > 1:
             print "in %d files" % len(t.files),
         if t.complete and t.is_active:
             print "\xe2\x86\x91%s/s to %d peers" % (filesizeformat(t.up_rate), t.peers_connected),
         if t.is_active and not (t.complete or t.hashing):
             print "\xe2\x86\x93%s/s from %d peers%s" % (filesizeformat(t.down_rate), t.peers_connected, " - %s left" % t.eta if hasattr(t, 'eta') else '')
         else:
             print "- Completed %s" % as_age(t.finished) if hasattr(t, 'finished') else ("- Started %s" % as_age(t.inserted_new) if hasattr(t, 'inserted_new') else '')