win32traceutil.py :  » Windows » pyExcelerator » pywin32-214 » win32 » lib » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Windows » pyExcelerator 
pyExcelerator » pywin32 214 » win32 » lib » win32traceutil.py
# This is a helper for the win32trace module

# If imported from a normal Python program, it sets up sys.stdout and sys.stderr
# so output goes to the collector.

# If run from the command line, it creates a collector loop.

# Eg:
# C:>start win32traceutil.py (or python.exe win32traceutil.py)
# will start a process with a (pretty much) blank screen.
#
# then, switch to a DOS prompt, and type:
# C:>python.exe
# Python 1.4 etc...
# >>> import win32traceutil
# Redirecting output to win32trace remote collector
# >>> print "Hello"
# >>>
# And the output will appear in the first collector process.

# Note - the client or the collector can be started first.
# There is a 0x20000 byte buffer.  If this gets full, it is reset, and new
# output appended from the start.

import win32trace

def RunAsCollector():
  import sys
  try:
    import win32api
    win32api.SetConsoleTitle("Python Trace Collector")
  except:
    pass # Oh well!
  win32trace.InitRead()
  print "Collecting Python Trace Output..."
  try:
    while 1:
      # a short timeout means ctrl+c works next time we wake...
      sys.stdout.write(win32trace.blockingread(500))
  except KeyboardInterrupt:
    print "Ctrl+C"


def SetupForPrint():
  win32trace.InitWrite()
  try:  # Under certain servers, sys.stdout may be invalid.
    print "Redirecting output to win32trace remote collector"
  except:
    pass
  win32trace.setprint() # this works in an rexec environment.

if __name__=='__main__':
  RunAsCollector()
else:
  SetupForPrint()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.