1 #!/usr/bin/env python 2 3 "Start the demonstration program." 4 5 import os, sys 6 7 # Try and open the application in a Web browser. 8 # The preferred module is Paul's proposed desktop module - see #1301512 in 9 # the Python SourceForge project: http://www.python.org/sf?id=1301512 10 11 if "--nobrowser" not in sys.argv: 12 print "Opening a browser to show the application." 13 print "If this fails, specify --nobrowser to turn it off." 14 try: 15 import desktop 16 except ImportError: 17 import webbrowser as desktop 18 19 desktop.open("http://localhost:8080") 20 21 # Find out where WebStack's distribution directory is. 22 23 cwd = os.getcwd() 24 parts = os.path.split(cwd) 25 if parts[-1] == "tools": 26 parts = parts[:-1] 27 base = os.path.join(*parts) 28 29 # Set up the environment and run the demo program. 30 31 pythonpath = os.environ.get("PYTHONPATH") 32 if pythonpath: 33 pythonpath = pythonpath + os.pathsep 34 else: 35 pythonpath = "" 36 37 os.environ["PYTHONPATH"] = "%s%s%s%s" % (pythonpath, base, os.pathsep, os.path.join(base, "examples", "Common")) 38 os.system("%s %s %s" % (sys.executable, os.path.join(base, "examples", "BaseHTTPRequestHandler", "DemoApp.py"), 39 " ".join(sys.argv[1:]))) 40 41 # vim: tabstop=4 expandtab shiftwidth=4