Example #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!'
Example #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)
Example #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
Example #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: {
Example #5
0
from pecan.deploy import deploy
app = deploy('config.py')
Example #6
0
 def load(self):
     from pecan.deploy import deploy
     return deploy(self.cfgfname)
Example #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())
Example #8
0
def application(environ, start_response):
    wsgi_app = deploy(config_file('prod.py'))
    return wsgi_app(environ, start_response)
Example #9
0
def application(environ, start_response):
    wsgi_app = deploy(config_file("local.py"))
    return wsgi_app(environ, start_response)
Example #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()
Example #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
        }
Example #12
0
File: run.py Project: 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
        }
Example #13
0
 def load_test_app(self, config):
     return deploy(config)
Example #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))
Example #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()
Example #16
0
from pecan.deploy import deploy

application = deploy('/var/www/cgi-bin/pecan_config.py')
Example #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)
Example #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
        }
    }
Example #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()
Example #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
)
Example #21
0
File: serve.py Project: anh/pecan
 def load(self):
     from pecan.deploy import deploy
     return deploy(self.cfgfname)
Example #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)