Example #1
0
def main(argv=None):
    logging.basicConfig(level=logging.INFO, stream=sys.stderr)
    opts, args = parser.parse_args(argv)
    Model.metadata.create_all(bind=create_engine(opts.url))
    app = load_app(opts.url, opts.debug)
    server = loadserver('egg:Paste#http')
    try:
        server(app)
    except (KeyboardInterrupt, SystemExit):
        print "Bye!"
Example #2
0
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()

        ini = os.path.abspath(sys.argv[1])
        
        self.port = getport(ini)
        
        wsgi_app = loadapp('config:%s' % ini)
        server = loadserver('config:%s' % ini)

        self.thread = Thread(target=server, args=(wsgi_app,))
        self.thread.daemon = True
        self.thread.start()
Example #3
0
    def __init__(self, config, args):
        config_uri = 'config:%s' % config.config_file
        src = config["bushwacker"]["src"]
        dst = config["bushwacker"]["dst"]
        file_queue = bricks.OrderedSetQueue()

        self.generator = Generator(config, args, file_queue)
        self.server = deploy.loadserver(config_uri)
        self.app = deploy.loadapp(config_uri)
        self.observer = observers.Observer()

        ignore_patterns = (os.path.join(dst, '*'), '.*', '*.swp', '*.swx',
                           '*.swpx', '*.*~', '*/4913', '*.ini')
        event_handler = EventHandler(file_queue, ignore_directories=True,
                                     ignore_patterns=ignore_patterns)
        self.observer.schedule(event_handler, src, recursive=True)
Example #4
0
def start():
    """Starts Moksha on localhost port 8080 for development.

    You can change the port and allow remote connections by setting
    server.port or server.address on the command line::

        paver server.address=your.ip.address server.port=8000 start

    FIXME:
        - Get the loggers to work.
    """
    from paste.deploy import loadapp, loadserver
    from moksha.config.environment import load_environment
    from moksha.config.middleware import make_app
    ini = 'config:' + path('development.ini').abspath()
    wsgi_app = loadapp(ini)
    serve = loadserver(ini)
    serve(wsgi_app)
Example #5
0
def start():
    """Starts Moksha on localhost port 8080 for development.

    You can change the port and allow remote connections by setting
    server.port or server.address on the command line::

        paver server.address=your.ip.address server.port=8000 start

    FIXME:
        - Get the loggers to work.
    """
    from paste.deploy import loadapp, loadserver
    from moksha.config.environment import load_environment
    from moksha.config.middleware import make_app
    ini = 'config:' + path('development.ini').abspath()
    wsgi_app = loadapp(ini)
    serve = loadserver(ini)
    serve(wsgi_app)
Example #6
0
    def get_wsgi_server(self, name=None, defaults=None):
        """
        Reads the configuration source and finds and loads a WSGI server
        defined by the server entry with the name ``name`` per the PasteDeploy
        configuration format and loading mechanism.

        :param name: The named WSGI server to find, load and return. Defaults
            to ``None`` which becomes ``main`` inside
            :func:`paste.deploy.loadserver`.
        :param defaults: The ``global_conf`` that will be used during server
            instantiation.
        :return: A WSGI server runner callable which accepts a WSGI app.

        """
        name = self._maybe_get_default_name(name)
        defaults = self._get_defaults(defaults)
        return loadserver(self.pastedeploy_spec,
                          name=name,
                          relative_to=self.relative_to,
                          global_conf=defaults)
Example #7
0
    def get_wsgi_server(self, name=None, defaults=None):
        """
        Reads the configuration source and finds and loads a WSGI server
        defined by the server entry with the name ``name`` per the PasteDeploy
        configuration format and loading mechanism.

        :param name: The named WSGI server to find, load and return. Defaults
            to ``None`` which becomes ``main`` inside
            :func:`paste.deploy.loadserver`.
        :param defaults: The ``global_conf`` that will be used during server
            instantiation.
        :return: A WSGI server runner callable which accepts a WSGI app.

        """
        name = self._maybe_get_default_name(name)
        defaults = self._get_defaults(defaults)
        return loadserver(self.pastedeploy_spec,
                          name=name,
                          relative_to=self.relative_to,
                          global_conf=defaults)
Example #8
0
def rumalchemy(argv=None):
    opts, args = parser.parse_args(argv)
    try:
        url = args[0]
    except IndexError:
        if not opts.config:
            print >> sys.stderr, "Need to provide a database url "\
                                 "(eg: postgres:///somedatabase) or a config "\
                                 "file."
            parser.print_help(sys.stderr)
            return -1
        url = None
    logging.basicConfig(
        level=getattr(logging, opts.log_level.upper()),
        stream=sys.stderr
        )
    app = load_app(url, opts.config, opts.tables, opts.debug)
    server = loadserver(server_map[opts.server])
    try:
        server(app)
    except (KeyboardInterrupt, SystemExit):
        pass
    return 0
Example #9
0
#!/usr/bin/python

"""
Start the Reporting API application using Paste Deploy.
"""

import sys
import os
from paste.deploy import loadapp, loadserver
import logging

if __name__ == '__main__':
    logging.basicConfig(
        filename='/var/log/reporting-api.log', level=logging.INFO
    )
    REALFILE = os.path.realpath(__file__)
    REALDIR = os.path.dirname(REALFILE)
    PARDIR = os.path.realpath(os.path.join(REALDIR, os.pardir))
    CONFDIR = os.path.join(PARDIR, 'reporting_api', 'conf')
    PASTE_CONFIG = os.path.join(CONFDIR, 'paste.config')
    sys.path.insert(0, PARDIR)
    REPORTING_APP = loadapp('config:' + PASTE_CONFIG)
    SERVER = loadserver('config:' + PASTE_CONFIG)
    SERVER(REPORTING_APP)
Example #10
0
 def loadserver(self, server_spec, name, relative_to, **kw):# pragma:no cover
     return loadserver(
         server_spec, name=name, relative_to=relative_to, **kw)
Example #11
0
 def loadserver(self, server_spec, name, relative_to,
                **kw):  # pragma:no cover
     return loadserver(server_spec,
                       name=name,
                       relative_to=relative_to,
                       **kw)
Example #12
0
 def loadserver(self, server_spec, name, relative_to, **kw):
     return loadserver(
         server_spec, name=name, relative_to=relative_to, **kw)
Example #13
0
def main():
    server = loadserver("config:%s" % os.path.abspath(configfile), servername)
    wsgi_app=make_app()
    server(wsgi_app)
    server.serve_forever()
Example #14
0
# -*- coding:utf-8 -*-

import os,sys
from paste.deploy import loadapp, loadserver

CUR_DIR = os.path.dirname(os.path.abspath(__file__))

sys.path.insert(0, CUR_DIR)

wsgi_app = loadapp('config:%s' % os.path.join(CUR_DIR, 'config.ini'))
print 'app:', wsgi_app

print ''

wsgi_server = loadserver('config:%s' % os.path.join(CUR_DIR, 'config.ini'))
print 'server:', wsgi_server


if __name__ == '__main__':
    wsgi_server(wsgi_app)



Example #15
0
def main():
    server = loadserver("config:%s" % os.path.abspath(configfile), servername)
    wsgi_app = make_app()
    server(wsgi_app)
    server.serve_forever()
Example #16
0

class ShowHead():
    def __init__(self):
        pass

    def __call__(self, environ, start_response, *args, **kwargs):
        req = Request(environ)
        res = Response()
        res.status = "200 OK"
        res.content_type = "text/plain"
        res.body = pformat(req.headers.items(), indent=4)
        return res(environ, start_response)

    @classmethod
    def factory(cls, global_conf, **kwargs):
        return cls()


if __name__ == '__main__':
    configfile = "paste.ini"

    appname = "main"
    wsgi_app = loadapp("config:%s" % os.path.abspath(configfile), appname)

    servername = "main"
    server = loadserver("config:%s" % os.path.abspath(configfile), servername)
    server(wsgi_app)

    server.serve_forever()