Пример #1
0
def construct_graph(args):
    """Preliminary HFOS application Launcher"""

    app = Core(args)

    setup_root(app)

    if args['debug']:
        from circuits import Debugger
        hfoslog("Starting circuits debugger", lvl=warn, emitter='GRAPH')
        dbg = Debugger().register(app)
        dbg.IgnoreEvents.extend(["read", "_read", "write", "_write",
                                 "stream_success", "stream_complete",
                                 "stream"])

    hfoslog("Beginning graph assembly.", emitter='GRAPH')

    if args['drawgraph']:
        from circuits.tools import graph

        graph(app)

    if args['opengui']:
        import webbrowser
        # TODO: Fix up that url:
        webbrowser.open("http://%s:%i/" % (args['host'], args['port']))

    hfoslog("Graph assembly done.", emitter='GRAPH')

    return app
Пример #2
0
def construct_graph(args):
    """Preliminary HFOS application Launcher"""

    app = Core(host=args.host, port=args.port, insecure=args.insecure)

    setup_root(app)

    # if dodebug:
    # from circuits import Debugger

    # dbg = Debugger()
    # dbg.IgnoreEvents.extend(["write", "_write", "streamsuccess"])

    # HFDebugger(root=server).register(server)

    hfoslog("Beginning graph assembly.", emitter='GRAPH')

    if args.drawgraph:
        from circuits.tools import graph

        graph(app)

    if args.opengui:
        import webbrowser

        webbrowser.open("http://%s:%i/" % (args.host, args.port))

    hfoslog("Graph assembly done.", emitter='GRAPH')

    return app
Пример #3
0
 def debug(self):
     graph(self.root)
     return self.serve_file(
             os.path.abspath(
                 os.path.join(os.getcwd(), "Manager.png")
             )
         )
Пример #4
0
def construct_graph(ctx, name, instance, args):
    """Preliminary Isomer application Launcher"""

    app = Core(name, instance, **args)

    # TODO: This should probably be read-only
    BaseMeta.context = ctx

    setup_root(app)

    if args["debug"]:
        from circuits import Debugger

        isolog("Starting circuits debugger", lvl=warn, emitter="GRAPH")
        dbg = Debugger().register(app)
        # TODO: Make these configurable from modules, navdata is _very_ noisy
        # but should not be listed _here_
        dbg.IgnoreEvents.extend([
            "read",
            "_read",
            "write",
            "_write",
            "stream_success",
            "stream_complete",
            "serial_packet",
            "raw_data",
            "stream",
            "navdatapush",
            "referenceframe",
            "updateposition",
            "updatesubscriptions",
            "generatevesseldata",
            "generatenavdata",
            "sensordata",
            "reset_flood_offenders",
            "reset_flood_counters",  # Flood counters
            "task_success",
            "task_done",  # Thread completion
            "keepalive",  # IRC Gateway
            "peek",  # AVIO and others
            "joystickchange",  # AVIO
        ])

    isolog("Beginning graph assembly.", emitter="GRAPH")

    if args["draw_graph"]:
        from circuits.tools import graph

        graph(app)

    if args["open_gui"]:
        import webbrowser

        # TODO: Fix up that url:
        webbrowser.open("http://%s:%i/" % (args["host"], args["port"]))

    isolog("Graph assembly done.", emitter="GRAPH")

    return app
Пример #5
0
    def cli_compgraph(self, event):
        """Draw current component graph"""

        self.log("Drawing component graph")
        from circuits.tools import graph

        graph(self)
        self._drawgraph()
Пример #6
0
def construct_graph(dodebug=False, dograph=False, dogui=False):
    """Preliminary HFOS application Launcher"""

    if dodebug:
        from circuits import Debugger

    server = Server(("0.0.0.0", 8055))
    setup_root(server)
    Logger().register(server)
    hfoslog("[HFOS] Beginning graph assembly.")

    HFDebugger().register(server)

    app = App().register(server)

    # Machineroom().register(app)

    navdata = NavData().register(server)
    NMEAParser('localhost', 2222).register(navdata)

    TileCache().register(server)
    Static("/", docroot="/var/lib/hfos/static").register(server)
    WebSocketsDispatcher("/websocket").register(server)

    clientmanager = ClientManager().register(server)
    AlertManager().register(clientmanager)
    SchemaManager().register(clientmanager)
    ObjectManager().register(clientmanager)
    Authenticator().register(clientmanager)
    Chat().register(clientmanager)
    MapViewManager().register(clientmanager)
    LayerManager().register(clientmanager)
    RemoteControlManager().register(clientmanager)
    WebDemo().register(clientmanager)
    Wiki().register(clientmanager)
    # CameraManager().register(clientmanager)

    # Logger().register(server)

    if dodebug:
        dbg = Debugger()
        dbg.IgnoreEvents.extend(["write", "_write", "streamsuccess"])
        # dbg.register(lm)

    if dograph:
        from circuits.tools import graph

        graph(server)

    if dogui:
        import webbrowser

        webbrowser.open("http://127.0.0.1:8055")

    hfoslog("[HFOS] Graph assembly done.")

    return server
Пример #7
0
def construct_graph(dodebug=False, dograph=False, dogui=False):
    """Preliminary HFOS application Launcher"""

    if dodebug:
        from circuits import Debugger

    server = Server(("0.0.0.0", 8055))
    setup_root(server)
    Logger().register(server)
    hfoslog("[HFOS] Beginning graph assembly.")

    HFDebugger().register(server)

    app = App().register(server)

    # Machineroom().register(app)

    navdata = NavData().register(server)
    NMEAParser("localhost", 2222).register(navdata)

    TileCache().register(server)
    Static("/", docroot="/var/lib/hfos/static").register(server)
    WebSocketsDispatcher("/websocket").register(server)

    clientmanager = ClientManager().register(server)
    AlertManager().register(clientmanager)
    SchemaManager().register(clientmanager)
    ObjectManager().register(clientmanager)
    Authenticator().register(clientmanager)
    Chat().register(clientmanager)
    MapViewManager().register(clientmanager)
    LayerManager().register(clientmanager)
    RemoteControlManager().register(clientmanager)
    WebDemo().register(clientmanager)
    Wiki().register(clientmanager)
    # CameraManager().register(clientmanager)

    # Logger().register(server)

    if dodebug:
        dbg = Debugger()
        dbg.IgnoreEvents.extend(["write", "_write", "streamsuccess"])
        # dbg.register(lm)

    if dograph:
        from circuits.tools import graph

        graph(server)

    if dogui:
        import webbrowser

        webbrowser.open("http://127.0.0.1:8055")

    hfoslog("[HFOS] Graph assembly done.")

    return server
Пример #8
0
    def runTest(self):
        a = A()
        b = B()
        c = C()
        d = D()
        e = E()
        f = F()

        a += b
        b += c

        e += f
        d += e
        a += d

        self.assertEquals(a.manager, a)
        self.assertEquals(b.manager, a)
        self.assertEquals(c.manager, b)
        self.assertFalse(c.components)

        self.assertTrue(b in a.components)
        self.assertTrue(d in a.components)

        self.assertEquals(d.manager, a)
        self.assertEquals(e.manager, d)
        self.assertEquals(f.manager, e)

        self.assertTrue(f in e.components)
        self.assertTrue(e in d.components)
        self.assertFalse(f.components)

        self.assertEquals(graph(a), GRAPH)
Пример #9
0
    def started(self, component):
        """Started Event Handler

        This is fired internally when your application starts up and can be used to
        trigger events that only occur once during startup.
        """
        logger.debug(graph(self.root))
Пример #10
0
def main():
    opts, args = parse_options()

    bind = parse_bind(opts.bind)

    if opts.validate:
        application = (Application() + Root())
        app = validator(application)

        httpd = make_server(bind[0], bind[1], app)
        httpd.serve_forever()

        raise SystemExit(0)

    manager = Manager()

    opts.debug and Debugger().register(manager)

    Poller = select_poller(opts.poller.lower())
    Poller().register(manager)

    if opts.server.lower() == "base":
        BaseServer(bind).register(manager)
        HelloWorld().register(manager)
    else:
        Server(bind).register(manager)
        Root().register(manager)

    docroot = os.getcwd() if not args else args[0]

    Static(docroot=docroot, dirlisting=True).register(manager)

    opts.passwd and Authentication(passwd=opts.passwd).register(manager)

    opts.logging and Logger().register(manager)

    if opts.profile and hotshot:
        profiler = hotshot.Profile(".profile")
        profiler.start()

    if opts.debug:
        print(graph(manager, name="circuits.web"))
        print()
        print(inspect(manager))

    for i in range(opts.jobs):
        manager.start(process=True)

    manager.run()

    if opts.profile and hotshot:
        profiler.stop()
        profiler.close()

        stats = hotshot.stats.load(".profile")
        stats.strip_dirs()
        stats.sort_stats("time", "calls")
        stats.print_stats(20)
Пример #11
0
def main():
    opts, args = parse_options()

    bind = parse_bind(opts.bind)

    if opts.validate:
        application = (Application() + Root())
        app = validator(application)

        httpd = make_server(bind[0], bind[1], app)
        httpd.serve_forever()

        raise SystemExit(0)

    manager = Manager()

    opts.debug and Debugger().register(manager)

    Poller = select_poller(opts.poller.lower())
    Poller().register(manager)

    if opts.server.lower() == "base":
        BaseServer(bind).register(manager)
        HelloWorld().register(manager)
    else:
        Server(bind).register(manager)
        Root().register(manager)

    docroot = os.getcwd() if not args else args[0]

    Static(docroot=docroot, dirlisting=True).register(manager)

    opts.passwd and Authentication(passwd=opts.passwd).register(manager)

    opts.logging and Logger().register(manager)

    if opts.profile and hotshot:
        profiler = hotshot.Profile(".profile")
        profiler.start()

    if opts.debug:
        print(graph(manager, name="circuits.web"))
        print()
        print(inspect(manager))

    for i in range(opts.jobs):
        manager.start(process=True)

    manager.run()

    if opts.profile and hotshot:
        profiler.stop()
        profiler.close()

        stats = hotshot.stats.load(".profile")
        stats.strip_dirs()
        stats.sort_stats("time", "calls")
        stats.print_stats(20)
Пример #12
0
    def graph(self, source, target, args):
        """Display graph structure of the system

        Syntax; GRAPH
        """

        code = graph(self.root, "kdb")

        lang = "Plain Text"
        data = {"code": code, "lang": lang, "submit": "Submit"}
        url = "http://codepad.org/"
        r = urlopen(url, urlencode(data))

        if r.code == 200:
            msg = r.url
        else:
            msg = log("ERROR: {0:d} while posting graph", r.code)

        return msg
Пример #13
0
 def ready(self, *args):
     graph(self.root)
Пример #14
0
 def GET(self, client):
     return graph(self.root) + '\n'
Пример #15
0
Файл: _gtk.py Проект: A-K/naali
def test2():
    import gobject
    from circuits import Manager, Debugger
    from circuits.net.sockets import TCPClient, Connect, Write

    m = Manager()
    m += GtkDriver()
    m += Debugger()

    def on_delete(window, event):
        m.stop()

    w = gtk.Window()
    w.connect('delete-event', on_delete)
    vb = gtk.VBox()

    b = gtk.Button('Click me')

    tv = gtk.TextView()
    sw = gtk.ScrolledWindow()
    sw.add(tv)

    vb.pack_start(sw)

    class Wget(TCPClient):

        channel = "wget"

        def __init__(self, tv, host='google.com', port=80):
            super(Wget, self).__init__()

            self.tv = tv
            self += TCPClient(channel=self.channel)

        def fetch_google(self, *args):
            self.push(Connect('google.com', 80), "connect")

        def connected(self, host, port):
            print "Connected to %s" % host
            self.push(Write('GET / HTTP/1.0\r\n\r\n'))

        def error(self, *args):
            print "ERROR: %r" % list(args)

        def read(self, data):
            def _write(data):
                self.tv.get_buffer().set_text(data)
            gobject.idle_add(_write, data)

    wg = Wget(tv)
    m += wg

    def on_click(self, wget):
        tv.get_buffer().set_text('')
        wget.fetch_google()


    b.connect('clicked', on_click, wg)
    vb.pack_start(b, expand=False)
    w.add(vb)
    w.show_all()

    print graph(m)
    print inspect(m)

    m.run()
Пример #16
0
 def started(self, *args):
     print(graph(self.root))
Пример #17
0
        "backupCount": 7,
        "level": "DEBUG",
    },
    "ui": {
        "port": "8123",
    },
}

class ErrorHandler(Component):
    def exception(self, error_type, value, traceback, \
                  handler=None, fevent=None):
        sys.exit();

if __name__ == '__main__':

    application = Application("TestPortal", CONFIG)
    Debugger().register(application)
    ErrorHandler().register(application)
    # Build a web (HTTP) server for handling user interface requests.
    port = int(application.config.get("ui", "port", 0))
    portal_server = BaseServer(("0.0.0.0", port), channel="ui") \
        .register(application)
    Portal(portal_server, title="Test Portal").register(application)
    HelloWorldPortlet().register(application)
    DisplayPortlet(channel="sample-display").register(application)
    ServerTimePortlet().register(application)
    
    from circuits.tools import graph
    print(graph(application))
    application.run()
Пример #18
0
 def started(self, *args):
     print(graph(self.root))
Пример #19
0
	def GET(self, client):
		return graph(self.root) + '\n'
Пример #20
0
 def debug(self):
     graph(self.root)
     return self.serve_file(
         os.path.abspath(os.path.join(os.getcwd(), "Manager.png")))
Пример #21
0
    "ui": {
        "port": "8877",
    },
}

class ErrorHandler(Component):
    def exception(self, error_type, value, traceback, handler=None):
        sys.exit();

if __name__ == '__main__':

    application = Application("CoCy", CONFIG)
    Debugger().register(application)
    ErrorHandler().register(application)
    
#    # Build a portal as user interface
#    port = int(application.config.get("ui", "port", 0))
#    portal_server = BaseServer(("", port), channel="ui").register(application)
#    portal = Portal(portal_server, title="CoCy").register(application)
#    PortletsFactory().register(application)
#    dev_dir = UPnPDeviceDirectory().register(application)

    # The server    
    upnp_dev_server \
        = UPnPDeviceServer(application.app_dir).register(application)
    media_renderer = DummyPlayer().register(application)
    
    from circuits.tools import graph
    print graph(application)
    application.run()
Пример #22
0
}


class ErrorHandler(Component):
    def exception(self, error_type, value, traceback, handler=None):
        sys.exit()


if __name__ == '__main__':

    application = Application("CoCy", CONFIG)
    Debugger().register(application)
    ErrorHandler().register(application)

    # Build a portal as user interface
    port = int(application.config.get("ui", "port", 0))
    portal_server = BaseServer(("", port), channel="ui").register(application)
    portal = Portal(portal_server, title="CoCy").register(application)
    PortletsFactory().register(application)
    dev_dir = UPnPDeviceDirectory().register(application)

    # The light server
    upnp_dev_server \
        = UPnPDeviceServer(application.app_dir).register(application)
    binary_light = BinaryLight().register(application)
    BinaryLightPortlet(binary_light).register(portal)

    from circuits.tools import graph
    six.print_(graph(application))
    application.run()
Пример #23
0
}


class ErrorHandler(Component):
    def exception(self, error_type, value, traceback, handler=None):
        sys.exit()


if __name__ == '__main__':

    application = Application("CoCy", CONFIG)
    Debugger().register(application)
    ErrorHandler().register(application)

    # Build a portal as user interface
    port = int(application.config.get("ui", "port", 0))
    portal_server = BaseServer(("", port), channel="ui").register(application)
    portal = Portal(portal_server, title="CoCy").register(application)
    PortletsFactory().register(application)
    dev_dir = UPnPDeviceDirectory().register(application)

    # The light server
    upnp_dev_server \
        = UPnPDeviceServer(application.app_dir).register(application)
    binary_light = BinaryLight().register(application)
    BinaryLightPortlet(binary_light).register(portal)

    from circuits.tools import graph
    print graph(application)
    application.run()
Пример #24
0
def test2():
    import gobject
    from circuits import Manager, Debugger
    from circuits.net.sockets import TCPClient, Connect, Write

    m = Manager()
    m += GtkDriver()
    m += Debugger()

    def on_delete(window, event):
        m.stop()

    w = gtk.Window()
    w.connect('delete-event', on_delete)
    vb = gtk.VBox()

    b = gtk.Button('Click me')

    tv = gtk.TextView()
    sw = gtk.ScrolledWindow()
    sw.add(tv)

    vb.pack_start(sw)

    class Wget(TCPClient):

        channel = "wget"

        def __init__(self, tv, host='google.com', port=80):
            super(Wget, self).__init__()

            self.tv = tv
            self += TCPClient(channel=self.channel)

        def fetch_google(self, *args):
            self.push(Connect('google.com', 80), "connect")

        def connected(self, host, port):
            print "Connected to %s" % host
            self.push(Write('GET / HTTP/1.0\r\n\r\n'))

        def error(self, *args):
            print "ERROR: %r" % list(args)

        def read(self, data):
            def _write(data):
                self.tv.get_buffer().set_text(data)

            gobject.idle_add(_write, data)

    wg = Wget(tv)
    m += wg

    def on_click(self, wget):
        tv.get_buffer().set_text('')
        wget.fetch_google()

    b.connect('clicked', on_click, wg)
    vb.pack_start(b, expand=False)
    w.add(vb)
    w.show_all()

    print graph(m)
    print inspect(m)

    m.run()
Пример #25
0
 def ready(self, *args):
     graph(self.root)
Пример #26
0
def main():
    opts, args = parse_options()

    if opts.jit and psyco:
        psyco.full()

    if ":" in opts.bind:
        address, port = opts.bind.split(":")
        port = int(port)
    else:
        address, port = opts.bind, 8000

    bind = (address, port)

    if opts.validate:
        application = (wsgi.Application() + Root())
        app = validator(application)

        httpd = make_server(address, port, app)
        httpd.serve_forever()
        
        raise SystemExit, 0

    manager = Manager()

    if opts.debug:
        manager += Debugger()

    poller = opts.type.lower()
    if poller == "poll":
        Poller = Poll
    elif poller == "epoll":
        if EPoll is None:
            print "No epoll support available - defaulting to Select..."
            Poller = Select
        else:
            Poller = EPoll
    else:
        Poller = Select

    if opts.server.lower() == "base":
        manager += (BaseServer(bind, poller=Poller) + HelloWorld())
    else:
        manager += (Server(bind, poller=Poller) + Root())

    if opts.profile:
        if hotshot:
            profiler = hotshot.Profile(".profile")
            profiler.start()

    if opts.debug:
        print graph(manager, name="circuits.web")
        print
        print inspect(manager)

    if opts.mp:
        from circuits.core.workers import cpus
        for i in xrange(cpus() - 1):
            manager.start(process=True)

    manager.run()

    if opts.profile and hotshot:
        profiler.stop()
        profiler.close()

        stats = hotshot.stats.load(".profile")
        stats.strip_dirs()
        stats.sort_stats("time", "calls")
        stats.print_stats(20)