home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / python2.4 / site-packages / BitTorrent / spewout.py < prev    next >
Encoding:
Python Source  |  2006-07-20  |  1.1 KB  |  45 lines

  1.  
  2. # This file created for Debian because btdownloadcurses can't 
  3. # find btdownloadheadless because we rename it.
  4.  
  5. def print_spew(spew):
  6.     s = StringIO()
  7.     s.write('\n\n\n')
  8.     for c in spew:
  9.         s.write('%20s ' % c['ip'])
  10.         if c['initiation'] == 'local':
  11.             s.write('l')
  12.         else:
  13.             s.write('r')
  14.         rate, interested, choked = c['upload']
  15.         s.write(' %10s ' % str(int(rate)))
  16.         if c['is_optimistic_unchoke']:
  17.             s.write('*')
  18.         else:
  19.             s.write(' ')
  20.         if interested:
  21.             s.write('i')
  22.         else:
  23.             s.write(' ')
  24.         if choked:
  25.             s.write('c')
  26.         else:
  27.             s.write(' ')
  28.  
  29.         rate, interested, choked, snubbed = c['download']
  30.         s.write(' %10s ' % str(int(rate)))
  31.         if interested:
  32.             s.write('i')
  33.         else:
  34.             s.write(' ')
  35.         if choked:
  36.             s.write('c')
  37.         else:
  38.             s.write(' ')
  39.         if snubbed:
  40.             s.write('s')
  41.         else:
  42.             s.write(' ')
  43.         s.write('\n')
  44.     print s.getvalue()
  45.