Beispiel #1
0
  def _resize_graph(self):
    """
    Prompts for user input to resize the graph panel. Options include...

      * down arrow - grow graph
      * up arrow - shrink graph
      * enter / space - set size
    """

    with nyx.curses.CURSES_LOCK:
      try:
        while True:
          show_message('press the down/up to resize the graph, and enter when done', BOLD)
          key = nyx.curses.key_input()

          if key.match('down'):
            # don't grow the graph if it's already consuming the whole display
            # (plus an extra line for the graph/log gap)

            max_height = nyx.curses.screen_size().height - self.get_top()
            current_height = self.get_height()

            if current_height < max_height + 1:
              self.set_graph_height(self._graph_height + 1)
          elif key.match('up'):
            self.set_graph_height(self._graph_height - 1)
          elif key.is_selection():
            break

          nyx_interface().redraw()
      finally:
        show_message()
Beispiel #2
0
        def _edit_selected_value():
            selected = self._scroller.selection(self._get_config_options())
            initial_value = selected.value() if selected.is_set() else ''
            new_value = input_prompt(
                '%s Value (esc to cancel): ' % selected.name, initial_value)

            if new_value != initial_value:
                try:
                    if selected.value_type == 'Boolean':
                        # if the value's a boolean then allow for 'true' and 'false' inputs

                        if new_value.lower() == 'true':
                            new_value = '1'
                        elif new_value.lower() == 'false':
                            new_value = '0'
                    elif selected.value_type == 'LineList':
                        new_value = new_value.split(
                            ',')  # set_conf accepts list inputs

                    tor_controller().set_conf(selected.name, new_value)
                    self.redraw()
                except Exception as exc:
                    show_message('%s (press any key)' % exc,
                                 HIGHLIGHT,
                                 max_wait=30)
Beispiel #3
0
    def _show_snapshot_prompt(self):
        """
    Lets user enter a path to take a snapshot, canceling if left blank.
    """

        path_input = input_prompt('Path to save log snapshot: ')

        if path_input:
            try:
                self.save_snapshot(path_input)
                show_message('Saved: %s' % path_input, HIGHLIGHT, max_wait=2)
            except IOError as exc:
                show_message('Unable to save snapshot: %s' % exc,
                             HIGHLIGHT,
                             max_wait=2)
Beispiel #4
0
def show_menu():
    menu = _make_menu()
    cursor = MenuCursor(menu.children[0].children[0])

    with nyx.curses.CURSES_LOCK:
        show_message('Press m or esc to close the menu.', BOLD)

        while not cursor.is_done:
            selection_x = _draw_top_menubar(menu, cursor.selection)
            _draw_submenu(cursor.selection, cursor.selection.submenu, 1,
                          selection_x)
            cursor.handle_key(nyx.curses.key_input())
            nyx_interface().redraw(True)

        show_message()
Beispiel #5
0
    def _show_write_dialog(self):
        """
    Confirmation dialog for saving tor's configuration.
    """

        controller = tor_controller()
        torrc = controller.get_info('config-text', None)

        if nyx.popups.confirm_save_torrc(torrc):
            try:
                controller.save_conf()
                show_message('Saved configuration to %s' %
                             controller.get_info('config-file', '<unknown>'),
                             HIGHLIGHT,
                             max_wait=2)
            except stem.OperationFailed as exc:
                show_message('Unable to save configuration ([%s] %s)' %
                             (exc.code, exc.message),
                             HIGHLIGHT,
                             max_wait=2)
            except stem.ControllerError as exc:
                show_message('Unable to save configuration (%s)' % exc,
                             HIGHLIGHT,
                             max_wait=2)

        self.redraw()
Beispiel #6
0
        def _clear_log():
            msg = 'This will clear the log. Are you sure (c again to confirm)?'
            key_press = show_message(msg, BOLD, max_wait=30)

            if key_press.match('c'):
                self._clear()