Guest User

Untitled

a guest
May 23rd, 2013
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. self.myOut = stdOutCustom(self.debug_log)
  2. self.orig_out = sys.stdout
  3. self.orig_err = sys.stderr
  4.  
  5. class stdOutCustom(object):
  6.  
  7.     errors = 'strict'
  8.     encoding = 'utf-8'
  9.  
  10.     def __init__(self, fp):
  11.         self.log = fp
  12.  
  13.     def write(self, d):
  14.         self.log.write(d.encode('utf-8'))
  15.  
  16.     def write(self, d):
  17.  
  18.         if isinstance(d, str):
  19.             self.log.write(d.encode('utf-8'))
  20.         else:
  21.             self.log.write(d)
  22.  
  23.     def flush(self):
  24.         self.stdout.flush()
  25.  
  26.     def __del__(self):
  27.         self.log.close()
Advertisement
Add Comment
Please, Sign In to add comment