Esempio n. 1
0
 def main(self):
     self.startup()
     config = settings.settings()
     m = Manager()
     m += directory_monitor(config)
     m += git_monitor()
     m += cmd_runner(config)  
     m += gtk_status_icon(config)
     m += notifications()
     
     if self.options.verbose:
         m += Debugger()
         print inspect(m)
         
     m.run()
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
0
def test_inspect():
    a = A()
    s = inspect(a)

    assert "Components: 0" in s
    assert "Event Handlers: 2" in s
    assert "foo; 1" in s
    assert "<handler[*][foo] (A.foo)>" in s
    assert "prepare_unregister_complete; 1" in s
    assert "<handler[<instance of A>][prepare_unregister_complete] (A._on_prepare_unregister_complete)>" in s
Esempio n. 5
0
def test_inspect():
    a = A()
    s = inspect(a)

    assert "Components: 0" in s
    assert "Event Handlers: 2" in s
    assert "foo; 1" in s
    assert "<handler[*][foo] (A.foo)>" in s
    assert "prepare_unregister_complete; 1" in s
    assert "<handler[<instance of A>][prepare_unregister_complete] (A._on_prepare_unregister_complete)>" in s
Esempio n. 6
0
def test_inspect():
    if pytest.PYVER[:2] == (3, 3):
        pytest.skip("Broken on Python 3.3")

    a = A()
    s = inspect(a)

    assert "Components: 0" in s
    assert "Event Handlers: 2" in s
    assert "foo; 1" in s
    assert "<handler[*.foo] (A.foo)>" in s
    assert "prepare_unregister_complete; 1" in s
    assert "<handler[<instance of A>.prepare_unregister_complete] (A._on_prepare_unregister_complete)>" in s
Esempio n. 7
0
def test_inspect():
    if pytest.PYVER[:2] == (3, 3):
        pytest.skip("Broken on Python 3.3")

    a = A()
    s = inspect(a)

    assert "Components: 0" in s
    assert "Event Handlers: 2" in s
    assert "foo; 1" in s
    assert "<handler[*][foo] (A.foo)>" in s
    assert "prepare_unregister_complete; 1" in s
    assert "<handler[<instance of A>][prepare_unregister_complete] (A._on_prepare_unregister_complete)>" in s
Esempio n. 8
0
    def POST(self, input=None):
        if not input:
            return ""

        self.response.headers["Content-Type"] = "text/plain"

        if input.strip() == "inspect":
            return inspect(self)

        self.response.stream = True

        sid = self.request.sid
        self += Command(self.request, self.response, input, channel=sid)

        return self.response
Esempio n. 9
0
    def POST(self, input=None):
        if not input:
            return ""

        self.response.headers["Content-Type"] = "text/plain"

        if input.strip() == "inspect":
            return inspect(self)

        self.response.stream = True

        sid = self.request.sid
        self += Command(self.request, self.response, input, channel=sid)

        return self.response
Esempio n. 10
0
    def inspect(self, source, target, args):
        """Display an inspection report of the system

        Syntax; INSPECT
        """

        code = inspect(self.root)
        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 inspection report", r.code)

        return msg
Esempio n. 11
0
File: _gtk.py Progetto: 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()
Esempio n. 12
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)
Esempio n. 13
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()