| 1 | #!/usr/bin/python2.4 |
|---|
| 2 | # -*- coding: utf-8 -*- |
|---|
| 3 | # |
|---|
| 4 | # Copyright (C) 2003-2009 Edgewall Software |
|---|
| 5 | # Copyright (C) 2003-2004 Jonas Borgström <jonas@edgewall.com> |
|---|
| 6 | # All rights reserved. |
|---|
| 7 | # |
|---|
| 8 | # This software is licensed as described in the file COPYING, which |
|---|
| 9 | # you should have received as part of this distribution. The terms |
|---|
| 10 | # are also available at http://trac.edgewall.org/wiki/TracLicense. |
|---|
| 11 | # |
|---|
| 12 | # This software consists of voluntary contributions made by many |
|---|
| 13 | # individuals. For the exact contribution history, see the revision |
|---|
| 14 | # history and logs, available at http://trac.edgewall.org/log/. |
|---|
| 15 | # |
|---|
| 16 | # Author: Jonas Borgström <jonas@edgewall.com> |
|---|
| 17 | |
|---|
| 18 | try: |
|---|
| 19 | import os |
|---|
| 20 | import pkg_resources |
|---|
| 21 | if 'TRAC_ENV' not in os.environ and \ |
|---|
| 22 | 'TRAC_ENV_PARENT_DIR' not in os.environ: |
|---|
| 23 | os.environ['TRAC_ENV'] = '/data/trac/projects/blogtrader' |
|---|
| 24 | if 'PYTHON_EGG_CACHE' not in os.environ: |
|---|
| 25 | if 'TRAC_ENV' in os.environ: |
|---|
| 26 | egg_cache = os.path.join(os.environ['TRAC_ENV'], '.egg-cache') |
|---|
| 27 | elif 'TRAC_ENV_PARENT_DIR' in os.environ: |
|---|
| 28 | egg_cache = os.path.join(os.environ['TRAC_ENV_PARENT_DIR'], |
|---|
| 29 | '.egg-cache') |
|---|
| 30 | pkg_resources.set_extraction_path(egg_cache) |
|---|
| 31 | from trac.web import cgi_frontend |
|---|
| 32 | cgi_frontend.run() |
|---|
| 33 | except SystemExit: |
|---|
| 34 | raise |
|---|
| 35 | except Exception, e: |
|---|
| 36 | import sys |
|---|
| 37 | import traceback |
|---|
| 38 | |
|---|
| 39 | print>>sys.stderr, e |
|---|
| 40 | traceback.print_exc(file=sys.stderr) |
|---|
| 41 | |
|---|
| 42 | print 'Status: 500 Internal Server Error' |
|---|
| 43 | print 'Content-Type: text/plain' |
|---|
| 44 | print |
|---|
| 45 | print 'Oops...' |
|---|
| 46 | print |
|---|
| 47 | print 'Trac detected an internal error:', e |
|---|
| 48 | print |
|---|
| 49 | traceback.print_exc(file=sys.stdout) |
|---|