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


Python configmanager.ConfigManager类代码示例

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


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

示例1: AutoAdd

class AutoAdd(component.Component):
    def __init__(self):
        component.Component.__init__(self, "AutoAdd", depend=["TorrentManager"], interval=5)
        # Get the core config
        self.config = ConfigManager("core.conf")

        # A list of filenames
        self.invalid_torrents = []
        # Filename:Attempts
        self.attempts = {}

        # Register set functions
        self.config.register_set_function("autoadd_enable",
            self._on_autoadd_enable, apply_now=True)
        self.config.register_set_function("autoadd_location",
            self._on_autoadd_location)

    def update(self):
        if not self.config["autoadd_enable"]:
            # We shouldn't be updating because autoadd is not enabled
            component.pause("AutoAdd")
            return

        # Check the auto add folder for new torrents to add
        if not os.path.isdir(self.config["autoadd_location"]):
            log.warning("Invalid AutoAdd folder: %s", self.config["autoadd_location"])
            component.pause("AutoAdd")
            return

        for filename in os.listdir(self.config["autoadd_location"]):
            try:
                filepath = os.path.join(self.config["autoadd_location"], filename)
            except UnicodeDecodeError, e:
                log.error("Unable to auto add torrent due to improper filename encoding: %s", e)
                continue
            if os.path.isfile(filepath) and filename.endswith(".torrent"):
                try:
                    filedump = self.load_torrent(filepath)
                except (RuntimeError, Exception), e:
                    # If the torrent is invalid, we keep track of it so that we
                    # can try again on the next pass.  This is because some
                    # torrents may not be fully saved during the pass.
                    log.debug("Torrent is invalid: %s", e)
                    if filename in self.invalid_torrents:
                        self.attempts[filename] += 1
                        if self.attempts[filename] >= MAX_NUM_ATTEMPTS:
                            os.rename(filepath, filepath + ".invalid")
                            del self.attempts[filename]
                            self.invalid_torrents.remove(filename)
                    else:
                        self.invalid_torrents.append(filename)
                        self.attempts[filename] = 1
                    continue

                # The torrent looks good, so lets add it to the session
                component.get("TorrentManager").add(filedump=filedump, filename=filename)

                os.remove(filepath)
开发者ID:EiNSTeiN-,项目名称:deluge-gtk3,代码行数:58,代码来源:autoadd.py

示例2: __init__

    def __init__(self):
        component.Component.__init__(self, "ConnectionManager")
        self.gtkui_config = ConfigManager("gtkui.conf")

        self.config = ConfigManager("hostlist.conf.1.2", DEFAULT_CONFIG)

        self.running = False
开发者ID:laanwj,项目名称:deluge,代码行数:7,代码来源:connectionmanager.py

示例3: update_config

    def update_config(self):
        self.config = ConfigManager("console.conf",DEFAULT_PREFS)
        s_primary = self.config["sort_primary"]
        s_secondary = self.config["sort_secondary"]
        self.__cols_to_show = [
            pref for pref in column_pref_names
                if ("show_%s" % pref) not in self.config
                or self.config["show_%s"%pref]
        ]

        self.__columns = [prefs_to_names[col] for col in self.__cols_to_show]
        self.__status_fields = column.get_required_fields(self.__columns)

        # we always need these, even if we're not displaying them
        for rf in ["state", "name", "queue", "progress"]:
            if rf not in self.__status_fields:
                self.__status_fields.append(rf)

        # same with sort keys
        if s_primary and (s_primary not in self.__status_fields):
            self.__status_fields.append(s_primary)
        if s_secondary and (s_secondary not in self.__status_fields):
            self.__status_fields.append(s_secondary)

        self.__update_columns()
开发者ID:Ashod,项目名称:Deluge,代码行数:25,代码来源:alltorrents.py

示例4: __init__

    def __init__(self):
        super(StatusTab, self).__init__('Status', 'status_tab', 'status_tab_label')

        self.config = ConfigManager('gtkui.conf')

        self.progressbar = self.main_builder.get_object('progressbar')
        self.piecesbar = None

        self.add_tab_widget('summary_availability', fratio, ('distributed_copies',))
        self.add_tab_widget('summary_total_downloaded', ftotal_sized,
                            ('all_time_download', 'total_payload_download'))
        self.add_tab_widget('summary_total_uploaded', ftotal_sized,
                            ('total_uploaded', 'total_payload_upload'))
        self.add_tab_widget('summary_download_speed', fspeed_max,
                            ('download_payload_rate', 'max_download_speed'))
        self.add_tab_widget('summary_upload_speed', fspeed_max,
                            ('upload_payload_rate', 'max_upload_speed'))
        self.add_tab_widget('summary_seeds', fpeer, ('num_seeds', 'total_seeds'))
        self.add_tab_widget('summary_peers', fpeer, ('num_peers', 'total_peers'))
        self.add_tab_widget('summary_eta', ftime_or_dash, ('eta',))
        self.add_tab_widget('summary_share_ratio', fratio, ('ratio',))
        self.add_tab_widget('summary_active_time', ftime_or_dash, ('active_time',))
        self.add_tab_widget('summary_seed_time', ftime_or_dash, ('seeding_time',))
        self.add_tab_widget('summary_seed_rank', fseed_rank_or_dash, ('seed_rank', 'seeding_time'))
        self.add_tab_widget('progressbar', fpcnt, ('progress', 'state', 'message'))
        self.add_tab_widget('summary_last_seen_complete', fdate_or_never, ('last_seen_complete',))
        self.add_tab_widget('summary_last_transfer', ftime_or_dash, ('time_since_transfer',))

        self.config.register_set_function('show_piecesbar', self.on_show_piecesbar_config_changed, apply_now=True)
开发者ID:deluge-torrent,项目名称:deluge,代码行数:29,代码来源:status_tab.py

示例5: __init__

    def __init__(self):
        component.Component.__init__(self, "ToolBar")
        log.debug("ToolBar Init..")
        self.window = component.get("MainWindow")
        self.toolbar = self.window.main_glade.get_widget("toolbar")
        self.config = ConfigManager("gtkui.conf")
        ### Connect Signals ###
        self.window.main_glade.signal_autoconnect({
            "on_toolbutton_add_clicked": self.on_toolbutton_add_clicked,
            "on_toolbutton_remove_clicked": self.on_toolbutton_remove_clicked,
            "on_toolbutton_pause_clicked": self.on_toolbutton_pause_clicked,
            "on_toolbutton_resume_clicked": self.on_toolbutton_resume_clicked,
            "on_toolbutton_preferences_clicked": \
                self.on_toolbutton_preferences_clicked,
            "on_toolbutton_connectionmanager_clicked": \
                self.on_toolbutton_connectionmanager_clicked,
            "on_toolbutton_queue_up_clicked": self.on_toolbutton_queue_up_clicked,
            "on_toolbutton_queue_down_clicked": self.on_toolbutton_queue_down_clicked
        })
        self.change_sensitivity = [
            "toolbutton_add",
            "toolbutton_remove",
            "toolbutton_pause",
            "toolbutton_resume",
            "toolbutton_queue_up",
            "toolbutton_queue_down"
        ]

        self.config.register_set_function("classic_mode", self._on_classic_mode, True)

        # Hide if necessary
        self.visible(self.config["show_toolbar"])
开发者ID:chlen-nigera,项目名称:Deluge.app,代码行数:32,代码来源:toolbar.py

示例6: __init__

    def __init__(self):
        component.Component.__init__(self, 'SystemTray', interval=4)
        self.mainwindow = component.get('MainWindow')
        self.config = ConfigManager('gtkui.conf')
        # List of widgets that need to be hidden when not connected to a host
        self.hide_widget_list = [
            'menuitem_add_torrent',
            'menuitem_pause_session',
            'menuitem_resume_session',
            'menuitem_download_limit',
            'menuitem_upload_limit',
            'menuitem_quitdaemon',
            'separatormenuitem1',
            'separatormenuitem2',
            'separatormenuitem3',
            'separatormenuitem4'
        ]
        self.config.register_set_function('enable_system_tray', self.on_enable_system_tray_set)
        # bit of a hack to prevent function from doing something on startup
        self.__enabled_set_once = False
        self.config.register_set_function('enable_appindicator', self.on_enable_appindicator_set)

        self.max_download_speed = -1.0
        self.download_rate = 0.0
        self.max_upload_speed = -1.0
        self.upload_rate = 0.0

        self.config_value_changed_dict = {
            'max_download_speed': self._on_max_download_speed,
            'max_upload_speed': self._on_max_upload_speed
        }
开发者ID:deluge-torrent,项目名称:deluge,代码行数:31,代码来源:systemtray.py

示例7: __init__

    def __init__(self):
        component.Component.__init__(self, "SystemTray", interval=4)
        self.window = component.get("MainWindow")
        self.config = ConfigManager("gtkui.conf")
        # List of widgets that need to be hidden when not connected to a host
        self.hide_widget_list = [
            "menuitem_add_torrent",
            "menuitem_pause_all",
            "menuitem_resume_all",
            "menuitem_download_limit",
            "menuitem_upload_limit",
            "menuitem_quitdaemon",
            "separatormenuitem1",
            "separatormenuitem2",
            "separatormenuitem3",
            "separatormenuitem4"
        ]
        self.config.register_set_function("enable_system_tray", self.on_enable_system_tray_set)
        # bit of a hack to prevent function from doing something on startup
        self.__enabled_set_once = False
        self.config.register_set_function("enable_appindicator", self.on_enable_appindicator_set)

        self.max_download_speed = -1.0
        self.download_rate = 0.0
        self.max_upload_speed = -1.0
        self.upload_rate = 0.0

        self.config_value_changed_dict = {
            "max_download_speed": self._on_max_download_speed,
            "max_upload_speed": self._on_max_upload_speed
        }
开发者ID:NoGare,项目名称:deluge1,代码行数:31,代码来源:systemtray.py

示例8: run

    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()
开发者ID:deluge-torrent,项目名称:deluge,代码行数:32,代码来源:main.py

示例9: __init__

 def __init__(self, stdscr, encoding=None):
     self.popup = None
     self.statuses = {}
     self.messages = deque()
     self.config = ConfigManager("hostlist.conf.1.2", DEFAULT_CONFIG)
     BaseMode.__init__(self, stdscr, encoding)
     self.__update_statuses()
     self.__update_popup()
开发者ID:Ashod,项目名称:Deluge,代码行数:8,代码来源:connectionmanager.py

示例10: __load_config

    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,代码行数:19,代码来源:connectionmanager.py

示例11: __init__

 def __init__(self):
     super(WebApi, self).__init__("Web", depend=["SessionProxy"])
     self.host_list = ConfigManager("hostlist.conf.1.2", DEFAULT_HOSTS)
     if not os.path.isfile(self.host_list.config_file):
         self.host_list.save()
     self.core_config = CoreConfig()
     self.event_queue = EventQueue()
     try:
         self.sessionproxy = component.get("SessionProxy")
     except KeyError:
         self.sessionproxy = SessionProxy()
开发者ID:Kash-Krishna,项目名称:SharkByte,代码行数:11,代码来源:json_api.py

示例12: __init__

    def __init__(self):
        if wnck:
            self.screen = wnck.screen_get_default()
        component.Component.__init__(self, 'MainWindow', interval=2)
        self.config = ConfigManager('gtkui.conf')
        self.main_builder = gtk.Builder()

        # Patch this GtkBuilder to avoid connecting signals from elsewhere
        #
        # Think about splitting up  mainwindow gtkbuilder file into the necessary parts
        # to avoid GtkBuilder monkey patch. Those parts would then need adding to mainwindow 'by hand'.
        self.gtk_builder_signals_holder = _GtkBuilderSignalsHolder()
        self.main_builder.prev_connect_signals = copy.deepcopy(self.main_builder.connect_signals)

        def patched_connect_signals(*a, **k):
            raise RuntimeError('In order to connect signals to this GtkBuilder instance please use '
                               '"component.get(\'MainWindow\').connect_signals()"')
        self.main_builder.connect_signals = patched_connect_signals

        # Get Gtk Builder files Main Window, New release dialog, and Tabs.
        for filename in ('main_window.ui', 'main_window.new_release.ui', 'main_window.tabs.ui',
                         'main_window.tabs.menu_file.ui', 'main_window.tabs.menu_peer.ui'):
            self.main_builder.add_from_file(
                resource_filename('deluge.ui.gtkui', os.path.join('glade', filename)))

        self.window = self.main_builder.get_object('main_window')
        self.window.set_icon(deluge.ui.gtkui.common.get_deluge_icon())
        self.vpaned = self.main_builder.get_object('vpaned')
        self.initial_vpaned_position = self.config['window_pane_position']

        # Keep a list of components to pause and resume when changing window state.
        self.child_components = ['TorrentView', 'StatusBar', 'TorrentDetails']

        # Load the window state
        self.load_window_state()

        # Keep track of window minimization state so we don't update UI when it is minimized.
        self.is_minimized = False
        self.restart = False

        self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL, [('text/uri-list', 0, 80)], ACTION_COPY)

        # Connect events
        self.window.connect('window-state-event', self.on_window_state_event)
        self.window.connect('configure-event', self.on_window_configure_event)
        self.window.connect('delete-event', self.on_window_delete_event)
        self.window.connect('drag-data-received', self.on_drag_data_received_event)
        self.vpaned.connect('notify::position', self.on_vpaned_position_event)
        self.window.connect('expose-event', self.on_expose_event)

        self.config.register_set_function('show_rate_in_title', self._on_set_show_rate_in_title, apply_now=False)

        client.register_event_handler('NewVersionAvailableEvent', self.on_newversionavailable_event)
开发者ID:deluge-torrent,项目名称:deluge,代码行数:53,代码来源:mainwindow.py

示例13: __init__

    def __init__(self):
        component.Component.__init__(self, "AutoAdd", depend=["TorrentManager"], interval=5)
        # Get the core config
        self.config = ConfigManager("core.conf")

        # A list of filenames
        self.invalid_torrents = []
        # Filename:Attempts
        self.attempts = {}

        # Register set functions
        self.config.register_set_function("autoadd_enable",
            self._on_autoadd_enable, apply_now=True)
        self.config.register_set_function("autoadd_location",
            self._on_autoadd_location)
开发者ID:EiNSTeiN-,项目名称:deluge-gtk3,代码行数:15,代码来源:autoadd.py

示例14: __init__

    def __init__(self):
        if Wnck:
            self.screen = Wnck.Screen.get_default()
        component.Component.__init__(self, "MainWindow", interval=2)
        self.config = ConfigManager("gtkui.conf")
        # Get the glade file for the main window
        self.main_glade = Gtk.Builder()
        self.main_glade.add_from_file(
                    pkg_resources.resource_filename("deluge.ui.gtkui",
                                                    "builder/main_window.ui"))

        self.window_signals = {}

        self.window = self.main_glade.get_object("main_window")

        self.window.set_icon(common.get_deluge_icon())

        self.vpaned = self.main_glade.get_object("vpaned")
        self.initial_vpaned_position = self.config["window_pane_position"]

        # Load the window state
        self.load_window_state()

        # Keep track of window's minimization state so that we don't update the
        # UI when it is minimized.
        self.is_minimized = False

        self.window.drag_dest_set(Gtk.DestDefaults.ALL, [Gtk.TargetEntry.new('text/uri-list', 0,
            80)], Gdk.DragAction.COPY)

        # Connect events
        self.window.connect("window-state-event", self.on_window_state_event)
        self.window.connect("configure-event", self.on_window_configure_event)
        self.window.connect("delete-event", self.on_window_delete_event)
        self.window.connect("drag-data-received", self.on_drag_data_received_event)
        self.vpaned.connect("notify::position", self.on_vpaned_position_event)
        self.window.connect("draw", self.on_expose_event)

        self.config.register_set_function("show_rate_in_title", self._on_set_show_rate_in_title, apply_now=False)

        client.register_event_handler("NewVersionAvailableEvent", self.on_newversionavailable_event)
        client.register_event_handler("TorrentFinishedEvent", self.on_torrentfinished_event)
开发者ID:EiNSTeiN-,项目名称:deluge-gtk3,代码行数:42,代码来源:mainwindow.py

示例15: enable

    def enable(self):
        self.config = ConfigManager("execute.conf", DEFAULT_CONFIG)
        event_manager = component.get("EventManager")
        self.registered_events = {}

        # Go through the commands list and register event handlers
        for command in self.config["commands"]:
            event = command[EXECUTE_EVENT]
            if event in self.registered_events:
                continue

            def create_event_handler(event):
                def event_handler(torrent_id):
                    self.execute_commands(torrent_id, event)
                return event_handler
            event_handler = create_event_handler(event)
            event_manager.register_event_handler(EVENT_MAP[event], event_handler)
            self.registered_events[event] = event_handler

        log.debug("Execute core plugin enabled!")
开发者ID:s0undt3ch,项目名称:Deluge,代码行数:20,代码来源:core.py


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