Ejemplo n.º 1
0
    def run(self):
        if not hasattr(self, 'loop'):
            palette = STYLES
            additional_opts = {
                'screen': urwid.raw_display.Screen(),
                'unhandled_input': self.header_hotkeys,
                'handle_mouse': False
            }
            if self.common['opts'].run_on_serial:
                palette = STYLES_MONO
            else:
                additional_opts['screen'].set_terminal_properties(colors=256)
                additional_opts['screen'].reset_default_terminal_palette()

            evl = urwid.TornadoEventLoop(IOLoop())
            self.common['loop'] = urwid.MainLoop(self.common['ui'],
                                                 palette,
                                                 event_loop=evl,
                                                 **additional_opts)
            log.debug("Running event loop: {}".format(
                self.common['loop'].event_loop))

        try:
            self.set_alarm_in(0.05, self.next_screen)
            for k in self.common['controllers']:
                log.debug("Importing controller: {}".format(k))
                klass = import_object(
                    ("%s.controllers.{}Controller" % self.project).format(k))
                self.common['controllers'][k] = klass(self.common)
            log.debug("*** %s", self.common['controllers'])
            self._connect_base_signals()
            self.common['loop'].run()
        except:
            log.exception("Exception in controller.run():")
            raise
Ejemplo n.º 2
0
    def __init__(self, config, stream=None, event_loop=None):
        stream = (stream
                  or create_msg_channel(config["viewer_channel"], "message"))
        data_store = MessageAsyncDataStore(stream.on_recv)

        context = gviewer.DisplayerContext(data_store,
                                           self,
                                           actions=gviewer.Actions([
                                               ("e", "export replay script",
                                                self.export_replay),
                                               ("r", "replay", self.replay),
                                               ("L", "log", self.log)
                                           ]))

        self.log_context = LogDisplayer(config).context
        event_loop = event_loop or urwid.TornadoEventLoop(
            ioloop.IOLoop.instance())
        self.viewer = gviewer.GViewer(context,
                                      palette=self.PALETTE,
                                      other_contexts=[self.log_context],
                                      config=gviewer.Config(auto_scroll=True),
                                      event_loop=event_loop)
        self.formatter = TuiFormatter()
        self.config = config
        self.event_client = EventClient(config["events_channel"])
        self.terminal_width, _ = get_terminal_size()
Ejemplo n.º 3
0
    def start(self):
        loop = urwid.MainLoop(self.create_widget(),
                              self.palette,
                              event_loop=urwid.TornadoEventLoop(IOLoop()),
                              unhandled_input=self.exit_on_q)
        self.pager.start(loop)

        loop.set_alarm_in(0, self.refresh_footer)
        loop.run()
Ejemplo n.º 4
0
 def _build_loop(self):
     """ Returns event loop configured with color palette """
     additional_opts = {
         'screen': urwid.raw_display.Screen(),
         'unhandled_input': self.header_hotkeys,
         'handle_mouse': True
     }
     additional_opts['screen'].set_terminal_properties(colors=256)
     additional_opts['screen'].reset_default_terminal_palette()
     evl = urwid.TornadoEventLoop(IOLoop())
     return urwid.MainLoop(
         self.ui, STYLES, event_loop=evl, **additional_opts)
Ejemplo n.º 5
0
def build_loop(ui, config, **kwargs):
    """ Returns event loop configured with color palette

    Arguments:
    ui: Interface component
    config: Applications configuration
    kwargs: Additional keyword items to pass to urwid.MainLoop

    Returns:
    urwid.MainLoop()
    """
    opts = {
        'screen': urwid.raw_display.Screen(),
        'unhandled_input': None,
        'handle_mouse': True
    }
    opts['screen'].set_terminal_properties(colors=256)
    opts['screen'].reset_default_terminal_palette()
    opts.update(**kwargs)
    evl = urwid.TornadoEventLoop(IOLoop())
    return urwid.MainLoop(
        ui, STYLES, event_loop=evl, **opts)
Ejemplo n.º 6
0
 def setUp(self):
     from tornado.ioloop import IOLoop
     self.evl = urwid.TornadoEventLoop(IOLoop())