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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import socket
  5. from pyreadline.unicode_helper import ensure_str
  6. _logfile = False
  7.  
  8. def start_log(on, filename):
  9.     global _logfile, _logfile
  10.     if on == 'on':
  11.         _logfile = open(filename, 'w')
  12.     else:
  13.         _logfile = False
  14.  
  15.  
  16. def log(s):
  17.     if _logfile:
  18.         s = ensure_str(s)
  19.         print >>_logfile, s
  20.         _logfile.flush()
  21.     
  22.  
  23. host = 'localhost'
  24. port = 8081
  25. logsocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  26. show_event = [
  27.     'keypress',
  28.     'bound_function',
  29.     'bind_key',
  30.     'console']
  31. show_event = [
  32.     'bound_function']
  33. sock_silent = True
  34.  
  35. def log_sock(s, event_type = None):
  36.     if sock_silent:
  37.         pass
  38.     elif event_type is None:
  39.         logsocket.sendto(ensure_str(s), (host, port))
  40.     elif event_type in show_event:
  41.         logsocket.sendto(ensure_str(s), (host, port))
  42.     
  43.  
  44.