From db04635b84ba5b639186de6b9dc5eba3f51d7093 Mon Sep 17 00:00:00 2001 From: Tom LAVEILLE Date: Fri, 20 Mar 2026 14:27:48 +0100 Subject: [PATCH 1/4] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20ver?= =?UTF-8?q?s=20"gn=5Ftools"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gn_tools/metadata.txt | 6 +++--- gn_tools/plugin_main.py | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) mode change 100755 => 100644 gn_tools/plugin_main.py diff --git a/gn_tools/metadata.txt b/gn_tools/metadata.txt index 04c8a98..984f310 100644 --- a/gn_tools/metadata.txt +++ b/gn_tools/metadata.txt @@ -19,16 +19,16 @@ deprecated=False experimental=True plugin_dependencies= qgisMinimumVersion=3.30 -qgisMaximumVersion=3.99 +qgisMaximumVersion=4.99 supportsQt6=True # versioning -version=0.1.0 +version=0.1.1 changelog= [service] -domain_name=https://geonature.cen-isere.fr/geonature +domain_name=https://geonature.cenra-outils.org/geonature biodiv_aura=https://donnees.biodiversite-auvergne-rhone-alpes.fr [ref_taxon] diff --git a/gn_tools/plugin_main.py b/gn_tools/plugin_main.py old mode 100755 new mode 100644 index 6b49ee2..17a7ba5 --- a/gn_tools/plugin_main.py +++ b/gn_tools/plugin_main.py @@ -24,7 +24,7 @@ from qgis.PyQt.QtCore import QCoreApplication, QLocale, QTranslator, QUrl from qgis.PyQt.QtGui import QDesktopServices, QIcon from qgis.PyQt.QtWidgets import QAction, QMessageBox from qgis.PyQt.QtNetwork import QNetworkAccessManager -from PyQt5.QtWidgets import QCheckBox, QApplication +from qgis.PyQt.QtWidgets import QCheckBox, QApplication # project from gn_tools.__about__ import ( @@ -388,12 +388,13 @@ class GnToolsPlugin: self.dlg.show() # Run the dialog event loop - result = self.dlg.exec_() + result = self.dlg.exec() if result: # Do something useful here - delete the line containing pass and # substitute with you print('ok') print(result) + self.dlg.activateWindow() pass @@ -469,7 +470,7 @@ class GnToolsPlugin: def activate_window(self): # Put the dialog on top once the rectangle is drawn - # self.activateWindow() + self.dlg.activateWindow() self.canvas.unsetMapTool(self.move_tool) self.check_valid() From e5b3e2fedd2203df0076df8249330a5c6b6d4482 Mon Sep 17 00:00:00 2001 From: Tom LAVEILLE Date: Fri, 20 Mar 2026 14:28:15 +0100 Subject: [PATCH 2/4] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20ver?= =?UTF-8?q?s=20"gn=5Ftools/processing"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gn_tools/processing/gbif.py | 16 ++++++++-------- gn_tools/processing/login.py | 16 ++++++++-------- gn_tools/processing/status.py | 18 +++++++++--------- gn_tools/processing/widget.py | 28 ++++++++++++++-------------- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/gn_tools/processing/gbif.py b/gn_tools/processing/gbif.py index 1bae9ef..596566c 100644 --- a/gn_tools/processing/gbif.py +++ b/gn_tools/processing/gbif.py @@ -2,10 +2,10 @@ import json import time # Import PyQt libs -from PyQt5.QtCore import QObject, pyqtSignal, QUrl, Qt, QVariant -from PyQt5.QtGui import QColor -from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply -from PyQt5.QtWidgets import QDialog, QPushButton, QApplication, QVBoxLayout, QHBoxLayout, QButtonGroup, QCheckBox, QLabel +from qgis.PyQt.QtCore import QObject, pyqtSignal, QUrl, Qt, QVariant +from qgis.PyQt.QtGui import QColor +from qgis.PyQt.QtNetwork import QNetworkRequest, QNetworkReply +from qgis.PyQt.QtWidgets import QDialog, QPushButton, QApplication, QVBoxLayout, QHBoxLayout, QButtonGroup, QCheckBox, QLabel # Import PyQgis libs from qgis.utils import iface from qgis.core import QgsProject, QgsFeature, QgsDataSourceUri, QgsRectangle, QgsNetworkAccessManager, QgsVectorLayer, QgsPointXY, QgsWkbTypes, QgsMapLayerProxyModel, QgsGeometry, QgsCoordinateReferenceSystem, QgsCoordinateTransform, QgsField @@ -60,7 +60,7 @@ class GetTaxrefId(QObject): url = "https://api.checklistbank.org/nameusage/search?content=SCIENTIFIC_NAME&datasetKey=2008&facet=datasetKey&facet=rank&facet=issue&facet=status&facet=nomStatus&facet=nameType&facet=field&facet=authorship&facet=authorshipYear&facet=extinct&facet=environment&facet=origin&limit=50&offset=0&q={nom}&rank={rank}&type=PREFIX".format(nom=nom.split("(")[0], rank=rank.lower()) print(url) request = QNetworkRequest(QUrl(url)) - request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") + request.setHeader(QNetworkRequest.KnownHeaders(0), "application/json") reply = self.network_manager.get(request) reply.finished.connect(lambda: self.handle_finished(reply, feature_id)) self._iterate_names += 1 @@ -68,7 +68,7 @@ class GetTaxrefId(QObject): def handle_finished(self, reply, feature_id): self._pending_downloads -= 1 - if reply.error() != QNetworkReply.NoError: + if reply.error() != QNetworkReply.NetworkError(0): print(f"code: {reply.error()} message: {reply.errorString()}") if reply.error() == 403: print("Service down") @@ -146,14 +146,14 @@ class ImportDataGbif(QObject): self.nb_request = 1 print(url) request = QNetworkRequest(url) - request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") + request.setHeader(QNetworkRequest.KnownHeaders(0), "application/json") reply = self.network_manager.get(request) reply.finished.connect(lambda: self.handle_finished(reply)) self._pending_downloads += 1 def handle_finished(self, reply): self._pending_downloads -= 1 - if reply.error() != QNetworkReply.NoError: + if reply.error() != QNetworkReply.NetworkError(0): print(f"code: {reply.error()} message: {reply.errorString()}") if reply.error() == 403: print("Service down") diff --git a/gn_tools/processing/login.py b/gn_tools/processing/login.py index 338dc98..da1680e 100644 --- a/gn_tools/processing/login.py +++ b/gn_tools/processing/login.py @@ -8,8 +8,8 @@ from qgis.PyQt.QtCore import QByteArray, QJsonDocument, QObject, QUrl, pyqtSigna from qgis.PyQt.QtNetwork import QNetworkReply, QNetworkRequest from qgis.PyQt.QtWidgets import QAction, QMessageBox, QDialog -from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QApplication +from qgis.PyQt.QtCore import Qt +from qgis.PyQt.QtWidgets import QApplication # from PyQt6.QtCore import Qt # from PyQt6.QtWidgets import QApplication @@ -42,7 +42,7 @@ class GetLogin(QDialog): # self.total_zh = 0 # PyQt5 - Version - QApplication.setOverrideCursor(Qt.WaitCursor) + QApplication.setOverrideCursor(Qt.CursorShape(3)) # PyQt6 - Version # QApplication.setOverrideCursor(Qt.CursorShape.WaitCursor) self._pending_downloads = 0 @@ -57,14 +57,14 @@ class GetLogin(QDialog): QApplication.restoreOverrideCursor() # If reply is an error or reply is a redirection, login is not accepted print(reply.attribute( - QNetworkRequest.HttpStatusCodeAttribute + QNetworkRequest.Attribute(0) )) print('Login : ',reply.error()) self.network_manager.cookieStatus = reply.attribute( - QNetworkRequest.HttpStatusCodeAttribute + QNetworkRequest.Attribute(0) ) if ( - reply.error() != QNetworkReply.NoError + reply.error() != QNetworkReply.NetworkError(0) or self.network_manager.cookieStatus != 200 ): # Error code 299 means the logins are invalid @@ -98,7 +98,7 @@ class GetLogin(QDialog): else: self.cookies = self.network_manager.cookieJar() self.is_connect.setText("Good Job !") - + QApplication.setOverrideCursor(Qt.CursorShape(0)) # If the authenfication configuration already exists, # modify it with the new values # self.manager_config.setConfigMap( @@ -156,7 +156,7 @@ class GetLogin(QDialog): } print(url) request = QNetworkRequest(url) - request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") + request.setHeader(QNetworkRequest.KnownHeaders(0), "application/json") document = QJsonDocument(data_json) print(document.toJson()) reply = self.network_manager.post(request, document.toJson()) diff --git a/gn_tools/processing/status.py b/gn_tools/processing/status.py index ec6668a..f6f8d4c 100644 --- a/gn_tools/processing/status.py +++ b/gn_tools/processing/status.py @@ -15,7 +15,7 @@ from qgis.PyQt.QtCore import ( pyqtSignal, QJsonDocument, Qt, - QTextCodec + # QTextCodec ) from qgis.PyQt.QtNetwork import QNetworkReply, QNetworkRequest from qgis.PyQt.QtWidgets import ( @@ -294,7 +294,7 @@ class PivotStatus(QDialog): self.cd_nom = cd_nom self.url_api = self.domain_url + __api_cd_sta__ - # QApplication.setOverrideCursor(Qt.WaitCursor) + # QApplication.setOverrideCursor(Qt.CursorShape(3)) self.multi_dep = True self.cookie = (self.network_manager.cookieJar() @@ -325,17 +325,17 @@ class PivotStatus(QDialog): + ','.join(map(str,cd_nom)) ) request = QNetworkRequest(url) - request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") - request.setHeader(QNetworkRequest.CookieHeader, self.cookie) + request.setHeader(QNetworkRequest.KnownHeaders(0), "application/json") + request.setHeader(QNetworkRequest.KnownHeaders(4), self.cookie) reply = self.network_manager.get(request) reply.finished.connect(lambda: self.import_finished(reply)) def import_finished(self, reply): self._pending_downloads -= 1 - print(reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)) + print(reply.attribute(QNetworkRequest.Attribute(0))) - if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200: + if reply.attribute(QNetworkRequest.Attribute(0)) != 200: print(f"code: {reply.error()} message: {reply.errorString()}") else: data_request = reply.readAll().data().decode() @@ -449,9 +449,9 @@ class PivotStatus(QDialog): layername = data['layer_name'] fcString = json.dumps(data) - codec = QTextCodec.codecForName("UTF-8") - fields = QgsJsonUtils.stringToFields(fcString, codec) - feats = QgsJsonUtils.stringToFeatureList(fcString, fields, codec) + # codec = QTextCodec.codecForName("UTF-8") + fields = QgsJsonUtils.stringToFields(fcString) + feats = QgsJsonUtils.stringToFeatureList(fcString, fields) vl = QgsVectorLayer(geom_type, layername, "memory") if vl.sourceCrs() != self.layer_crs: diff --git a/gn_tools/processing/widget.py b/gn_tools/processing/widget.py index 4983494..146deb2 100644 --- a/gn_tools/processing/widget.py +++ b/gn_tools/processing/widget.py @@ -17,7 +17,7 @@ from qgis.PyQt.QtCore import ( QObject, QUrl, pyqtSignal, - QTextCodec, + # QTextCodec, Qt ) from qgis.PyQt.QtNetwork import QNetworkReply, QNetworkRequest @@ -68,7 +68,8 @@ class ParamWidget(QDialog): self.print_change ) else : - QApplication.setOverrideCursor(Qt.WaitCursor) + QApplication.setOverrideCursor(Qt.CursorShape(3)) + print(network_manager.cookieJar().cookiesForUrl(QUrl(self.domain_url))) self.cookie = (network_manager.cookieJar() .cookiesForUrl(QUrl(self.domain_url))[0] ) @@ -104,9 +105,9 @@ class ParamWidget(QDialog): def import_finished(self, reply): self._pending_downloads -= 1 QApplication.restoreOverrideCursor() - print(reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)) + print(reply.attribute(QNetworkRequest.Attribute(0))) - if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200: + if reply.attribute(QNetworkRequest.Attribute(0)) != 200: print(f"code: {reply.error()} message: {reply.errorString()}") else: self.lst_exp = ['Synthèse taxons'] @@ -146,8 +147,8 @@ class ParamWidget(QDialog): # Define request properties (cookie, header) request = QNetworkRequest(url) - request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") - request.setHeader(QNetworkRequest.CookieHeader, self.cookie) + request.setHeader(QNetworkRequest.KnownHeaders(0), "application/json") + request.setHeader(QNetworkRequest.KnownHeaders(4), self.cookie) if apiFilter: doc = QJsonDocument(self.json_filter) @@ -194,7 +195,7 @@ class LoadingImport(QDialog): # self.json_filter = {} # self.total_zh = 0 - QApplication.setOverrideCursor(Qt.WaitCursor) + QApplication.setOverrideCursor(Qt.CursorShape(3)) self._pending_downloads = 0 self.run() @@ -283,10 +284,10 @@ class LoadingImport(QDialog): # Define request properties (cookie, header) request = QNetworkRequest(url) - request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") + request.setHeader(QNetworkRequest.KnownHeaders(0), "application/json") if self.cookie: - request.setHeader(QNetworkRequest.CookieHeader, self.cookie) + request.setHeader(QNetworkRequest.KnownHeaders(4), self.cookie) if 'Synthèse taxons' in self.source : reply = self.network_manager.post(request,doc.toJson()) @@ -297,9 +298,9 @@ class LoadingImport(QDialog): def loading_finished(self,reply): self._pending_downloads -= 1 - print(reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)) + print(reply.attribute(QNetworkRequest.Attribute(0))) - if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200: + if reply.attribute(QNetworkRequest.Attribute(0)) != 200: print(f"code: {reply.error()} message: {reply.errorString()}") else: data_request = reply.readAll().data().decode() @@ -399,9 +400,8 @@ class LoadingImport(QDialog): fcString = json.dumps(data) - codec = QTextCodec.codecForName("UTF-8") - fields = QgsJsonUtils.stringToFields(fcString, codec) - feats = QgsJsonUtils.stringToFeatureList(fcString, fields, codec) + fields = QgsJsonUtils.stringToFields(fcString) + feats = QgsJsonUtils.stringToFeatureList(fcString, fields) if self.api: crs_api = QgsCoordinateReferenceSystem(self.api['geometry_srid']) From 9b5f452f02fa4b6f60e459f43d38e76d8622d8b0 Mon Sep 17 00:00:00 2001 From: Tom LAVEILLE Date: Fri, 20 Mar 2026 14:28:28 +0100 Subject: [PATCH 3/4] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20ver?= =?UTF-8?q?s=20"gn=5Ftools/processing"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gn_tools/processing/draw.py | 8 ++++---- gn_tools/processing/filter_synthese.py | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gn_tools/processing/draw.py b/gn_tools/processing/draw.py index f2aa469..8456364 100644 --- a/gn_tools/processing/draw.py +++ b/gn_tools/processing/draw.py @@ -1,9 +1,9 @@ # Import PyQt libs -from PyQt5.QtCore import ( +from qgis.PyQt.QtCore import ( pyqtSignal, Qt, ) -from PyQt5.QtGui import QColor +from qgis.PyQt.QtGui import QColor # Import PyQgis libs from qgis.core import ( QgsRectangle, @@ -42,7 +42,7 @@ class RectangleFeatureTool(QgsMapTool): # Mouse button pressed. def canvasPressEvent(self, event: QgsMapMouseEvent): - if event.button() == Qt.LeftButton: + if event.button() == Qt.MouseButton(0x00000001): self.start_point = self.toMapCoordinates(event.pos()) self.end_point = self.start_point self.is_left_button_pressed = True @@ -58,7 +58,7 @@ class RectangleFeatureTool(QgsMapTool): # The mouse button is released. def canvasReleaseEvent(self, event: QgsMapMouseEvent): # if the left mouse button was released - if event.button() == Qt.LeftButton: + if event.button() == Qt.MouseButton(0x00000001): if event.type() == 3: # get the rectangle created from the click point and # left mouse button release points diff --git a/gn_tools/processing/filter_synthese.py b/gn_tools/processing/filter_synthese.py index 341dbb6..a3e3c6a 100644 --- a/gn_tools/processing/filter_synthese.py +++ b/gn_tools/processing/filter_synthese.py @@ -77,15 +77,15 @@ class GetFilterFromAPI(QDialog): self._pending_downloads -= 1 # If reply is an error or reply is a redirection, login is not accepted print(reply.attribute( - QNetworkRequest.HttpStatusCodeAttribute + QNetworkRequest.Attribute(0) )) print(reply.error(),' : ',reply.dtype) self.network_manager.cookieStatus = reply.attribute( - QNetworkRequest.HttpStatusCodeAttribute + QNetworkRequest.Attribute(0) ) QApplication.restoreOverrideCursor() if ( - reply.error() != QNetworkReply.NoError + reply.error() != QNetworkReply.NetworkError(0) or self.network_manager.cookieStatus != 200 ): # Error code 299 means the logins are invalid @@ -126,7 +126,7 @@ class GetFilterFromAPI(QDialog): def get_jdd(self): self._pending_downloads += 1 - QApplication.setOverrideCursor(Qt.WaitCursor) + QApplication.setOverrideCursor(Qt.CursorShape(3)) self.dlg.jdd_box.setEnabled(True) url_api = self.domain_url + 'api/meta/datasets?' @@ -142,7 +142,7 @@ class GetFilterFromAPI(QDialog): def get_phylog(self): self._pending_downloads += 2 - QApplication.setOverrideCursor(Qt.WaitCursor) + QApplication.setOverrideCursor(Qt.CursorShape(3)) self.dlg.regne.setEnabled(True) if self.parent.src_name == 'GéoNature': @@ -154,7 +154,7 @@ class GetFilterFromAPI(QDialog): def get_taxon_tree(self): - QApplication.setOverrideCursor(Qt.WaitCursor) + QApplication.setOverrideCursor(Qt.CursorShape(3)) if self.parent.src_name == 'GéoNature': url_api = self.tax_url + 'api/synthese/taxons_tree' @@ -170,8 +170,8 @@ class GetFilterFromAPI(QDialog): def send_request(self,url,type_request,type_param): print(url) request = QNetworkRequest(url) - request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") - request.setHeader(QNetworkRequest.CookieHeader, self.cookie) + request.setHeader(QNetworkRequest.KnownHeaders(0), "application/json") + request.setHeader(QNetworkRequest.KnownHeaders(4), self.cookie) if type_request == 'GET': reply = self.network_manager.get(request) elif type_request == 'POST': From 1f639006a3c96171c2fc3bed3795f136e2b90e27 Mon Sep 17 00:00:00 2001 From: Tom LAVEILLE Date: Fri, 20 Mar 2026 14:28:55 +0100 Subject: [PATCH 4/4] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20ver?= =?UTF-8?q?s=20"gn=5Ftools/toolbelt"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gn_tools/toolbelt/log_handler.py | 0 gn_tools/toolbelt/preferences.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 gn_tools/toolbelt/log_handler.py mode change 100755 => 100644 gn_tools/toolbelt/preferences.py diff --git a/gn_tools/toolbelt/log_handler.py b/gn_tools/toolbelt/log_handler.py old mode 100755 new mode 100644 diff --git a/gn_tools/toolbelt/preferences.py b/gn_tools/toolbelt/preferences.py old mode 100755 new mode 100644