Пример #1
0
    def run(self, args=None):
        options, args = self.parser.parse_args(args)
        logging.debug('Options: %r', options)

        application = make_application(shared=options.htdocs)

        try:
            self.run_server(application, options)
        except SystemExit, err:
            # the flup CGIRequest uses sys.exit(0) to terminate
            if err.code: # log a non-zero exit status (0 means no error)
                logging.exception('A SystemExit(%d) exception occurred.' % err.code)
            raise # exit now with this exit status
Пример #2
0
    def run(self, args=None):
        options, args = self.parser.parse_args(args)
        logging.debug('Options: %r', options)

        application = make_application(shared=options.htdocs)

        try:
            self.run_server(application, options)
        except SystemExit, err:
            # the flup CGIRequest uses sys.exit(0) to terminate
            if err.code:  # log a non-zero exit status (0 means no error)
                logging.exception('A SystemExit(%d) exception occurred.' %
                                  err.code)
            raise  # exit now with this exit status
Пример #3
0
def run_server(hostname='', port=8080,
               docs=True,
               debug='off',
               user=None, group=None,
               threaded=True,
               **kw):
    app = flask.Flask(__name__)
    app.register_blueprint(easy_attach_page, url_prefix='/easy_attach')
    app.register_blueprint(sqlrun_page, url_prefix='/sqlrun')
    """ Run a standalone server on specified host/port. """
    application = make_application(shared=docs)
    application = DispatcherMiddleware(application, {
        '/': application,
      	'/__moinfbp': app,
    })


    if port < 1024:
        if os.name == 'posix' and os.getuid() != 0:
            raise RuntimeError('Must run as root to serve port number under 1024. '
                               'Run as root or change port setting.')

    if user:
        switch_user(user, group)

    if debug == 'external':
        # no threading is better for debugging, the main (and only)
        # thread then will just terminate when an exception happens
        threaded = False

    run_simple(hostname=hostname, port=port,
               application=application,
               threaded=threaded,
               use_debugger=(debug == 'web'),
               passthrough_errors=(debug == 'external'),
               request_handler=RequestHandler,
               **kw)
Пример #4
0
from werkzeug.wsgi import SharedDataMiddleware
from MoinMoin.web.serving import make_application
from MoinMoin import web
import os

moinmoin = make_application(shared=False)

app = SharedDataMiddleware(
    moinmoin,
    {'/moin_static198': os.path.join(web.__path__[0], 'static/htdocs')})


def wsgi_app(env, func):
    env['SCRIPT_NAME'] = '/'
    env['PATH_INFO'] = env['PATH_INFO'][len('/'):]
    return app(env, func)
Пример #5
0
from MoinMoin.web.serving import make_application

sys.path.insert(0, "/etc/moin")


class ScriptFixerMiddleware(object):

    def __init__(self, application):
        self.application = application

    def __call__(self, environ, start_response):
        if not environ.get("SCRIPT_NAME"):
            path = environ.get("PATH_INFO", "")
            if path.startswith("/"):
                path = path[1:]

            parsed = urlparse.urlparse(path)

            script_name = "/".join(parsed.path.split("/")[:1])
            if not script_name.startswith("/"):
                script_name = "/" + script_name

            environ["SCRIPT_NAME"] = script_name
            environ["PATH_INFO"] = "/".join(parsed.path.split("/")[1:])

        return self.application(environ, start_response)


application = ScriptFixerMiddleware(make_application(shared=False))
Пример #6
0
import sys, os

# a) Configuration of Python's code search path
#    If you already have set up the PYTHONPATH environment variable for the
#    stuff you see below, you don't need to do a1) and a2).

# a1) Path of the directory where the MoinMoin code package is located.
#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
#sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')

# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
#     See wiki/config/... for some sample config files.
sys.path.insert(0, os.path.join(r'/usr/local/share/sage_wiki'))
#sys.path.insert(0, '/path/to/farmconfigdir')

# b) Configuration of moin's logging
#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
#    You also don't need this if you are happy with the builtin defaults.
#    See wiki/config/logging/... for some sample config files.
#from MoinMoin import log
#log.load_config('/path/to/logging_configuration_file')

from MoinMoin.web.serving import make_application

# Creating the WSGI application
# use shared=True to have moin serve the builtin static docs
# use shared=False to not have moin serve static docs
# use shared='/my/path/to/htdocs' to serve static docs from that path
application = make_application(shared=True)

Пример #7
0
# a) Configuration of Python's code search path
#    If you already have set up the PYTHONPATH environment variable for the
#    stuff you see below, you don't need to do a1) and a2).

# a1) Path of the directory where the MoinMoin code package is located.
#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
#sys.path.insert(0, '/lib/python2.3/site-packages')

# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
#     See wiki/config/... for some sample config files.
# TODO: don't use absolute path...
sys.path.insert(0, os.path.join(THIS_DIR, 'conf'))
#sys.path.insert(0, '/path/to/farmconfigdir')

# b) Configuration of moin's logging
#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
#    You also don't need this if you are happy with the builtin defaults.
#    See wiki/config/logging/... for some sample config files.
#from MoinMoin import log
#log.load_config('/path/to/logging_configuration_file')

from MoinMoin.web.serving import make_application

# Creating the WSGI application
# use shared=True to have moin serve the builtin static docs
# use shared=False to not have moin serve static docs
#use shared='/my/path/to/htdocs' to serve static docs from that path
static_dir = os.path.join(THIS_DIR, 'moin', 'static')
application = make_application(shared=static_dir)
Пример #8
0
        threaded = True
        ssl_context = ctx
        shared = '/volume1/moindev/lib/moin/MoinMoinHtdocs'

        # moin-lib의 make_application에서 shared가 dict일 경우
        # 별도처리없이 SharedDataMiddleware를 만들어주기때문에
        # 여기에 통합해서 사용한다.
        docs = {'/moin_static195': shared,
                      # XXX only works / makes sense for root-mounted wikis:
                      '/favicon.ico': os.path.join(shared, 'favicon.ico'),
                      '/robots.txt': os.path.join(shared, 'robots.txt'),
                      '/TK_dayone_photos': '/volume1/homes/me/dropbox/Apps/Day One/Journal.dayone/photos',
                      '/MEI_dayone_photos': '/volume1/homes/me/dropbox_happytk/Apps/Day One (1)/Journal.dayone/photos/',
                      '/webpub_amb': '/volume1/photo/webpub_amb',
                      }
        application = make_application(shared=docs)

        if debug == 'external':
            # no threading is better for debugging, the main (and only)
            # thread then will just terminate when an exception happens
            threaded = False

        app = flask.Flask(__name__)
        app.register_blueprint(easy_attach_page, url_prefix='/easy_attach')
        application = DispatcherMiddleware(application, {
            '/archive':  application,
            '/ntuning':  application,
            '/mei':      application,
            '/master':   application,
            '/__moinfbp': app,
        })
Пример #9
0
# a) Configuration of Python's code search path
#    If you already have set up the PYTHONPATH environment variable for the
#    stuff you see below, you don't need to do a1) and a2).

# a1) Path of the directory where the MoinMoin code package is located.
#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
#sys.path.insert(0, '/lib/python2.3/site-packages')

# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
#     See wiki/config/... for some sample config files.
# TODO: don't use absolute path...
sys.path.insert(0, os.path.join(THIS_DIR, 'conf'))
#sys.path.insert(0, '/path/to/farmconfigdir')

# b) Configuration of moin's logging
#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
#    You also don't need this if you are happy with the builtin defaults.
#    See wiki/config/logging/... for some sample config files.
#from MoinMoin import log
#log.load_config('/path/to/logging_configuration_file')

from MoinMoin.web.serving import make_application

# Creating the WSGI application
# use shared=True to have moin serve the builtin static docs
# use shared=False to not have moin serve static docs
#use shared='/my/path/to/htdocs' to serve static docs from that path
static_dir = os.path.join(THIS_DIR, 'moin', 'static')
application = make_application(shared=static_dir)
Пример #10
0
# -*- coding: iso-8859-1 -*-
import sys, os
INTERP = "/usr/bin/python2.7"
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
sys.path.insert(0, '/usr/lib/python2.7/site-packages')
sys.path.insert(0, '/usr/local/share/moin')
from MoinMoin.web.serving import make_application
application = make_application(shared=True)
Пример #11
0
from werkzeug.wsgi import SharedDataMiddleware
from MoinMoin.web.serving import make_application
from MoinMoin import web
import os

moinmoin = make_application(shared=False)

app = SharedDataMiddleware(moinmoin, {
    '/moin_static197': os.path.join(web.__path__[0], 'static/htdocs')
})

def wsgi_app(env, func):
    env['SCRIPT_NAME'] = '/'
    env['PATH_INFO'] = env['PATH_INFO'][len('/'):]
    return app(env,func)
Пример #12
0
# a1) Path of the directory where the MoinMoin code package is located.
#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
#sys.path.insert(0, 'PREFIX/lib/python2.7/site-packages')

# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
#     See wiki/config/... for some sample config files.
#sys.path.insert(0, '/path/to/wikiconfigdir')
#sys.path.insert(0, '/path/to/farmconfigdir')

# b) Configuration of moin's logging
#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
#    You also don't need this if you are happy with the builtin defaults.
#    See wiki/config/logging/... for some sample config files.
#from MoinMoin import log
#log.load_config('/path/to/logging_configuration_file')

from MoinMoin.web.serving import make_application

# Creating the WSGI application
# use shared=True to have moin serve the builtin static docs
# use shared=False to not have moin serve static docs
# use shared='/my/path/to/htdocs' to serve static docs from that path
try:
    trusted_proxies = [
        os.environ['GATEWAY'],
    ]
except KeyError:
    trusted_proxies = None

application = make_application(shared=True, trusted_proxies=trusted_proxies)