startup.py :  » Windows » pyExcelerator » pywin32-214 » pythonwin » pywin » framework » 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 » pythonwin » pywin » framework » startup.py
# startup.py
#
"The main application startup code for PythonWin."

#
# This does the basic command line handling.

# Keep this as short as possible, cos error output is only redirected if
# this runs OK.  Errors in imported modules are much better - the messages go somewhere (not any more :-)

import sys
import win32ui

# You may wish to redirect error output somewhere useful if you have startup errors.
# eg, 'import win32traceutil' will do this for you.
# import win32traceutil # Just uncomment this line to see error output!

# An old class I used to use - generally only useful if Pythonwin is running under MSVC
#class DebugOutput:
#  softspace=1
#  def write(self,message):
#    win32ui.OutputDebug(message)
#sys.stderr=sys.stdout=DebugOutput()

# To fix a problem with Pythonwin when started from the Pythonwin directory,
# we update the pywin path to ensure it is absolute.
# If it is indeed relative, it will be relative to our current directory.
# If its already absolute, then this will have no affect.
import pywin, pywin.framework
pywin.__path__[0] = win32ui.FullPath(pywin.__path__[0])
pywin.framework.__path__[0] = win32ui.FullPath(pywin.framework.__path__[0])

# make a few wierd sys values.  This is so later we can clobber sys.argv to trick
# scripts when running under a GUI environment.

moduleName = "pywin.framework.intpyapp"
sys.appargvoffset = 0
sys.appargv = sys.argv[:]
# Must check for /app param here.
if len(sys.argv)>=2 and sys.argv[0].lower()=='/app':
  import cmdline
  moduleName = cmdline.FixArgFileName(sys.argv[1])
  sys.appargvoffset = 2
  newargv=sys.argv[sys.appargvoffset:]
#  newargv.insert(0, sys.argv[0])
  sys.argv = newargv

# Import the application module.
__import__(moduleName)

try:
  win32ui.GetApp()._obj_
  # This worked - an app already exists - do nothing more
except (AttributeError, win32ui.error):
  # This means either no app object exists at all, or the one
  # that does exist does not have a Python class (ie, was created
  # by the host .EXE).  In this case, we do the "old style" init...
  import app
  if app.AppBuilder is None:
    raise TypeError("No application object has been registered")

  app.App = app.AppBuilder()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.