| 426 | | print "Starting server on port %s with settings module %r." % (port, SETTINGS_MODULE) |
|---|
| 427 | | print "Go to http://127.0.0.1:%s/ for Django." % port |
|---|
| 428 | | print "Quit the server with CONTROL-C (Unix) or CTRL-BREAK (Windows)." |
|---|
| 429 | | try: |
|---|
| 430 | | run(int(port), AdminMediaHandler(WSGIHandler())) |
|---|
| 431 | | except WSGIServerException, e: |
|---|
| 432 | | # Use helpful error messages instead of ugly tracebacks. |
|---|
| 433 | | ERRORS = { |
|---|
| 434 | | 13: "You don't have permission to access that port.", |
|---|
| 435 | | 98: "That port is already in use.", |
|---|
| 436 | | } |
|---|
| | 425 | def inner_run(): |
|---|
| | 426 | from django.conf.settings import SETTINGS_MODULE |
|---|
| | 427 | print "Starting server on port %s with settings module %r." % (port, SETTINGS_MODULE) |
|---|
| | 428 | print "Go to http://127.0.0.1:%s/ for Django." % port |
|---|
| | 429 | print "Quit the server with CONTROL-C (Unix) or CTRL-BREAK (Windows)." |
|---|
| 438 | | error_text = ERRORS[e.args[0].args[0]] |
|---|
| 439 | | except (AttributeError, KeyError): |
|---|
| 440 | | error_text = str(e) |
|---|
| 441 | | sys.stderr.write("Error: %s\n" % error_text) |
|---|
| 442 | | sys.exit(1) |
|---|
| 443 | | except KeyboardInterrupt: |
|---|
| 444 | | sys.exit(0) |
|---|
| | 431 | run(int(port), AdminMediaHandler(WSGIHandler())) |
|---|
| | 432 | except WSGIServerException, e: |
|---|
| | 433 | # Use helpful error messages instead of ugly tracebacks. |
|---|
| | 434 | ERRORS = { |
|---|
| | 435 | 13: "You don't have permission to access that port.", |
|---|
| | 436 | 98: "That port is already in use.", |
|---|
| | 437 | } |
|---|
| | 438 | try: |
|---|
| | 439 | error_text = ERRORS[e.args[0].args[0]] |
|---|
| | 440 | except (AttributeError, KeyError): |
|---|
| | 441 | error_text = str(e) |
|---|
| | 442 | sys.stderr.write("Error: %s\n" % error_text) |
|---|
| | 443 | sys.exit(1) |
|---|
| | 444 | except KeyboardInterrupt: |
|---|
| | 445 | sys.exit(0) |
|---|
| | 446 | from django.utils import autoreload |
|---|
| | 447 | autoreload.main(inner_run) |
|---|