示例#1
0
    def __init__(self, parent_mode, stdscr, console_config, encoding=None):
        BaseMode.__init__(self, stdscr, encoding=encoding, do_refresh=False)
        PopupsHandler.__init__(self)
        self.parent_mode = parent_mode
        self.cur_cat = 0
        self.messages = deque()
        self.action_input = None
        self.config_loaded = False
        self.console_config = console_config
        self.active_port = -1
        self.active_zone = ZONE.CATEGORIES
        self.sidebar_width = 15  # Width of the categories pane

        self.sidebar = PreferenceSidebar(parent_mode, self.sidebar_width)
        self.sidebar.set_focused(True)
        self.sidebar.active_input = 0

        self._calc_sizes(resize=False)

        self.panes = [
            InterfacePane(self),
            DownloadsPane(self),
            NetworkPane(self),
            BandwidthPane(self),
            OtherPane(self),
            DaemonPane(self),
            QueuePane(self),
            ProxyPane(self),
            CachePane(self),
        ]

        self.action_input = SelectInput(
            self, None, None,
            [_('Cancel'), _('Apply'), _('OK')], [0, 1, 2], 0)
示例#2
0
    def __init__(self, stdscr, encoding=None):
        BaseMode.__init__(self,
                          stdscr,
                          encoding=encoding,
                          do_refresh=False,
                          depend=['SessionProxy'])
        PopupsHandler.__init__(self)
        self.messages = deque()
        self.last_mark = -1
        self.go_top = False
        self.minor_mode = None

        self.consoleui = component.get('ConsoleUI')
        self.coreconfig = self.consoleui.coreconfig
        self.config = self.consoleui.config
        self.sidebar = FilterSidebar(self, self.config)
        self.torrentview_panel = mkwin(
            curses.COLOR_GREEN,
            curses.LINES - 1,
            curses.COLS - self.sidebar.width,
            0,
            self.sidebar.width,
        )
        self.torrentview = torrentview.TorrentView(self, self.config)

        util.safe_curs_set(util.Curser.INVISIBLE)
        self.stdscr.notimeout(0)
示例#3
0
 def __init__(self, stdscr, encoding=None):
     PopupsHandler.__init__(self)
     self.statuses = {}
     self.all_torrents = None
     self.hostlist = HostList()
     BaseMode.__init__(self, stdscr, encoding=encoding)
     self.update_hosts_status()
示例#4
0
    def __init__(self, parent_mode, stdscr, console_config, encoding=None):
        self.console_config = console_config
        self.parent_mode = parent_mode
        self.popup = None
        self.view_offset = 0
        self.cursel = 0
        self.marked = set()
        self.last_mark = -1

        path = os.path.expanduser(self.console_config['addtorrents']['last_path'])

        self.path_stack = ['/'] + path.strip('/').split('/')
        self.path_stack_pos = len(self.path_stack)
        self.listing_files = []
        self.listing_dirs = []

        self.raw_rows = []
        self.raw_rows_files = []
        self.raw_rows_dirs = []
        self.formatted_rows = []

        self.sort_column = self.console_config['addtorrents']['sort_column']
        self.reverse_sort = self.console_config['addtorrents']['reverse_sort']

        BaseMode.__init__(self, stdscr, encoding)

        self._listing_space = self.rows - 5
        self.__refresh_listing()

        util.safe_curs_set(util.Curser.INVISIBLE)
        self.stdscr.notimeout(0)
示例#5
0
    def __init__(self, parent_mode, stdscr, console_config, encoding=None):
        BaseMode.__init__(self, stdscr, encoding=encoding, do_refresh=False)
        PopupsHandler.__init__(self)
        self.parent_mode = parent_mode
        self.cur_cat = 0
        self.messages = deque()
        self.action_input = None
        self.config_loaded = False
        self.console_config = console_config
        self.active_port = -1
        self.active_zone = ZONE.CATEGORIES
        self.sidebar_width = 15  # Width of the categories pane

        self.sidebar = PreferenceSidebar(parent_mode, self.sidebar_width)
        self.sidebar.set_focused(True)
        self.sidebar.active_input = 0

        self._calc_sizes(resize=False)

        self.panes = [
            InterfacePane(self),
            DownloadsPane(self),
            NetworkPane(self),
            BandwidthPane(self),
            OtherPane(self),
            DaemonPane(self),
            QueuePane(self),
            ProxyPane(self),
            CachePane(self)
        ]

        self.action_input = SelectInput(self, None, None, [_('Cancel'), _('Apply'), _('OK')], [0, 1, 2], 0)
示例#6
0
    def __init__(self, parent_mode, stdscr, console_config, encoding=None):
        self.console_config = console_config
        self.parent_mode = parent_mode
        self.popup = None
        self.view_offset = 0
        self.cursel = 0
        self.marked = set()
        self.last_mark = -1

        path = os.path.expanduser(self.console_config['addtorrents']['last_path'])

        self.path_stack = ['/'] + path.strip('/').split('/')
        self.path_stack_pos = len(self.path_stack)
        self.listing_files = []
        self.listing_dirs = []

        self.raw_rows = []
        self.raw_rows_files = []
        self.raw_rows_dirs = []
        self.formatted_rows = []

        self.sort_column = self.console_config['addtorrents']['sort_column']
        self.reverse_sort = self.console_config['addtorrents']['reverse_sort']

        BaseMode.__init__(self, stdscr, encoding)

        self._listing_space = self.rows - 5
        self.__refresh_listing()

        util.safe_curs_set(util.Curser.INVISIBLE)
        self.stdscr.notimeout(0)
示例#7
0
    def on_resize(self, rows, cols):
        BaseMode.on_resize(self, rows, cols)
        self.__update_columns()
        if self.popup:
            self.popup.handle_resize()

        self._listing_start = self.rows // 2
        self.refresh()
示例#8
0
    def on_resize(self, rows, cols):
        BaseMode.on_resize(self, rows, cols)
        self.__update_columns()
        if self.popup:
            self.popup.handle_resize()

        self._listing_start = self.rows // 2
        self.refresh()
 def __init__(self, stdscr, encoding=None):
     PopupsHandler.__init__(self)
     self.statuses = {}
     self.all_torrents = None
     self.hostlist = HostList()
     self.update_hosts_status()
     BaseMode.__init__(self, stdscr, encoding=encoding)
     self.update_select_host_popup()
示例#10
0
    def on_resize(self, rows, cols):
        BaseMode.on_resize(self, rows, cols)

        if self.popup:
            self.popup.handle_resize()

        self.stdscr.erase()
        self.refresh()
示例#11
0
    def on_resize(self, rows, cols):
        BaseMode.on_resize(self, rows, cols)

        if self.popup:
            self.popup.handle_resize()

        self.stdscr.erase()
        self.refresh()
示例#12
0
    def on_resize(self, rows, cols):
        BaseMode.on_resize(self, rows, cols)
        self._calc_sizes()

        if self.popup:
            self.popup.handle_resize()

        self.sidebar.on_resize()
        self.refresh()
示例#13
0
    def on_resize(self, rows, cols):
        BaseMode.on_resize(self, rows, cols)
        self._calc_sizes()

        if self.popup:
            self.popup.handle_resize()

        self.sidebar.on_resize()
        self.refresh()
示例#14
0
    def on_resize(self, rows, cols):
        BaseMode.on_resize(self, rows, cols)

        if self.popup:
            self.popup.handle_resize()

        if not self.consoleui.is_active_mode(self):
            return

        self.toggle_sidebar()
示例#15
0
    def on_resize(self, rows, cols):
        BaseMode.on_resize(self, rows, cols)

        if self.popup:
            self.popup.handle_resize()

        if not self.consoleui.is_active_mode(self):
            return

        self.toggle_sidebar()
示例#16
0
    def __init__(self, stdscr, encoding=None):
        BaseMode.__init__(self, stdscr, encoding=encoding, do_refresh=False, depend=['SessionProxy'])
        PopupsHandler.__init__(self)
        self.messages = deque()
        self.last_mark = -1
        self.go_top = False
        self.minor_mode = None

        self.consoleui = component.get('ConsoleUI')
        self.coreconfig = self.consoleui.coreconfig
        self.config = self.consoleui.config
        self.sidebar = FilterSidebar(self, self.config)
        self.torrentview_panel = mkwin(curses.COLOR_GREEN, curses.LINES - 1,
                                       curses.COLS - self.sidebar.width, 0, self.sidebar.width)
        self.torrentview = torrentview.TorrentView(self, self.config)

        util.safe_curs_set(util.Curser.INVISIBLE)
        self.stdscr.notimeout(0)
示例#17
0
    def __init__(self, parent_mode, stdscr, console_config, encoding=None):
        PopupsHandler.__init__(self)
        self.console_config = console_config
        self.parent_mode = parent_mode
        self.torrentid = None
        self.torrent_state = None
        self._status_keys = [
            'files', 'name', 'state', 'download_payload_rate',
            'upload_payload_rate', 'progress', 'eta', 'all_time_download',
            'total_uploaded', 'ratio', 'num_seeds', 'total_seeds', 'num_peers',
            'total_peers', 'active_time', 'seeding_time', 'time_added',
            'distributed_copies', 'num_pieces', 'piece_length',
            'download_location', 'file_progress', 'file_priorities', 'message',
            'total_wanted', 'tracker_host', 'owner', 'seed_rank',
            'last_seen_complete', 'completed_time', 'time_since_transfer'
        ]
        self.file_list = None
        self.current_file = None
        self.current_file_idx = 0
        self.file_off = 0
        self.more_to_draw = False
        self.full_names = None
        self.column_string = ''
        self.files_sep = None
        self.marked = {}

        BaseMode.__init__(self, stdscr, encoding)
        self.column_names = ['Filename', 'Size', 'Progress', 'Priority']
        self.__update_columns()

        self._listing_start = self.rows // 2
        self._listing_space = self._listing_start - self._listing_start

        client.register_event_handler('TorrentFileRenamedEvent',
                                      self._on_torrentfilerenamed_event)
        client.register_event_handler('TorrentFolderRenamedEvent',
                                      self._on_torrentfolderrenamed_event)
        client.register_event_handler('TorrentRemovedEvent',
                                      self._on_torrentremoved_event)

        util.safe_curs_set(util.Curser.INVISIBLE)
        self.stdscr.notimeout(0)
示例#18
0
    def __init__(self, parent_mode, stdscr, console_config, encoding=None):
        PopupsHandler.__init__(self)
        self.console_config = console_config
        self.parent_mode = parent_mode
        self.torrentid = None
        self.torrent_state = None
        self._status_keys = ['files', 'name', 'state', 'download_payload_rate', 'upload_payload_rate',
                             'progress', 'eta', 'all_time_download', 'total_uploaded', 'ratio',
                             'num_seeds', 'total_seeds', 'num_peers', 'total_peers', 'active_time',
                             'seeding_time', 'time_added', 'distributed_copies', 'num_pieces',
                             'piece_length', 'download_location', 'file_progress', 'file_priorities', 'message',
                             'total_wanted', 'tracker_host', 'owner', 'seed_rank', 'last_seen_complete',
                             'completed_time', 'time_since_transfer']
        self.file_list = None
        self.current_file = None
        self.current_file_idx = 0
        self.file_off = 0
        self.more_to_draw = False
        self.full_names = None
        self.column_string = ''
        self.files_sep = None
        self.marked = {}

        BaseMode.__init__(self, stdscr, encoding)
        self.column_names = ['Filename', 'Size', 'Progress', 'Priority']
        self.__update_columns()

        self._listing_start = self.rows // 2
        self._listing_space = self._listing_start - self._listing_start

        client.register_event_handler('TorrentFileRenamedEvent', self._on_torrentfilerenamed_event)
        client.register_event_handler('TorrentFolderRenamedEvent', self._on_torrentfolderrenamed_event)
        client.register_event_handler('TorrentRemovedEvent', self._on_torrentremoved_event)

        util.safe_curs_set(util.Curser.INVISIBLE)
        self.stdscr.notimeout(0)
示例#19
0
 def pause(self):
     self.pop_popup()
     BaseMode.pause(self)
示例#20
0
 def on_resize(self, rows, cols):
     BaseMode.on_resize(self, rows, cols)
     if self.popup:
         self.popup.handle_resize()
     self._listing_space = self.rows - 5
     self.refresh()
示例#21
0
 def on_resize(self, rows, cols):
     BaseMode.on_resize(self, rows, cols)
     self.refresh()
示例#22
0
 def __init__(self, parent_mode, stdscr, encoding=None):
     BaseMode.__init__(self, stdscr, encoding)
     self.parent_mode = parent_mode
     self.offset = 0
示例#23
0
 def resume(self):
     BaseMode.resume(self)
     self.refresh()
示例#24
0
 def resume(self):
     BaseMode.resume(self)
     self.refresh()
示例#25
0
    def __init__(self, stdscr, encoding=None):
        # Get a handle to the main console
        self.console = component.get('ConsoleUI')
        Commander.__init__(self, self.console._commands, interactive=True)

        self.batch_write = False

        # A list of strings to be displayed based on the offset (scroll)
        self.lines = []
        # The offset to display lines
        self.display_lines_offset = 0

        # Holds the user input and is cleared on 'enter'
        self.input = ''
        self.input_incomplete = ''

        # Keep track of where the cursor is
        self.input_cursor = 0
        # Keep a history of inputs
        self.input_history = []
        self.input_history_index = 0

        # Keep track of double- and multi-tabs
        self.tab_count = 0

        self.console_config = component.get('TorrentList').config

        # To avoid having to truncate the file every time we're writing
        # or doing it on exit(and therefore relying on an error-less
        # or in other words clean exit, we're going to have two files
        # that we swap around based on length
        config_dir = deluge.configmanager.get_config_dir()
        self.history_file = [
            os.path.join(config_dir, 'cmd_line.hist1'),
            os.path.join(config_dir, 'cmd_line.hist2')
        ]
        self._hf_lines = [0, 0]
        if self.console_config['cmdline']['save_command_history']:
            try:
                with open(self.history_file[0], 'r', encoding='utf8') as _file:
                    lines1 = _file.read().splitlines()
                self._hf_lines[0] = len(lines1)
            except IOError:
                lines1 = []
                self._hf_lines[0] = 0

            try:
                with open(self.history_file[1], 'r', encoding='utf8') as _file:
                    lines2 = _file.read().splitlines()
                self._hf_lines[1] = len(lines2)
            except IOError:
                lines2 = []
                self._hf_lines[1] = 0

            # The non-full file is the active one
            if self._hf_lines[0] > self._hf_lines[1]:
                self.lines = lines1 + lines2
            else:
                self.lines = lines2 + lines1

            if len(self.lines) > MAX_HISTFILE_SIZE:
                self.lines = self.lines[-MAX_HISTFILE_SIZE:]

            # Instead of having additional input history file, we can
            # simply scan for lines beginning with ">>> "
            for i, line in enumerate(self.lines):
                line = remove_formatting(line)
                if line.startswith('>>> '):
                    console_input = line[4:]
                    if self.console_config['cmdline']['ignore_duplicate_lines']:
                        if len(self.input_history) > 0:
                            if self.input_history[-1] != console_input:
                                self.input_history.append(console_input)
                        else:
                            self.input_history.append(console_input)

            self.input_history_index = len(self.input_history)

        # show the cursor
        util.safe_curs_set(util.Curser.VERY_VISIBLE)
        BaseMode.__init__(self, stdscr, encoding, depend=['SessionProxy'])
示例#26
0
 def on_resize(self, rows, cols):
     BaseMode.on_resize(self, rows, cols)
     self.refresh()
示例#27
0
 def __init__(self, parent_mode, stdscr, encoding=None):
     BaseMode.__init__(self, stdscr, encoding)
     self.parent_mode = parent_mode
     self.offset = 0
示例#28
0
 def resume(self):
     BaseMode.resume(self)
     self.sidebar.show()
示例#29
0
 def resume(self):
     BaseMode.resume(self)
     self.sidebar.show()
示例#30
0
 def on_resize(self, rows, cols):
     BaseMode.on_resize(self, rows, cols)
     self.stdscr.erase()
     self.refresh()
示例#31
0
    def __init__(self, stdscr, encoding=None):
        # Get a handle to the main console
        self.console = component.get('ConsoleUI')
        Commander.__init__(self, self.console._commands, interactive=True)

        self.batch_write = False

        # A list of strings to be displayed based on the offset (scroll)
        self.lines = []
        # The offset to display lines
        self.display_lines_offset = 0

        # Holds the user input and is cleared on 'enter'
        self.input = ''
        self.input_incomplete = ''

        # Keep track of where the cursor is
        self.input_cursor = 0
        # Keep a history of inputs
        self.input_history = []
        self.input_history_index = 0

        # Keep track of double- and multi-tabs
        self.tab_count = 0

        self.console_config = component.get('TorrentList').config

        # To avoid having to truncate the file every time we're writing
        # or doing it on exit(and therefore relying on an error-less
        # or in other words clean exit, we're going to have two files
        # that we swap around based on length
        config_dir = deluge.configmanager.get_config_dir()
        self.history_file = [
            os.path.join(config_dir, 'cmd_line.hist1'),
            os.path.join(config_dir, 'cmd_line.hist2'),
        ]
        self._hf_lines = [0, 0]
        if self.console_config['cmdline']['save_command_history']:
            try:
                with open(self.history_file[0], 'r', encoding='utf8') as _file:
                    lines1 = _file.read().splitlines()
                self._hf_lines[0] = len(lines1)
            except IOError:
                lines1 = []
                self._hf_lines[0] = 0

            try:
                with open(self.history_file[1], 'r', encoding='utf8') as _file:
                    lines2 = _file.read().splitlines()
                self._hf_lines[1] = len(lines2)
            except IOError:
                lines2 = []
                self._hf_lines[1] = 0

            # The non-full file is the active one
            if self._hf_lines[0] > self._hf_lines[1]:
                self.lines = lines1 + lines2
            else:
                self.lines = lines2 + lines1

            if len(self.lines) > MAX_HISTFILE_SIZE:
                self.lines = self.lines[-MAX_HISTFILE_SIZE:]

            # Instead of having additional input history file, we can
            # simply scan for lines beginning with ">>> "
            for i, line in enumerate(self.lines):
                line = remove_formatting(line)
                if line.startswith('>>> '):
                    console_input = line[4:]
                    if self.console_config['cmdline']['ignore_duplicate_lines']:
                        if len(self.input_history) > 0:
                            if self.input_history[-1] != console_input:
                                self.input_history.append(console_input)
                        else:
                            self.input_history.append(console_input)

            self.input_history_index = len(self.input_history)

        # show the cursor
        util.safe_curs_set(util.Curser.VERY_VISIBLE)
        BaseMode.__init__(self, stdscr, encoding, depend=['SessionProxy'])
示例#32
0
 def pause(self):
     self.pop_popup()
     BaseMode.pause(self)
示例#33
0
 def on_resize(self, rows, cols):
     BaseMode.on_resize(self, rows, cols)
     self.stdscr.erase()
     self.refresh()
示例#34
0
 def on_resize(self, rows, cols):
     BaseMode.on_resize(self, rows, cols)
     if self.popup:
         self.popup.handle_resize()
     self._listing_space = self.rows - 5
     self.refresh()