Nov
30
2009
xiao
Python has the ability to alter its sys.stdout as to redirect its print commands to pretty much anything.
If, for instance, you want to print to both standard output and to a log file, you can create a class to handle the stdout like such:
class MyOutput():
def __init__(self, logfile):
self.stdout = sys.stdout
self.log = open(logfile, 'w')
def write(self, text):
self.stdout.write(text)
self.log.write(text)
self.log.flush()
def close(self):
self.stdout.close()
self.log.close()
sys.stdout = MyOutput("log.txt")
print "blah blah blah"
Continue reading
no comments | tags: file, log, output, print, Python, screen, stdout | posted in Tips
Nov
29
2009
xiao
Spooler simply stops every time you try to print or add a printer or something? You can keep restarting it but will never be able to print something? I won’t pretend to know your problem since it depends on potentially so many things but if you have a MacBook, one thing worth investigating is have you been running VMWare Fusion? The ThinPrint drivers of the VMWare Tools seem to be able to cause this problem when you run the same machine in BootCamp mode. Unfortunately, you can’t just uninstall it. Uninstalling VMWare Tools from inside virtual mode seems to solve this problem
no comments | tags: bootcamp, Fusion, Mac, Macbook, print, spooler, ThinPrint, tools, VMWare, Windows | posted in Tips