Esempio n. 1
0
def main():

    ap = argparse.ArgumentParser()
    ap.add_argument('-s', '--sockdir', default='./run')
    ap.add_argument('-r', '--redis', default='run/redis')
    options = ap.parse_args()

    inj = DependencyInjector()
    inj['jinja'] = jinja2.Environment(
        loader=jinja2.PackageLoader(__name__, 'templates'))
    inj['redis'] = redis.Redis(
        unixsock=options.redis + '/redis.sock')

    sock = zmq.pub_socket()
    sock.dict_configure({'connect': 'ipc://' + options.sockdir + '/sub.sock'})
    output = zerogw.JSONWebsockOutput(sock)
    inj['output'] = output

    sock = zmq.pull_socket(inj.inject(web.Websockets(
        resources=[],
        output=output,
        )))
    sock.dict_configure({'connect': 'ipc://' + options.sockdir + '/fw.sock'})

    site = web.Site(
        request_class=Request,
        resources=[
            inj.inject(About()),
            inj.inject(Register()),
            inj.inject(ShowIssue()),
        ])
    sock = zmq.rep_socket(site)
    sock.dict_configure({
        'connect': 'ipc://' + options.sockdir + '/http.sock'
        })
Esempio n. 2
0
def main():
    logging.basicConfig(level=logging.DEBUG)

    di = DependencyInjector()
    di['redis'] = Redis()
    di['jinja'] = jinja2.Environment(
        loader=jinja2.PackageLoader(__name__, 'templates'))

    note = zmq.rep_socket(di.inject(notepads.NotepadHTTP('uri')))
    note.connect('ipc://./run/notepad.sock')

    dash = zmq.rep_socket(di.inject(dashboards.DashboardHTTP('uri')))
    dash.connect('ipc://./run/dashboard.sock')

    outsock = zmq.pub_socket()
    outsock.connect('ipc://./run/ws-output.sock')
    output = di.inject(JSONWebsockOutput(outsock))
    di['websock_output'] = output

    wsdef = zmq.pull_socket(di.inject(DefaultHandler()))
    wsdef.connect('ipc://./run/ws-default.sock')

    wsnote = zmq.pull_socket(
        di.inject(notepads.NotepadWebsock(prefix='notepad.'),
                  output='websock_output'))
    wsnote.connect('ipc://./run/ws-notepad.sock')

    wsdash = zmq.pull_socket(
        di.inject(dashboards.DashboardWebsock(prefix='dashboard.'),
                  output='websock_output'))
    wsdash.connect('ipc://./run/ws-dashboard.sock')
Esempio n. 3
0
def main():
    logging.basicConfig(level=logging.DEBUG)

    di = DependencyInjector()
    di['redis'] = Redis()
    di['jinja'] = jinja2.Environment(
        loader=jinja2.PackageLoader(__name__, 'templates'))

    note = zmq.rep_socket(
        di.inject(notepads.NotepadHTTP('uri')))
    note.connect('ipc://./run/notepad.sock')

    dash = zmq.rep_socket(
        di.inject(dashboards.DashboardHTTP('uri')))
    dash.connect('ipc://./run/dashboard.sock')

    outsock = zmq.pub_socket()
    outsock.connect('ipc://./run/ws-output.sock')
    output = di.inject(JSONWebsockOutput(outsock))
    di['websock_output'] = output

    wsdef = zmq.pull_socket(
        di.inject(DefaultHandler()))
    wsdef.connect('ipc://./run/ws-default.sock')

    wsnote = zmq.pull_socket(
        di.inject(notepads.NotepadWebsock(prefix='notepad.'),
                  output='websock_output'))
    wsnote.connect('ipc://./run/ws-notepad.sock')

    wsdash = zmq.pull_socket(
        di.inject(dashboards.DashboardWebsock(prefix='dashboard.'),
                  output='websock_output'))
    wsdash.connect('ipc://./run/ws-dashboard.sock')
Esempio n. 4
0
def main():

    inj = DependencyInjector()
    inj['jinja'] = jinja2.Environment(
        loader=jinja2.FileSystemLoader('./templates'))
    inj['redis'] = redis.Redis(host='127.0.0.1', port=6379)

    site = web.Site(
        request_class=Request,
        resources=[
            inj.inject(About()),
            inj.inject(Auth()),
        ])
    sock = zmq.rep_socket(site)
    sock.dict_configure({'connect': 'ipc://./run/http.sock'})

    sock = zmq.pub_socket()
    sock.dict_configure({'connect': 'ipc://./run/sub.sock'})
    output = zerogw.JSONWebsockOutput(sock)
    inj['output'] = output

    sock = zmq.pull_socket(inj.inject(Websockets(
        resources=[web.DictResource({
            'pager': inj.inject(Pager()),
            'auth': inj.inject(WebsockAuth()),
            })],
        output=output,
        )))
    sock.dict_configure({'connect': 'ipc://./run/fw.sock'})
Esempio n. 5
0
    def run(self):
        signal.signal(signal.SIGCHLD, child_handler)
        signal.signal(signal.SIGQUIT, quit_handler)

        proto = Proto()
        proto.load_xml("xproto")
        proto.load_xml("xtest")
        proto.load_xml("xinerama")
        proto.load_xml("shm")
        proto.load_xml("randr")
        self.conn = conn = Connection(proto)
        conn.connection()
        self.root_window = Root(conn.init_data["roots"][0]["root"])

        inj = DependencyInjector()
        inj["dns"] = dns.Resolver(dns.Config.system_config())
        gethub().dns_resolver = inj["dns"]
        inj["xcore"] = xcore = Core(conn)
        inj["keysyms"] = keysyms = Keysyms()
        keysyms.load_default()

        cfg = inj["config"] = inj.inject(Config())
        cfg.init_extensions()

        # Hack, but this only makes GetScreenInfo work
        xcore.randr._proto.requests["GetScreenInfo"].reply.items["rates"].code = compile("0", "XPROTO", "eval")
        if cfg["auto-screen-configuration"]:
            if randr.check_screens(xcore):
                randr.configure_outputs(xcore, cfg["screen-dpi"] / 25.4)

        inj["theme"] = inj.inject(cfg.theme())
        inj["commander"] = cmd = inj.inject(CommandDispatcher())
        if hasattr(xcore, "randr"):
            NM = xcore.randr.NotifyMask
            # We only poll for events and use Xinerama for screen querying
            # because some drivers (nvidia) doesn't provide xrandr data
            # correctly
            xcore.randr.SelectInput(
                window=xcore.root_window, enable=NM.ScreenChange | NM.CrtcChange | NM.OutputChange | NM.OutputProperty
            )

        if hasattr(xcore, "xinerama"):
            info = xcore.xinerama.QueryScreens()["screen_info"]
            screenman = inj["screen-manager"] = ScreenManager(
                [Rectangle(scr["x_org"], scr["y_org"], scr["width"], scr["height"]) for scr in info]
            )
        else:
            screenman = inj["screen-manager"] = ScreenManager(
                [Rectangle(0, 0, xcore.root["width_in_pixels"], xcore.root["height_in_pixels"])]
            )
        inj.inject(screenman)

        cmd["tilenol"] = self
        keys = KeyRegistry()
        inj["key-registry"] = inj.inject(keys)
        mouse = MouseRegistry()
        inj["mouse-registry"] = inj.inject(mouse)
        inj["gestures"] = inj.inject(Gestures())

        gman = inj.inject(GroupManager(map(inj.inject, cfg.groups())))
        cmd["groups"] = gman
        inj["group-manager"] = gman

        rules = inj["classifier"] = inj.inject(Classifier())
        for cls, cond, act in cfg.rules():
            rules.add_rule(cond, act, klass=cls)

        eman = inj.inject(EventDispatcher())
        eman.all_windows[self.root_window.wid] = self.root_window
        inj["event-dispatcher"] = eman
        inj["ewmh"] = Ewmh()
        inj.inject(inj["ewmh"])

        inj.inject(self)

        cmd["env"] = EnvCommands()
        cmd["emul"] = inj.inject(EmulCommands())

        # Register hotkeys as mapping notify can be skipped on inplace restart
        keys.configure_hotkeys()

        mouse.init_buttons()
        mouse.register_buttons(self.root_window)
        self.setup_events()

        for screen_no, bar in cfg.bars():
            inj.inject(bar)
            if screen_no < len(screenman.screens):
                scr = screenman.screens[screen_no]
                if bar.position == "bottom":
                    scr.add_bottom_bar(bar)
                else:
                    scr.add_top_bar(bar)
                bar.create_window()
                scr.updated.listen(bar.redraw.emit)

        self.register_gadgets()

        self.catch_windows()
        self.loop()
Esempio n. 6
0
    def run(self):
        signal.signal(signal.SIGCHLD, child_handler)
        signal.signal(signal.SIGQUIT, quit_handler)

        proto = Proto()
        proto.load_xml('xproto')
        proto.load_xml('xtest')
        proto.load_xml('xinerama')
        proto.load_xml('shm')
        proto.load_xml('randr')
        self.conn = conn = Connection(proto)
        conn.connection()
        self.root_window = Root(conn.init_data['roots'][0]['root'])

        inj = DependencyInjector()
        inj['xcore'] = xcore = Core(conn)
        inj['keysyms'] = keysyms = Keysyms()
        keysyms.load_default()


        cfg = inj['config'] = inj.inject(Config())
        cfg.init_extensions()

        # Hack, but this only makes GetScreenInfo work
        xcore.randr._proto.requests['GetScreenInfo'].reply.items['rates'].code\
            = compile('0', 'XPROTO', 'eval')
        if cfg['auto-screen-configuration']:
            if randr.check_screens(xcore):
                randr.configure_outputs(xcore, cfg['screen-dpi']/25.4)

        inj['theme'] = inj.inject(cfg.theme())
        inj['commander'] = cmd = inj.inject(CommandDispatcher())
        if hasattr(xcore, 'randr'):
            NM = xcore.randr.NotifyMask
            # We only poll for events and use Xinerama for screen querying
            # because some drivers (nvidia) doesn't provide xrandr data
            # correctly
            xcore.randr.SelectInput(
                window=xcore.root_window,
                enable=NM.ScreenChange | NM.CrtcChange | NM.OutputChange | NM.OutputProperty)

        if hasattr(xcore, 'xinerama'):
            info = xcore.xinerama.QueryScreens()['screen_info']
            screenman = inj['screen-manager'] = ScreenManager([
                Rectangle(scr['x_org'], scr['y_org'],
                    scr['width'], scr['height'])
                for scr in info])
        else:
            screenman = inj['screen-manager'] = ScreenManager([Rectangle(0, 0,
                xcore.root['width_in_pixels'],
                xcore.root['height_in_pixels'])])
        inj.inject(screenman)

        cmd['tilenol'] = self
        keys = KeyRegistry()
        inj['key-registry'] = inj.inject(keys)
        mouse = MouseRegistry()
        inj['mouse-registry'] = inj.inject(mouse)
        inj['gestures'] = inj.inject(Gestures())

        gman = inj.inject(GroupManager(map(inj.inject, cfg.groups())))
        cmd['groups'] = gman
        inj['group-manager'] = gman

        rules = inj['classifier'] = inj.inject(Classifier())
        for cls, cond, act in cfg.rules():
            rules.add_rule(cond, act, klass=cls)

        eman = inj.inject(EventDispatcher())
        eman.all_windows[self.root_window.wid] = self.root_window
        inj['event-dispatcher'] = eman
        inj['ewmh'] = Ewmh()
        inj.inject(inj['ewmh'])

        inj.inject(self)

        cmd['env'] = EnvCommands()
        cmd['emul'] = inj.inject(EmulCommands())

        # Register hotkeys as mapping notify can be skipped on inplace restart
        keys.configure_hotkeys()

        mouse.init_buttons()
        mouse.register_buttons(self.root_window)
        self.setup_events()

        for screen_no, bar in cfg.bars():
            inj.inject(bar)
            if screen_no < len(screenman.screens):
                scr = screenman.screens[screen_no]
                if bar.position == 'bottom':
                    scr.add_bottom_bar(bar)
                else:
                    scr.add_top_bar(bar)
                bar.create_window()
                scr.updated.listen(bar.redraw.emit)

        self.register_gadgets()

        self.catch_windows()
        self.loop()
Esempio n. 7
0
    def run(self):
        signal.signal(signal.SIGCHLD, child_handler)
        signal.signal(signal.SIGQUIT, quit_handler)

        proto = Proto()
        proto.load_xml('xproto')
        proto.load_xml('xtest')
        proto.load_xml('xinerama')
        proto.load_xml('shm')
        proto.load_xml('randr')
        self.conn = conn = Connection(proto)
        conn.connection()
        self.root_window = Root(conn.init_data['roots'][0]['root'])

        inj = DependencyInjector()
        inj['dns'] = dns.Resolver(dns.Config.system_config())
        gethub().dns_resolver = inj['dns']
        inj['xcore'] = xcore = Core(conn)
        inj['keysyms'] = keysyms = Keysyms()
        keysyms.load_default()

        cfg = inj['config'] = inj.inject(Config())
        cfg.init_extensions()

        # Hack, but this only makes GetScreenInfo work
        xcore.randr._proto.requests['GetScreenInfo'].reply.items['rates'].code\
            = compile('0', 'XPROTO', 'eval')
        if cfg['auto-screen-configuration']:
            if randr.check_screens(xcore):
                randr.configure_outputs(xcore, cfg['screen-dpi'] / 25.4)

        inj['theme'] = inj.inject(cfg.theme())
        inj['commander'] = cmd = inj.inject(CommandDispatcher())
        if hasattr(xcore, 'randr'):
            NM = xcore.randr.NotifyMask
            # We only poll for events and use Xinerama for screen querying
            # because some drivers (nvidia) doesn't provide xrandr data
            # correctly
            xcore.randr.SelectInput(window=xcore.root_window,
                                    enable=NM.ScreenChange | NM.CrtcChange
                                    | NM.OutputChange | NM.OutputProperty)

        if hasattr(xcore, 'xinerama'):
            info = xcore.xinerama.QueryScreens()['screen_info']
            screenman = inj['screen-manager'] = ScreenManager([
                Rectangle(scr['x_org'], scr['y_org'], scr['width'],
                          scr['height']) for scr in info
            ])
        else:
            screenman = inj['screen-manager'] = ScreenManager([
                Rectangle(0, 0, xcore.root['width_in_pixels'],
                          xcore.root['height_in_pixels'])
            ])
        inj.inject(screenman)

        cmd['tilenol'] = self
        keys = KeyRegistry()
        inj['key-registry'] = inj.inject(keys)
        mouse = MouseRegistry()
        inj['mouse-registry'] = inj.inject(mouse)
        inj['gestures'] = inj.inject(Gestures())

        gman = inj.inject(GroupManager(map(inj.inject, cfg.groups())))
        cmd['groups'] = gman
        inj['group-manager'] = gman

        rules = inj['classifier'] = inj.inject(Classifier())
        for cls, cond, act in cfg.rules():
            rules.add_rule(cond, act, klass=cls)

        eman = inj.inject(EventDispatcher())
        eman.all_windows[self.root_window.wid] = self.root_window
        inj['event-dispatcher'] = eman
        inj['ewmh'] = Ewmh()
        inj.inject(inj['ewmh'])

        inj.inject(self)

        cmd['env'] = EnvCommands()
        cmd['emul'] = inj.inject(EmulCommands())

        # Register hotkeys as mapping notify can be skipped on inplace restart
        keys.configure_hotkeys()

        mouse.init_buttons()
        mouse.register_buttons(self.root_window)
        self.setup_events()

        for screen_no, bar in cfg.bars():
            inj.inject(bar)
            if screen_no < len(screenman.screens):
                scr = screenman.screens[screen_no]
                if bar.position == 'bottom':
                    scr.add_bottom_bar(bar)
                else:
                    scr.add_top_bar(bar)
                bar.create_window()
                scr.updated.listen(bar.redraw.emit)

        self.register_gadgets()

        self.catch_windows()
        self.loop()