bzr branch
http://gegoxaren.bato24.eu/bzr/loggerhead/trunk
498.3.1
by Jelmer Vernooij
Use python3 by default. |
1 |
#!/usr/bin/python3 -tt
|
407.2.5
by Toshio Kuratomi
Add GPLv2+ header to loggerhead.wsgi script |
2 |
# This program is free software; you can redistribute it and/or modify
|
3 |
# it under the terms of the GNU General Public License as published by
|
|
4 |
# the Free Software Foundation; either version 2 of the License, or
|
|
5 |
# (at your option) any later version.
|
|
6 |
#
|
|
7 |
# This program is distributed in the hope that it will be useful,
|
|
8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
# GNU General Public License for more details.
|
|
11 |
#
|
|
12 |
# You should have received a copy of the GNU General Public License
|
|
13 |
# along with this program; if not, write to the Free Software
|
|
467.2.1
by Toshio Kuratomi
Change to the FSF address in license headers |
14 |
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
|
407.2.5
by Toshio Kuratomi
Add GPLv2+ header to loggerhead.wsgi script |
15 |
|
407.2.1
by Toshio Kuratomi
Files to anable mod_wsgi |
16 |
|
17 |
import os |
|
18 |
import pwd |
|
543.2.1
by Jelmer Vernooij
Sort Python import definitions with isort |
19 |
import sys |
20 |
||
407.2.1
by Toshio Kuratomi
Files to anable mod_wsgi |
21 |
sys.path.insert(0, os.path.dirname(__file__)) |
22 |
||
543.2.1
by Jelmer Vernooij
Sort Python import definitions with isort |
23 |
from breezy import config as bzrconfig |
24 |
from breezy.plugin import load_plugins |
|
25 |
from paste.deploy.config import PrefixMiddleware |
|
407.2.1
by Toshio Kuratomi
Files to anable mod_wsgi |
26 |
from paste.httpexceptions import HTTPExceptionHandler |
543.2.1
by Jelmer Vernooij
Sort Python import definitions with isort |
27 |
|
28 |
from loggerhead.apps.error import ErrorHandlerApp |
|
407.2.1
by Toshio Kuratomi
Files to anable mod_wsgi |
29 |
from loggerhead.apps.transport import BranchesFromTransportRoot |
30 |
from loggerhead.config import LoggerheadConfig |
|
543.2.1
by Jelmer Vernooij
Sort Python import definitions with isort |
31 |
|
407.2.1
by Toshio Kuratomi
Files to anable mod_wsgi |
32 |
|
33 |
class NotConfiguredError(Exception): |
|
34 |
pass
|
|
35 |
||
36 |
||
37 |
load_plugins() |
|
38 |
config = LoggerheadConfig() |
|
39 |
prefix = config.get_option('user_prefix') or '' |
|
40 |
# Note we could use LoggerheadConfig here if it didn't fail when a
|
|
41 |
# config option is not also a commandline option
|
|
491.2.7
by Jelmer Vernooij
Support LOGGERHEAD_ROOT_DIR. |
42 |
root_dir = os.getenv('LOGGERHEAD_ROOT_DIR') |
43 |
if not root_dir: |
|
44 |
root_dir = bzrconfig.GlobalConfig().get_user_option('http_root_dir') |
|
45 |
if not root_dir: |
|
46 |
raise NotConfiguredError('You must set LOGGERHEAD_ROOT_DIR or have ' |
|
47 |
'a ~/.config/breezy/breezy.conf file for'
|
|
407.2.1
by Toshio Kuratomi
Files to anable mod_wsgi |
48 |
' %(user)s with http_root_dir set to the base directory you want' |
49 |
' to serve bazaar repositories from' % |
|
50 |
{'user': pwd.getpwuid(os.geteuid()).pw_name}) |
|
519.1.3
by Jelmer Vernooij
Avoid breezy.sixish. |
51 |
prefix = prefix.encode('utf-8', 'ignore') |
52 |
root_dir = root_dir.encode('utf-8', 'ignore') |
|
407.2.1
by Toshio Kuratomi
Files to anable mod_wsgi |
53 |
app = BranchesFromTransportRoot(root_dir, config) |
54 |
app = PrefixMiddleware(app, prefix=prefix) |
|
55 |
app = HTTPExceptionHandler(app) |
|
56 |
application = ErrorHandlerApp(app) |