Exemplo n.º 1
0
 def test_module_lookup_find_best_match(self):
     """
     1.  A config file has:
         app { 'modules': [invalid_module, valid_module] }
     2.  The module, `valid_module` has an app.py that defines a `def setup_app`
     """
     test_config_file = os.path.join(os.path.dirname(__file__), 'test_config', 'sample_apps', 'sample_app_config.py')
     assert deploy(test_config_file) == 'DEPLOYED!'
Exemplo n.º 2
0
def main(conf_path):
    application = deploy(conf_path)

    eventlet_enabled = dict(conf.EVENTLET).get("enabled")
    if eventlet_enabled:
        eventlet.monkey_patch(time=True, thread=True)

    server_conf = dict(conf.server)
    port = int(server_conf.get("port"))
    host = server_conf.get("host")
    wsgi.server(eventlet.listen((host, port)), application)
Exemplo n.º 3
0
def factory(global_config, **local_conf):
    conf = {
        'app': {
            'root': 'kosmos.api.v0.controllers.root.RootController',
            'modules': ['kosmos.api.v0'],
            'errors': {
                404: '/errors/not_found',
                405: '/errors/method_not_allowed',
                '__force_dict__': True
            }
        }
    }

    app = deploy.deploy(conf)

    return app
Exemplo n.º 4
0
import os
import cherrypy
from cherrypy import wsgiserver

from pecan.deploy import deploy

import prod

prod_config = os.path.abspath(
    os.path.join(os.path.dirname(__file__), 'prod.py'))
simpleapp_wsgi_app = deploy(prod_config)

public_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                           'public'))


# A dummy class for our Root object
# necessary for some CherryPy machinery
class Root(object):
    pass


def make_static_config(static_dir_name):
    """
    All custom static configurations are set here, since most are common, it
    makes sense to generate them just once.
    """
    static_path = os.path.join('/', static_dir_name)
    path = os.path.join(public_path, static_dir_name)
    configuration = {
        static_path: {
Exemplo n.º 5
0
from pecan.deploy import deploy
app = deploy('config.py')
Exemplo n.º 6
0
 def load(self):
     from pecan.deploy import deploy
     return deploy(self.cfgfname)
Exemplo n.º 7
0
import os
from pecan.deploy import deploy

def config_file():
    _file = os.path.abspath(__file__)
    dirname = lambda x: os.path.dirname(x)
    parent_dir = dirname(dirname(_file))
    return os.path.join(parent_dir, 'prod_config.py')

application = deploy(config_file())
Exemplo n.º 8
0
def application(environ, start_response):
    wsgi_app = deploy(config_file('prod.py'))
    return wsgi_app(environ, start_response)
Exemplo n.º 9
0
def application(environ, start_response):
    wsgi_app = deploy(config_file("local.py"))
    return wsgi_app(environ, start_response)
Exemplo n.º 10
0
import cherrypy
from cherrypy import wsgiserver
from pecan.deploy import deploy
from sys import argv

app = deploy(argv[1])

application = wsgiserver.WSGIPathInfoDispatcher({
    '/': app
})
port = int(argv[2])
server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', port), application, server_name='testapp')

try:
    print('starting server at port {0}'.format(port))
    server.start()
except KeyboardInterrupt:
    print('stopping server!')
    server.stop()
Exemplo n.º 11
0
import os
from os.path import dirname
import cherrypy
from cherrypy import wsgiserver

from pecan.deploy import deploy

simpleapp_wsgi_app = deploy('dev.py')

current_dir = os.path.abspath(dirname(__file__))
base_dir = dirname(current_dir)
public_path = os.path.abspath(os.path.join(base_dir, 'public'))


# A dummy class for our Root object
# necessary for some CherryPy machinery
class Root(object):
    pass


def make_static_config(static_dir_name):
    """
    All custom static configurations are set here, since most are common, it
    makes sense to generate them just once.
    """
    static_path = os.path.join('/', static_dir_name)
    configuration = {
        static_path: {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': public_path
        }
Exemplo n.º 12
0
Arquivo: run.py Projeto: ceph/shaman
import os
from os.path import dirname
import cherrypy
from cherrypy import wsgiserver

from pecan.deploy import deploy

simpleapp_wsgi_app = deploy('dev.py')

current_dir = os.path.abspath(dirname(__file__))
base_dir = dirname(current_dir)
public_path = os.path.abspath(os.path.join(base_dir, 'public'))


# A dummy class for our Root object
# necessary for some CherryPy machinery
class Root(object):
    pass


def make_static_config(static_dir_name):
    """
    All custom static configurations are set here, since most are common, it
    makes sense to generate them just once.
    """
    static_path = os.path.join('/', static_dir_name)
    configuration = {
        static_path: {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': public_path
        }
Exemplo n.º 13
0
 def load_test_app(self, config):
     return deploy(config)
Exemplo n.º 14
0
from pecan.deploy import deploy
from arobot.common.config import CONF
import os

CONFIG_PATH = 'pecan_config_path'

# fix pecan configuration name
config_path = CONF.get('DEFAULT', CONFIG_PATH)
application = deploy(os.path.abspath(config_path))
Exemplo n.º 15
0
def main():
    app = deploy("/etc/managesf/config.py")
    host = app.config['server']['host']
    port = app.config['server']['port']
    srv = simple_server.make_server(host, port, app)
    srv.serve_forever()
Exemplo n.º 16
0
from pecan.deploy import deploy

application = deploy('/var/www/cgi-bin/pecan_config.py')
Exemplo n.º 17
0
from pecan import conf
from pecan.deploy import deploy
app = deploy('/opt/web/draughtcraft/src/production.py')

from paste.exceptions.errormiddleware import ErrorMiddleware
app = ErrorMiddleware(app,
                      error_email=conf.error_email,
                      from_address=conf.error_email,
                      smtp_server=conf.error_smtp_server,
                      smtp_username=conf.error_email,
                      smtp_password=conf.error_password,
                      smtp_use_tls=True)
Exemplo n.º 18
0
import os
import cherrypy
from cherrypy import wsgiserver

from pecan.deploy import deploy

import prod

prod_config = os.path.abspath(os.path.join(os.path.dirname(__file__), 'prod.py'))
simpleapp_wsgi_app = deploy(prod_config)

public_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'public'))

# A dummy class for our Root object
# necessary for some CherryPy machinery
class Root(object):
    pass

def make_static_config(static_dir_name):
    """
    All custom static configurations are set here, since most are common, it
    makes sense to generate them just once.
    """
    static_path = os.path.join('/', static_dir_name)
    path = os.path.join(public_path, static_dir_name)
    configuration = {
        static_path: {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': path
        }
    }
Exemplo n.º 19
0
from __future__ import print_function
import os
from pecan.deploy import deploy


def config_file(file_name=None):
    file_name = file_name or 'config.py'
    _file = os.path.abspath(__file__)
    dirname = lambda x: os.path.dirname(x)
    parent_dir = dirname(dirname(_file))
    return os.path.join(parent_dir, file_name)


def application(environ, start_response):
    wsgi_app = deploy(config_file('prod.py'))
    return wsgi_app(environ, start_response)

if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    # at some point, it would be nice to use pecan_mount
    #import pecan_mount
    #httpd = make_server('', 8181, pecan_mount.tree)
    httpd = make_server('', 8181, deploy(config_file('config.py')))
    print("Serving HTTP on port 8181...")

    # Respond to requests until process is killed
    httpd.serve_forever()
Exemplo n.º 20
0
from pecan import conf
from pecan.deploy import deploy
app = deploy('/opt/web/draughtcraft/src/production.py')

from paste.exceptions.errormiddleware import ErrorMiddleware
app = ErrorMiddleware(
    app,
    error_email=conf.error_email,
    from_address=conf.error_email,
    smtp_server=conf.error_smtp_server,
    smtp_username=conf.error_email,
    smtp_password=conf.error_password,
    smtp_use_tls=True
)
Exemplo n.º 21
0
Arquivo: serve.py Projeto: anh/pecan
 def load(self):
     from pecan.deploy import deploy
     return deploy(self.cfgfname)
Exemplo n.º 22
0
 def __init__(self) -> None:
     super().__init__()
     self._phonebook_wsgi_app = deploy(
         os.path.join(os.path.dirname(__file__), 'config.py'))
     self._server = wsgi.Server(('0.0.0.0', 8080), self._phonebook_wsgi_app)