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 host = "http://localhost:8080" # or another absolute URL 22 23 import DemoApp 24 resource = DemoApp.get_site(host) 25 26 # Try and open the application in a Web browser. 27 # The preferred module is Paul's proposed desktop module - see #1301512 in 28 # the Python SourceForge project: http://www.python.org/sf?id=1301512 29 30 if "--nobrowser" not in sys.argv: 31 print "Opening a browser to show the application." 32 print "If this fails, specify --nobrowser to turn it off." 33 try: 34 import desktop 35 except ImportError: 36 import webbrowser as desktop 37 38 desktop.open(host) 39 40 # Special magic incantation to start the demo. 41 42 from WebStack.Adapters.BaseHTTPRequestHandler import deploy 43 44 print "Serving..." 45 deploy(resource, handle_errors=0) 46 47 # vim: tabstop=4 expandtab shiftwidth=4