当前位置: 首页>>代码示例>>Python>>正文


Python ConfigManager.run_converter方法代码示例

本文整理汇总了Python中deluge.configmanager.ConfigManager.run_converter方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigManager.run_converter方法的具体用法?Python ConfigManager.run_converter怎么用?Python ConfigManager.run_converter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在deluge.configmanager.ConfigManager的用法示例。


在下文中一共展示了ConfigManager.run_converter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __load_config

# 需要导入模块: from deluge.configmanager import ConfigManager [as 别名]
# 或者: from deluge.configmanager.ConfigManager import run_converter [as 别名]
    def __load_config(self):
        auth_file = deluge.configmanager.get_config_dir("auth")
        if not os.path.exists(auth_file):
            from deluge.common import create_localclient_account
            create_localclient_account()

        localclient_username, localclient_password = get_localhost_auth()
        DEFAULT_CONFIG = {
            "hosts": [(
                hashlib.sha1(str(time.time())).hexdigest(),
                 DEFAULT_HOST,
                 DEFAULT_PORT,
                 localclient_username,
                 localclient_password
            )]
        }
        config = ConfigManager("hostlist.conf.1.2", DEFAULT_CONFIG)
        config.run_converter((0, 1), 2, self.__migrate_config_1_to_2)
        return config
开发者ID:cheuschober,项目名称:deluge,代码行数:21,代码来源:connectionmanager.py

示例2: ConsoleUI

# 需要导入模块: from deluge.configmanager import ConfigManager [as 别名]
# 或者: from deluge.configmanager.ConfigManager import run_converter [as 别名]

#.........这里部分代码省略.........
            return d

        def on_connect_fail(reason):
            if reason.check(DelugeError):
                rm = reason.getErrorMessage()
            else:
                rm = reason.value.message
            print('Could not connect to daemon: %s:%s\n %s' % (options.daemon_addr, options.daemon_port, rm))
            commander.do_command('quit')

        d = None
        if not self.interactive and options.parsed_cmds[0].command == 'connect':
            d = commander.do_command(options.parsed_cmds.pop(0))
        else:
            log.info('connect: host=%s, port=%s, username=%s, password=%s',
                     options.daemon_addr, options.daemon_port, options.daemon_user, options.daemon_pass)
            d = client.connect(options.daemon_addr, options.daemon_port, options.daemon_user, options.daemon_pass)
        d.addCallback(on_connect)
        d.addErrback(on_connect_fail)
        return d

    def run(self, stdscr):
        """This method is called by the curses.wrapper to start the mainloop and screen.

        Args:
            stdscr (_curses.curses window): curses screen passed in from curses.wrapper.

        """
        # We want to do an interactive session, so start up the curses screen and
        # pass it the function that handles commands
        colors.init_colors()
        self.stdscr = stdscr
        self.config = ConfigManager('console.conf', defaults=DEFAULT_CONSOLE_PREFS, file_version=2)
        self.config.run_converter((0, 1), 2, self._migrate_config_1_to_2)

        self.statusbars = StatusBars()
        from deluge.ui.console.modes.connectionmanager import ConnectionManager
        self.register_mode(ConnectionManager(stdscr, self.encoding), set_mode=True)

        torrentlist = self.register_mode(TorrentList(self.stdscr, self.encoding))
        self.register_mode(CmdLine(self.stdscr, self.encoding))
        self.register_mode(EventView(torrentlist, self.stdscr, self.encoding))
        self.register_mode(TorrentDetail(torrentlist, self.stdscr, self.config, self.encoding))
        self.register_mode(Preferences(torrentlist, self.stdscr, self.config, self.encoding))
        self.register_mode(AddTorrents(torrentlist, self.stdscr, self.config, self.encoding))

        self.eventlog = EventLog()

        self.active_mode.topbar = '{!status!}Deluge ' + deluge.common.get_version() + ' Console'
        self.active_mode.bottombar = '{!status!}'
        self.active_mode.refresh()
        # Start the twisted mainloop
        reactor.run()

    @overrides(TermResizeHandler)
    def on_terminal_size(self, *args):
        rows, cols = super(ConsoleUI, self).on_terminal_size(args)
        for mode in self.modes:
            self.modes[mode].on_resize(rows, cols)

    def register_mode(self, mode, set_mode=False):
        self.modes[mode.mode_name] = mode
        if set_mode:
            self.set_mode(mode.mode_name)
        return mode
开发者ID:deluge-torrent,项目名称:deluge,代码行数:69,代码来源:main.py


注:本文中的deluge.configmanager.ConfigManager.run_converter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。