Ejemplo n.º 1
0
def webserver(options, reload=False):
    from app import app
    print "Running server"
    if reload:
        # Con flask
        print "Trabajando con flask stand-alone"
        import gevent.wsgi
        from gevent import monkey
        import werkzeug.serving
        werkzeug.serving
        # http://flask.pocoo.org/snippets/34/ (2nd comment)
        monkey.patch_all()

        @werkzeug.serving.run_with_reloader
        def runServer():
            app.debug = True
            ws = gevent.wsgi.WSGIServer(('', options.port), app)
            ws.serve_forever()

        app.run()

    else:
        # Con Twisted
        from resources import site
        from twisted.internet import reactor

        from models import COMaster
        for x in COMaster.select():
            print x

        reactor.listenTCP(options.port, site) #@UndefinedVariable
        reactor.callLater(1, functools.partial(open_local_browser, port=options.port))    #@UndefinedVariable
        print "Iniciando servidor en http://0.0.0.0:%s" % options.port
        reactor.run() #@UndefinedVariable
Ejemplo n.º 2
0
def listenabled(options, profile='default', all=False):
    '''Lista las comasters'''
    from models import Profile, COMaster
    if not all:
        cos = Profile.get(name=profile).comaster_set
    else:
        cos = COMaster.select()

    for co in Profile.get(name=profile).comaster_set:
        print co.address, co.enabled