Пример #1
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)
Пример #2
0
    def _show_filter_prompt(self):
        """
    Prompts the user to add a new regex filter.
    """

        regex_input = input_prompt('Regular expression: ')

        if regex_input:
            self._filter.select(regex_input)
Пример #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)
Пример #4
0
        def _reconnect():
            if self._vals.is_connected:
                return

            controller = tor_controller()
            self.show_message('Reconnecting...', HIGHLIGHT)

            try:
                try:
                    controller.reconnect(chroot_path=nyx.chroot())
                except stem.connection.MissingPassword:
                    password = nyx.input_prompt('Controller Password: '******'s control port")
                self.show_message('Tor reconnected', HIGHLIGHT, max_wait=1)
            except Exception as exc:
                self.show_message('Unable to reconnect (%s)' % exc,
                                  HIGHLIGHT,
                                  max_wait=3)
                controller.close()