Пример #1
0
	def signal_popup_menu_activate_reload(self, _):
		treeview = self.gobjects['treeview_plugins']
		pm = self.application.plugin_manager
		selected_plugin = None
		selection = treeview.get_selection()
		if selection.count_selected_rows():
			(model, tree_paths) = selection.get_selected_rows()
			selected_plugin = model[tree_paths[0]][0]

		for tree_iter in gui_utilities.gtk_treeview_selection_iterate(treeview):
			name = self._model[tree_iter][0]  # pylint: disable=unsubscriptable-object
			enabled = name in pm.enabled_plugins
			pm.unload(name)
			try:
				klass = pm.load(name, reload_module=True)
			except Exception as error:
				self._on_plugin_load_error(name, error)
				if name == selected_plugin:
					self._set_plugin_info(name)
				self._model[tree_iter][2] = "{0} (Reload Failed)".format(name)  # pylint: disable=unsubscriptable-object
				continue
			if name in self._module_errors:
				del self._module_errors[name]
			self._model[tree_iter][2] = klass.title  # pylint: disable=unsubscriptable-object
			if name == selected_plugin:
				self._set_plugin_info(name)
			if enabled:
				pm.enable(name)
Пример #2
0
    def _reload(self):
        self._update_status_bar("Reloading... ")
        treeview = self.gobjects['treeview_plugins']
        pm = self.application.plugin_manager
        selected_plugin = None
        selection = treeview.get_selection()
        if selection.count_selected_rows():
            (model, tree_paths) = selection.get_selected_rows()
            selected_plugin = model[tree_paths[0]][0]

        for tree_iter in gui_utilities.gtk_treeview_selection_iterate(
                treeview):
            model_row = self._model[tree_iter]
            # only reloading installed plugins is currently supported
            named_row = self._named_model(*model_row)
            if named_row.type == _ROW_TYPE_CATALOG and named_row.id != _LOCAL_REPOSITORY_ID:
                self._reload_catalog(named_row, tree_iter)
            elif named_row.type == _ROW_TYPE_REPOSITORY:
                self._reload_repository(model_row)
            elif named_row.type == _ROW_TYPE_PLUGIN:
                if not named_row.installed:
                    self._update_status_bar(
                        'Cannot reload a plugin that is not installed.')
                    continue
                self._reload_plugin(named_row, model_row, pm, tree_iter,
                                    selected_plugin)
            else:
                self.logger.warning(
                    'reload selected for an unsupported row type')
Пример #3
0
    def signal_popup_menu_activate_reload(self, _):
        treeview = self.gobjects['treeview_plugins']
        pm = self.application.plugin_manager
        selected_plugin = None
        selection = treeview.get_selection()
        if selection.count_selected_rows():
            (model, tree_paths) = selection.get_selected_rows()
            selected_plugin = model[tree_paths[0]][0]

        for tree_iter in gui_utilities.gtk_treeview_selection_iterate(
                treeview):
            name = self._model[tree_iter][0]  # pylint: disable=unsubscriptable-object
            enabled = name in pm.enabled_plugins
            pm.unload(name)
            try:
                klass = pm.load(name, reload_module=True)
            except Exception as error:
                self._on_plugin_load_error(name, error)
                if name == selected_plugin:
                    self._set_plugin_info(name)
                self._model[tree_iter][2] = "{0} (Reload Failed)".format(name)  # pylint: disable=unsubscriptable-object
                continue
            if name in self._module_errors:
                del self._module_errors[name]
                self._model[tree_iter][2] = klass.title  # pylint: disable=unsubscriptable-object
            if name == selected_plugin:
                self._set_plugin_info(name)
            if enabled:
                pm.enable(name)
Пример #4
0
	def signal_popup_menu_activate_reload(self, _):
		treeview = self.gobjects['treeview_plugins']
		pm = self.application.plugin_manager
		selected_plugin = None
		selection = treeview.get_selection()
		if selection.count_selected_rows():
			(model, tree_paths) = selection.get_selected_rows()
			selected_plugin = model[tree_paths[0]][0]

		for tree_iter in gui_utilities.gtk_treeview_selection_iterate(treeview):
			named_row = self._named_model(*self._model[tree_iter])
			if named_row.type != _ROW_TYPE_PLUGIN:
				continue
			if named_row.id not in pm.enabled_plugins:
				continue
			enabled = named_row.id in pm.enabled_plugins
			pm.unload(named_row.id)
			try:
				klass = pm.load(named_row.id, reload_module=True)
			except Exception as error:
				self._on_plugin_load_error(named_row.id, error)
				if named_row.id == selected_plugin:
					self._set_info(named_row.id)
				self._set_model_item(tree_iter, 'title', "{0} (Reload Failed)".format(named_row.id))
				continue
			if named_row.id in self._module_errors:
				del self._module_errors[named_row.id]
			self._set_model_item(tree_iter, 'title', klass.title)
			if named_row.id == selected_plugin:
				self._set_info(self._model[tree_iter])
			if enabled:
				pm.enable(named_row.id)
Пример #5
0
	def _prompt_to_delete_row(self, treeview, _):
		if isinstance(self.loader_thread, threading.Thread) and self.loader_thread.is_alive():
			gui_utilities.show_dialog_warning('Can Not Delete Rows While Loading', self.parent)
			return
		model = treeview.get_model()
		row_ids = [model.get_value(ti, 0) for ti in gui_utilities.gtk_treeview_selection_iterate(treeview)]
		if len(row_ids) == 0:
			return
		elif len(row_ids) == 1:
			message = 'Delete This Row?'
		else:
			message = "Delete These {0:,} Rows?".format(len(row_ids))
		if not gui_utilities.show_dialog_yes_no(message, self.parent, 'This information will be lost.'):
			return
		self.application.emit(self.table_name[:-1] + '-delete', row_ids)
Пример #6
0
	def _prompt_to_delete_row(self, treeview, _):
		if isinstance(self.loader_thread, threading.Thread) and self.loader_thread.is_alive():
			gui_utilities.show_dialog_warning('Can Not Delete Rows While Loading', self.parent)
			return
		model = treeview.get_model()
		row_ids = [model.get_value(ti, 0) for ti in gui_utilities.gtk_treeview_selection_iterate(treeview)]
		if len(row_ids) == 0:
			return
		elif len(row_ids) == 1:
			message = 'Delete This Row?'
		else:
			message = "Delete These {0:,} Rows?".format(len(row_ids))
		if not gui_utilities.show_dialog_yes_no(message, self.parent, 'This information will be lost.'):
			return
		self.application.emit(self.table_name[:-1] + '-delete', row_ids)
Пример #7
0
    def signal_popup_menu_activate_reload(self, _):
        treeview = self.gobjects['treeview_plugins']
        pm = self.application.plugin_manager
        selected_plugin = None
        selection = treeview.get_selection()
        if selection.count_selected_rows():
            (model, tree_paths) = selection.get_selected_rows()
            selected_plugin = model[tree_paths[0]][0]

        for tree_iter in gui_utilities.gtk_treeview_selection_iterate(
                treeview):
            model_row = self._model[tree_iter]
            # only reloading installed plugins is currently supported
            if model_row.parent is None:
                continue
            named_row = self._named_model(*model_row)
            if named_row.type != _ROW_TYPE_PLUGIN:
                continue
            if not named_row.installed:
                continue

            enabled = named_row.id in pm.enabled_plugins
            pm.unload(named_row.id)
            try:
                klass = pm.load(named_row.id, reload_module=True)
            except Exception as error:
                self._on_plugin_load_error(named_row.id, error)
                if named_row.id == selected_plugin:
                    self._set_info(model_row)
                self._set_model_item(
                    tree_iter, 'title',
                    "{0} (Reload Failed)".format(named_row.id))
                continue
            if named_row.id in self._module_errors:
                del self._module_errors[named_row.id]
            self._set_model_item(tree_iter, 'title', klass.title)
            self._set_model_item(tree_iter, 'compatibility',
                                 'Yes' if klass.is_compatible else 'No')
            self._set_model_item(tree_iter, 'version', klass.version)
            if named_row.id == selected_plugin:
                self._set_info(self._model[tree_iter])
            if enabled:
                pm.enable(named_row.id)