home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2347 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.0 KB  |  49 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import socket
  5.  
  6. try:
  7.     import msvcrt
  8. except ImportError:
  9.     msvcrt = None
  10.     print 'problem'
  11.  
  12. port = 8081
  13. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  14. s.bind(('', port))
  15. s.settimeout(0.05)
  16. print 'Starting logserver on port:', port
  17. print 'Press q to quit logserver', port
  18. singleline = False
  19.  
  20. def check_key():
  21.     if msvcrt is None:
  22.         return False
  23.     if msvcrt.kbhit() != 0:
  24.         q = msvcrt.getch()
  25.         return q in 'q'
  26.     return False
  27.  
  28. while None:
  29.     
  30.     try:
  31.         (data, addr) = s.recvfrom(1024)
  32.     except socket.timeout:
  33.         if check_key():
  34.             print 'Quitting logserver'
  35.             break
  36.         
  37.     except:
  38.         check_key()
  39.  
  40.     if data.startswith('@@'):
  41.         continue
  42.     
  43.     if singleline:
  44.         print '\r', ' ' * 78, '\r', data,
  45.         continue
  46.     print data
  47.     continue
  48.     return None
  49.