def decorated_function(*args, **kwargs): inst = args[0] # Check if QGIS Model Baker is installed and active, disable access if not plugin_version_right = is_plugin_version_valid(QGIS_MODEL_BAKER_PLUGIN_NAME, QGIS_MODEL_BAKER_MIN_REQUIRED_VERSION, QGIS_MODEL_BAKER_EXACT_REQUIRED_VERSION) if plugin_version_right: func_to_decorate(*args, **kwargs) else: if QGIS_MODEL_BAKER_REQUIRED_VERSION_URL: # If we depend on a specific version of QGIS Model Baker (only on that one) # and it is not the latest version, show a download link msg = QCoreApplication.translate("AsistenteLADMCOLPlugin", "The plugin 'QGIS Model Baker' version {} is required, but couldn't be found. Download it <a href=\"{}\">from this link</a> and use 'Install from ZIP' in the Plugin Manager.").format( QGIS_MODEL_BAKER_MIN_REQUIRED_VERSION, QGIS_MODEL_BAKER_REQUIRED_VERSION_URL) else: msg = QCoreApplication.translate("AsistenteLADMCOLPlugin", "The plugin 'QGIS Model Baker' version {} {}is required, but couldn't be found. Click the button to show the Plugin Manager.").format( QGIS_MODEL_BAKER_MIN_REQUIRED_VERSION, '' if QGIS_MODEL_BAKER_EXACT_REQUIRED_VERSION else '(or higher) ') widget = inst.iface.messageBar().createMessage("Asistente LADM_COL", msg) button = QPushButton(widget) button.setText(QCoreApplication.translate("AsistenteLADMCOLPlugin", "Plugin Manager")) button.pressed.connect(inst.show_plugin_manager) widget.layout().addWidget(button) inst.iface.messageBar().pushWidget(widget, Qgis.Warning, 15) inst.logger.warning(__name__, QCoreApplication.translate("AsistenteLADMCOLPlugin", "A dialog/tool couldn't be opened/executed, QGIS Model Baker not found."))
def test_01_dependencies(self): global asistente_ladm_col unload_qgis_model_baker() valid = is_plugin_version_valid( QGIS_MODEL_BAKER_PLUGIN_NAME, QGIS_MODEL_BAKER_MIN_REQUIRED_VERSION, QGIS_MODEL_BAKER_EXACT_REQUIRED_VERSION) self.assertFalse(valid) import_qgis_model_baker() valid = is_plugin_version_valid( QGIS_MODEL_BAKER_PLUGIN_NAME, QGIS_MODEL_BAKER_MIN_REQUIRED_VERSION, QGIS_MODEL_BAKER_EXACT_REQUIRED_VERSION) self.assertTrue(valid)
def check_if_dependency_is_valid(self): return is_plugin_version_valid(self.plugin_name, self.plugin_min_required_version, self.plugin_exact_required_version)