Beispiel #1
0
def upgradeInstalledPlugins():
    installer = pyplugin_installer.instance()
    initPluginManager(installer)

    errors = []
    pluginsList = plugins.all().copy()
    for plugin in pluginsList:
        if isBoundlessPlugin(pluginsList[plugin]):
            if pluginsList[plugin]['installed'] and pluginsList[plugin]['status'] == 'upgradeable':
                dlg = QgsPluginInstallerInstallingDialog(iface.mainWindow(), plugins.all()[plugin])
                dlg.exec_()
                if dlg.result():
                    errors.append(dlg.result())
                else:
                    updateAvailablePlugins()
                    loadPlugin(plugins.all()[plugin]['id'])
                    plugins.getAllInstalled(testLoad=True)
                    plugins.rebuild()
                    if not plugins.all()[plugin]["error"]:
                        if startPlugin(plugins.all()[plugin]['id']):
                            settings = QSettings()
                            settings.setValue('/PythonPlugins/' + plugins.all()[plugin]['id'], True)

    installer.exportPluginsToManager()
    return errors
Beispiel #2
0
def installAllFromRepository():
    """Install Boundless plugins from remote repository
    """
    installer = pyplugin_installer.instance()
    initPluginManager(installer)

    errors = []
    pluginsList = plugins.all().copy()
    for plugin in pluginsList:
        if isBoundlessPlugin(pluginsList[plugin]):
            if (pluginsList[plugin]['installed'] and pluginsList[plugin]['deprecated']) or \
                    not pluginsList[plugin]['deprecated'] and \
                    pluginsList[plugin]["zip_repository"] != '':
                dlg = QgsPluginInstallerInstallingDialog(iface.mainWindow(), plugins.all()[plugin])
                dlg.exec_()
                if dlg.result():
                    errors.append(dlg.result())
                else:
                    updateAvailablePlugins()
                    loadPlugin(plugins.all()[plugin]['id'])
                    plugins.getAllInstalled(testLoad=True)
                    plugins.rebuild()
                    if not plugins.all()[plugin]["error"]:
                        if startPlugin(plugins.all()[plugin]['id']):
                            settings = QSettings()
                            settings.setValue('/PythonPlugins/' + plugins.all()[plugin]['id'], True)

    installer.exportPluginsToManager()
    return errors
def loadPlugins():
    global _plugins
    _plugins = {}
    installer = pyplugin_installer.instance()
    installer.fetchAvailablePlugins(True)
    for name in plugins.all():
        plugin = plugins.all()[name]
        if utils.isBoundlessPlugin(plugin) and name not in ["boundlessconnect"]:
            _plugins[plugin["name"]] = copy(plugin)
Beispiel #4
0
def showPluginManager(boundlessOnly):
    """Show Plugin Manager with all plugins. This includes plugins from
    Official QGIS plugins repository and plugins from Boundless plugins
    repository (local or remote).
    If boundlessOnly=True, it will only show Boundless plugins
    """

    installer = pyplugin_installer.instance()

    initPluginManager(installer, boundlessOnly)
    iface.pluginManagerInterface().showPluginManager(2)
    # Restore repositories, as we don't want to keep local repo in cache
    repositories.load()
Beispiel #5
0
def deprecatedPlugins():
    """Return list of installed deprecated Boundless plugins
    """
    installer = pyplugin_installer.instance()
    initPluginManager(installer)

    deprecated = []
    for plugin in plugins.all():
        if isBoundlessPlugin(plugins.all()[plugin]):
            if plugins.all()[plugin]['installed'] and \
                    (plugins.all()[plugin]['deprecated'] or
                    plugin in oldPlugins):
                deprecated.append(plugins.all()[plugin])

    return deprecated
def installPlugin(pluginName):
    installer = pyplugin_installer.instance()
    installer.fetchAvailablePlugins(False)

    if pluginName in plugins.all():
        plugin = plugins.all()[pluginName]
        if pluginName not in utils.available_plugins or plugin['status'] == 'upgradeable':
            dlg = QgsPluginInstallerInstallingDialog(iface.mainWindow(), plugin)
            dlg.exec_()
            if dlg.result():
                return tr('The {} plugin could not be installed.<br>'
                            'The following problems were found during installation:<br>{}'.format(pluginName, dlg.result()))
    else:
        return tr('The {} plugin could not be installed.<br>'
                    'It was not found in any of the available repositories.'.format(pluginName))
Beispiel #7
0
def installAllFromDirectory(pluginsPath):
    """Install plugins from specified directory
    """
    errors = []

    installer = pyplugin_installer.instance()

    mask = pluginsPath + '/*.zip'

    for plugin in glob.glob(mask):
        result = installFromZipFile(plugin)
        if result is not None:
            errors.append(result)

    installer.exportPluginsToManager()
    return errors
            " Is the script running in the QGIS env?")

    zip_files = [file for file in pathlib.Path("./").glob("*.zip")]

    if not zip_files:
        raise PluginInstallException(
            f"ERROR: No plugin zip file found at {pathlib.Path('./').absolute()}."
        )

    if len(zip_files) > 1:
        raise PluginInstallException(
            f"ERROR: More than one plugin zip file found at {pathlib.Path('./').absolute()}."
            f" Found {[str(f) for f in zip_files]}.")

    plugin_install_zip = zip_files[0]
    plugin_installer = pyplugin_installer.instance()
    # Make sure plugin is not installed
    assert ("planet_explorer"
            not in pyplugin_installer.installer_data.plugins.all().keys()
            ), "Planet plugin is already installed!"

    # Attach the error catcher
    QgsApplication.messageLog().messageReceived.connect(error_catcher)

    # Install from the zip file
    plugin_installer.installFromZipFile(str(plugin_install_zip.absolute()))
    assert ("planet_explorer"
            in pyplugin_installer.installer_data.plugins.all().keys()
            ), "Planet plugin failed to install!"

    if ERROR_OCCURRED:
 def _install():
     installer = pyplugin_installer.instance()
     installer.installPlugin(self.plugin["id"])
     self.plugin["status"] = "installed"
    def initGui(self):
        pyplugin_installer.installer.initPluginInstaller()
        pyplugin_installer.installer_data.plugins.rebuild()

        if "projectgenerator" in available_plugins:
            pyplugin_installer.instance().uninstallPlugin("projectgenerator",
                                                          quiet=True)
        self.__generate_action = QAction(
            QIcon(
                os.path.join(os.path.dirname(__file__),
                             "images/QgisModelBaker-icon.svg")),
            self.tr("Generate"),
            None,
        )
        self.__export_action = QAction(
            QIcon(
                os.path.join(
                    os.path.dirname(__file__),
                    "images/QgisModelBaker-xtf-export-icon.svg",
                )),
            self.tr("Export Interlis Transfer File (.xtf)"),
            None,
        )
        self.__importdata_action = QAction(
            QIcon(
                os.path.join(
                    os.path.dirname(__file__),
                    "images/QgisModelBaker-xtf-import-icon.svg",
                )),
            self.tr("Import Interlis Transfer File (.xtf)"),
            None,
        )
        self.__datasetmanager_action = QAction(
            QIcon(
                os.path.join(
                    os.path.dirname(__file__),
                    "images/QgisModelBaker-datasetmanager-icon.svg",
                )),
            self.tr("Dataset Manager"),
            None,
        )
        self.__validate_action = QAction(
            QIcon(
                os.path.join(
                    os.path.dirname(__file__),
                    "images/QgisModelBaker-validator_icon.svg",
                )),
            self.tr("Data Validator"),
            None,
        )
        self.__workflow_wizard_action = QAction(
            QIcon(
                os.path.join(os.path.dirname(__file__),
                             "images/QgisModelBaker-wizard.svg")),
            self.tr("Import/Export Wizard"),
            None,
        )
        self.__configure_action = QAction(self.tr("Settings"), None)
        self.__help_action = QAction(self.tr("Help"), None)
        self.__about_action = QAction(self.tr("About"), None)
        self.__separator = QAction(None)
        self.__separator.setSeparator(True)
        self.__dataset_selector_action = QAction(self.tr("Dataset Selector"))

        # set these actions checkable to visualize that the dialog is open
        self.__generate_action.setCheckable(True)
        self.__export_action.setCheckable(True)
        self.__importdata_action.setCheckable(True)
        self.__workflow_wizard_action.setCheckable(True)
        self.__datasetmanager_action.setCheckable(True)
        self.__validate_action.setCheckable(True)

        self.__generate_action.triggered.connect(self.show_generate_dialog)
        self.__configure_action.triggered.connect(self.show_options_dialog)
        self.__importdata_action.triggered.connect(self.show_importdata_dialog)
        self.__datasetmanager_action.triggered.connect(
            self.show_datasetmanager_dialog)
        self.__validate_action.triggered.connect(self.show_validate_dock)
        self.__export_action.triggered.connect(self.show_export_dialog)
        self.__workflow_wizard_action.triggered.connect(
            self.show_workflow_wizard_dialog)
        self.__help_action.triggered.connect(self.show_help_documentation)
        self.__about_action.triggered.connect(self.show_about_dialog)

        self.iface.addPluginToDatabaseMenu(self.tr("Model Baker"),
                                           self.__workflow_wizard_action)
        self.iface.addPluginToDatabaseMenu(self.tr("Model Baker"),
                                           self.__generate_action)
        self.iface.addPluginToDatabaseMenu(self.tr("Model Baker"),
                                           self.__importdata_action)
        self.iface.addPluginToDatabaseMenu(self.tr("Model Baker"),
                                           self.__export_action)
        self.iface.addPluginToDatabaseMenu(self.tr("Model Baker"),
                                           self.__datasetmanager_action)
        self.iface.addPluginToDatabaseMenu(self.tr("Model Baker"),
                                           self.__validate_action)
        self.iface.addPluginToDatabaseMenu(self.tr("Model Baker"),
                                           self.__configure_action)
        self.iface.addPluginToDatabaseMenu(self.tr("Model Baker"),
                                           self.__separator)
        self.iface.addPluginToDatabaseMenu(self.tr("Model Baker"),
                                           self.__help_action)
        self.iface.addPluginToDatabaseMenu(self.tr("Model Baker"),
                                           self.__about_action)

        self.toolbar = self.iface.addToolBar(self.tr("Model Baker"))
        self.toolbar.setObjectName("ModelBakerToolbar")
        self.toolbar.setToolTip(self.tr("Model Baker Toolbar"))
        self.toolbar.addAction(self.__workflow_wizard_action)
        self.toolbar.addAction(self.__generate_action)
        self.toolbar.addAction(self.__importdata_action)
        self.toolbar.addAction(self.__export_action)
        self.__dataset_selector = DatasetSelector()
        self.__dataset_selector_action = self.toolbar.addWidget(
            self.__dataset_selector)
        # connect trigger to refresh model of dataset combobox when layer changed
        self.iface.layerTreeView().currentLayerChanged.connect(
            self.__dataset_selector.set_current_layer)
        self.toolbar.addAction(self.__datasetmanager_action)
        self.init_validate_dock()
        self.register_event_filter()
def installPlugin():
    import pyplugin_installer

    pyplugin_installer.instance().fetchAvailablePlugins(False)
    pyplugin_installer.instance().installPlugin("area_weighted_average")
def updatePluginManager():
    installer = pyplugin_installer.instance()
    plugins.getAllInstalled(testLoad=True)
    plugins.rebuild()
    installer.exportPluginsToManager()