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