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