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


Python ConfigManager.get方法代码示例

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


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

示例1: Core

# 需要导入模块: from deluge.configmanager import ConfigManager [as 别名]
# 或者: from deluge.configmanager.ConfigManager import get [as 别名]
class Core(component.Component):
    def __init__(self, listen_interface=None, read_only_config_keys=None):
        log.debug('Core init...')
        component.Component.__init__(self, 'Core')

        deluge_version = deluge.common.get_version()
        split_version = deluge.common.VersionSplit(deluge_version).version
        while len(split_version) < 4:
            split_version.append(0)

        deluge_fingerprint = lt.generate_fingerprint('DE', *split_version)
        user_agent = 'Deluge/{} libtorrent/{}'.format(deluge_version, self.get_libtorrent_version())

        # Start the libtorrent session.
        log.debug('Starting session (fingerprint: %s, user_agent: %s)', deluge_fingerprint, user_agent)
        settings_pack = {'peer_fingerprint': deluge_fingerprint,
                         'user_agent': user_agent,
                         'ignore_resume_timestamps': True}
        self.session = lt.session(settings_pack, flags=0)

        # Load the settings, if available.
        self._load_session_state()

        # Enable libtorrent extensions
        # Allows peers to download the metadata from the swarm directly
        self.session.add_extension('ut_metadata')
        # Ban peers that sends bad data
        self.session.add_extension('smart_ban')

        # Create the components
        self.eventmanager = EventManager()
        self.preferencesmanager = PreferencesManager()
        self.alertmanager = AlertManager()
        self.pluginmanager = PluginManager(self)
        self.torrentmanager = TorrentManager()
        self.filtermanager = FilterManager(self)
        self.authmanager = AuthManager()

        # New release check information
        self.new_release = None

        # External IP Address from libtorrent
        self.external_ip = None
        self.eventmanager.register_event_handler('ExternalIPEvent', self._on_external_ip_event)

        # GeoIP instance with db loaded
        self.geoip_instance = None

        # These keys will be dropped from the set_config() RPC and are
        # configurable from the command-line.
        self.read_only_config_keys = read_only_config_keys
        log.debug('read_only_config_keys: %s', read_only_config_keys)

        # Get the core config
        self.config = ConfigManager('core.conf')
        self.config.save()

        # If there was an interface value from the command line, use it, but
        # store the one in the config so we can restore it on shutdown
        self.__old_interface = None
        if listen_interface:
            if deluge.common.is_ip(listen_interface):
                self.__old_interface = self.config['listen_interface']
                self.config['listen_interface'] = listen_interface
            else:
                log.error('Invalid listen interface (must be IP Address): %s', listen_interface)

        # New release check information
        self.__new_release = None

        # Session status timer
        self.session_status = {}
        self.session_status_timer_interval = 0.5
        self.session_status_timer = task.LoopingCall(self.session.post_session_stats)
        self.alertmanager.register_handler('session_stats_alert', self._on_alert_session_stats)
        self._session_rates = {(k_rate, k_bytes): 0 for k_rate, k_bytes in SESSION_RATES_MAPPING.items()}
        self.session_rates_timer_interval = 2
        self.session_rates_timer = task.LoopingCall(self._update_session_rates)

    def start(self):
        """Starts the core"""
        self.session_status_timer.start(self.session_status_timer_interval)
        self.session_rates_timer.start(self.session_rates_timer_interval, now=False)

    def stop(self):
        log.debug('Core stopping...')

        if self.session_status_timer.running:
            self.session_status_timer.stop()

        if self.session_rates_timer.running:
            self.session_rates_timer.stop()

        # Save the libtorrent session state
        self._save_session_state()

        # We stored a copy of the old interface value
        if self.__old_interface:
            self.config['listen_interface'] = self.__old_interface

#.........这里部分代码省略.........
开发者ID:deluge-torrent,项目名称:deluge,代码行数:103,代码来源:core.py


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