Compare commits

...
14 Commits
Author SHA1 Message Date
tlaveille 852301a537 bug correctif 2025-04-11 10:26:02 +02:00
tlaveille b3451773be v1.6 2025-04-09 15:42:06 +02:00
tlaveille 72a4a8a7b7 Suite maj TT 2025-04-09 15:36:24 +02:00
tlaveille c809c12c9f Optimisation pour TT 2025-04-09 11:44:05 +02:00
tlaveille bc538524fb releases to latest 2025-04-07 17:30:36 +02:00
tlaveille 23f21a4c39 releases to latest 2025-04-07 17:29:22 +02:00
tlaveille 2b00cf9106 debug 2025-04-07 16:06:33 +02:00
tlaveille ad49b80b5a Actualiser README.md 2025-04-03 15:24:23 +02:00
tlaveille dbe918cfcf Mise à jour de sécurité 2025-04-03 12:45:32 +02:00
tlaveille f692414698 MAJ 2025-04-02 10:27:18 +02:00
tlaveille 75ec1c0191 Security MAJ 2025-04-02 10:24:29 +02:00
tlaveille ca79b96958 MAJ 2025-04-02 10:23:08 +02:00
tlaveille ce85b09e11 Security MAJ 2025-04-02 10:20:48 +02:00
tlaveille 8e84d39165 Sécurity MAJ 2025-04-02 10:17:53 +02:00
45 changed files with 1115 additions and 976 deletions
+2
View File
@@ -17,3 +17,5 @@
#ReIgnore #ReIgnore
**/__pycache__ **/__pycache__
**/test/ **/test/
PythonSQL.py
StyleLayer.py
+3
View File
@@ -27,8 +27,11 @@ import os
from .tools.resources import ( from .tools.resources import (
plugin_path, plugin_path,
resources_path, resources_path,
pyperclip,
maj_verif, maj_verif,
) )
pyperclip()
from .canvas_editor import AutoMap_Editor from .canvas_editor import AutoMap_Editor
from .style_invoke import AutoMap_Style from .style_invoke import AutoMap_Style
from .about_form import AboutDialog from .about_form import AboutDialog
+1 -2
View File
@@ -67,7 +67,6 @@ import glob
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base,
send_issues, send_issues,
) )
from .issues import CenRa_Issues from .issues import CenRa_Issues
@@ -762,7 +761,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.QMBquestion = QMessageBox() self.QMBquestion = QMessageBox()
self.QMBquestion.setWindowTitle(u"Attention !") self.QMBquestion.setWindowTitle(u"Attention !")
self.QMBquestion.setIcon(QMessageBox.Warning) self.QMBquestion.setIcon(QMessageBox.Warning)
self.QMBquestion.setText("Mise en page existente, la mise en page vas être écraser !") self.QMBquestion.setText("Mise en page existante, la mise en page va être écrasée !")
self.QMBquestion.setStandardButtons(QMessageBox.Yes|QMessageBox.No) self.QMBquestion.setStandardButtons(QMessageBox.Yes|QMessageBox.No)
self.QMBquestion.addButton(QPushButton('Autre mise en page'),QMessageBox.AcceptRole) self.QMBquestion.addButton(QPushButton('Autre mise en page'),QMessageBox.AcceptRole)
self.QMBquestion = self.QMBquestion.exec() self.QMBquestion = self.QMBquestion.exec()
+2 -2
View File
@@ -6,7 +6,7 @@
name=CenRa_AutoMap name=CenRa_AutoMap
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
description=CenRa_AutoMap description=CenRa_AutoMap
version=1.3 version=1.6
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@@ -21,7 +21,7 @@ tracker=https://gitea.cenra-outils.org/api/v1/repos/CEN-RA/Plugin_QGIS/issues
hasProcessingProvider=no hasProcessingProvider=no
# Uncomment the following line and add your changelog: # Uncomment the following line and add your changelog:
changelog=<h2>CenRa_AutoMap:</h2></br><p><h3>20/03/2025 - Version 1.3: </h3> - Fenêtre redimensionnable avec déplaçable avec la mollette sourit.</p></br><p><h3>25/02/2025 - Version 1.2: </h3> - DockWidget pour ouverture de couche avec theme.</p></br><p><h3>28/01/2025 - Version 1.1: </h3> - Multi-Composeur pris en charge.</p></br><p><h3>27/01/2025 - Version 1.0: </h3> - Version releases.</br> - Ajoute un message d'avertissement au moment d'écraser la mise en page.</br> - Ajoute prénom et nom dans la réalisation.</br> - Utilisation de Calibri.</p></br><p><h3>13/01/2025 - Version 0.1.10: </h3> - Correctif.</p></br><p><h3>07/01/2025 - Version 0.1.9: </h3> - ByPass du certif ssl ci erreur.</p></br><p><h3>19/12/2024 - Version 0.1.8: </h3> - Nouvelle mise en page.</br> - Incrémentation automatique de nouveau modele de mise en page. </br> - Correctif de bug.</p></br><p><h3>21/10/2024 - Version 0.1.7: </h3> - Epurations du code.</p></br><p><h3>07/10/2024 - Version 0.1.6: </h3> - Option de bibliotheque de logo custome.</p></br><p><h3>03/10/2024 - Version 0.1.5: </h3> - Remonte la fênetre dans la pille.</br> - Gestion du nombre de colonne dans la légend.</br></p></br><p><h3>02/10/2024 - Version 0.1.4: </h3> - Mise en page plein écrant.</br></p></br><p><h3>01/10/2024 - Version 0.1.3: </h3> - Récupération du titre et sous-titre pour mise en page existente.</br> - Integration de bibliotheque de logo.</br> - Integration de gestionaire pour les source de donnée.</br> - Mise en place d'une bar d'echelle adaptative. </br></p></br><p><h3>30/09/2024 - Version 0.1.2: </h3> - Activation du thème. </br> - Ajouter une carte de suivie. </br><p></br><h3>27/09/2024 - Version 0.1.1: </h3> - Ajout d'une liste déroulante pour les sources de données. </br>- Bouton pour ajouter des fonts de carte customisés. </br>- Fonctionnalité de génération d'atlas. </p></br><p><h3>26/09/2024 - Version 0.1.0: </h3> - Lancement du plugin CenRa_AutoMap avec une seul mise en page. </p></br> changelog=<h2>CenRa_AUTOMAP:</h2></br><p><h3>09/04/2025 - Version 1.6: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 1.5: </h3> - Optimisation pour le TT.</p></br><p><h3>03/04/2025 - Version 1.4: </h3> - Mise a jour de securite.</p></br><p><h3>20/03/2025 - Version 1.3: </h3> - Fenêtre redimensionnable avec déplaçable avec la mollette sourit.</p></br><p><h3>25/02/2025 - Version 1.2: </h3> - DockWidget pour ouverture de couche avec theme.</p></br><p><h3>28/01/2025 - Version 1.1: </h3> - Multi-Composeur pris en charge.</p></br><p><h3>27/01/2025 - Version 1.0: </h3> - Version releases.</br> - Ajoute un message d'avertissement au moment d'écraser la mise en page.</br> - Ajoute prénom et nom dans la réalisation.</br> - Utilisation de Calibri.</p></br><p><h3>13/01/2025 - Version 0.1.10: </h3> - Correctif.</p></br><p><h3>07/01/2025 - Version 0.1.9: </h3> - ByPass du certif ssl ci erreur.</p></br><p><h3>19/12/2024 - Version 0.1.8: </h3> - Nouvelle mise en page.</br> - Incrémentation automatique de nouveau modele de mise en page. </br> - Correctif de bug.</p></br><p><h3>21/10/2024 - Version 0.1.7: </h3> - Epurations du code.</p></br><p><h3>07/10/2024 - Version 0.1.6: </h3> - Option de bibliotheque de logo custome.</p></br><p><h3>03/10/2024 - Version 0.1.5: </h3> - Remonte la fênetre dans la pille.</br> - Gestion du nombre de colonne dans la légend.</br></p></br><p><h3>02/10/2024 - Version 0.1.4: </h3> - Mise en page plein écrant.</br></p></br><p><h3>01/10/2024 - Version 0.1.3: </h3> - Récupération du titre et sous-titre pour mise en page existente.</br> - Integration de bibliotheque de logo.</br> - Integration de gestionaire pour les source de donnée.</br> - Mise en place d'une bar d'echelle adaptative. </br></p></br><p><h3>30/09/2024 - Version 0.1.2: </h3> - Activation du thème. </br> - Ajouter une carte de suivie. </br><p></br><h3>27/09/2024 - Version 0.1.1: </h3> - Ajout d'une liste déroulante pour les sources de données. </br>- Bouton pour ajouter des fonts de carte customisés. </br>- Fonctionnalité de génération d'atlas. </p></br><p><h3>26/09/2024 - Version 0.1.0: </h3> - Lancement du plugin CenRa_AutoMap avec une seul mise en page. </p></br>
# Tags are comma separated with spaces allowed # Tags are comma separated with spaces allowed
tags=python tags=python
+6 -2
View File
@@ -66,11 +66,15 @@ from PyQt5 import QtWidgets
from qgis.PyQt.QtXml import QDomDocument from qgis.PyQt.QtXml import QDomDocument
from qgis.utils import iface from qgis.utils import iface
import glob import glob
from .tools.PythonSQL import * try:
Enabled = True
from .tools.StyleLayer import *
except:
Enabled = False
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base,
send_issues, send_issues,
) )
from .issues import CenRa_Issues from .issues import CenRa_Issues
-16
View File
@@ -1,16 +0,0 @@
import sys
import socket
import os
host = "91.134.194.220"
port = "5432"
dbname = "bd_cen"
if sys.platform == 'linux':
os_user = os.environ['USER']
else:
os_user = os.environ['USERNAME']
if os_user == 'STAGE':
os_user='stage'
if os_user == 'Administrateur':
os_user='stage'
Binary file not shown.
+10 -19
View File
@@ -4,6 +4,7 @@ import configparser
import shutil import shutil
import tempfile import tempfile
import base64 import base64
import os
import psycopg2 import psycopg2
import psycopg2.extras import psycopg2.extras
from os.path import abspath, join, pardir, dirname from os.path import abspath, join, pardir, dirname
@@ -107,25 +108,15 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None): def pyperclip():
from CenRa_METABASE.tools.PythonSQL import host,port,dbname,password,os_user dst = dirname(dirname(__file__))+"\\tools\\"
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) if os.access('N:/',os.R_OK):
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/StyleLayer.py'
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") try:
res_ident = first_cur.fetchone() shutil.copy(src, dst)
except:
print('404')
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels): def send_issues(url,titre,body,labels):
import requests import requests
import json import json
@@ -158,7 +149,7 @@ def maj_verif(NAME):
url = qgis.utils.pluginMetadata(NAME,'repository') url = qgis.utils.pluginMetadata(NAME,'repository')
#URL = url+'/raw/branch/main/plugins.xml' #URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version) len_version = len(version)
+7 -1
View File
@@ -12,13 +12,15 @@ import qgis
#include <QSettings> #include <QSettings>
import socket
import os import os
from .tools.resources import ( from .tools.resources import (
plugin_path, plugin_path,
pyperclip,
resources_path, resources_path,
maj_verif, maj_verif,
) )
pyperclip()
from .copie_editor import Copie_Editor from .copie_editor import Copie_Editor
from .about_form import AboutDialog from .about_form import AboutDialog
@@ -66,6 +68,10 @@ class PgCopie:
self.copie_editor = QAction(icon, 'Copie',None) self.copie_editor = QAction(icon, 'Copie',None)
self.toolBar.addAction(self.copie_editor) self.toolBar.addAction(self.copie_editor)
self.copie_editor.triggered.connect(self.open_editor) self.copie_editor.triggered.connect(self.open_editor)
self.copie_editor.setEnabled(False)
IPAddr=socket.gethostbyname(socket.gethostname())
if os.access('N:/',os.R_OK):
self.copie_editor.setEnabled(True)
def open_about_dialog(self): def open_about_dialog(self):
""" """
+28 -23
View File
@@ -14,12 +14,16 @@ from PyQt5.QtGui import *
from PyQt5 import QtGui from PyQt5 import QtGui
from qgis.core import * from qgis.core import *
from qgis.core import QgsDataSourceUri from qgis.core import QgsDataSourceUri
import os
from .tools.PythonSQL import * try:
from .tools.PythonSQL import login_base
except:
print('Pas de fichier PythonSQL')
from .tools.SQLRequet import *
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base,
send_issues, send_issues,
) )
from .issues import CenRa_Issues from .issues import CenRa_Issues
@@ -62,21 +66,22 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
# tablename # tablename
source_tablename = [s for s in list_sources if "table" in s][0].split('"')[3] source_tablename = [s for s in list_sources if "table" in s][0].split('"')[3]
account = login_base("account")
sigdb = account[5]
if source_db != sigdb: if source_db != sigdb:
#self.iface.messageBar().pushMessage(u"Un référentiel ne peut être copié, utilisez les filtres !", level=QgsMessageBar.CRITICAL, duration=10) #self.iface.messageBar().pushMessage(u"Un référentiel ne peut être copié, utilisez les filtres !", level=QgsMessageBar.CRITICAL, duration=10)
self.iface.messageBar().pushMessage("Ooops", u"Vous ne pouvez copier des couches que dans sigXX", level=Qgis.Critical, duration=5) self.iface.messageBar().pushMessage("Ooops", u"Vous ne pouvez copier des couches que dans sigXX", level=Qgis.Critical, duration=5)
else:
else : user = account[0]
mdp = account[1]
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) host = account[2]
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) port = account[3]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") dbname = account[4]
res_ident = first_cur.fetchone() cur = account[7]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') con = account[8]
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
# Creation de la liste des schemas de la base de donnees # Creation de la liste des schemas de la base de donnees
SQL = """WITH list_schema AS ( SQL = """WITH list_schema AS (
@@ -115,15 +120,15 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
#******************************debut script********************************* #******************************debut script*********************************
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) cur = account[7]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor) con = account[8]
first_conn.close()
# Récupération de la couche active # Récupération de la couche active
layer = self.iface.activeLayer() layer = self.iface.activeLayer()
+2 -2
View File
@@ -10,7 +10,7 @@
name=CenRA_COPIE name=CenRA_COPIE
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
description=Permet la copie d'une table dans une base PostGis description=Permet la copie d'une table dans une base PostGis
version=2.1 version=2.4
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@@ -19,7 +19,7 @@ email=si_besoin@cen-rhonealpes.fr
# Recommended items: # Recommended items:
# Uncomment the following line and add your changelog: # Uncomment the following line and add your changelog:
changelog=<h2>CenRa_COPIE:</h2></br><p><h3>07/01/2025 - Version 2.1: </h3> - ByPass du certif ssl ci erreur.</br></p><p><h3>22/10/2024 - Version 2:</h3>- Refonte du code.</p></br><p><h3>13/09/2024 - Version 1.5:</h3>- Ajoute d'un changelog et vérification de mise à jour.</p> changelog=<h2>CenRa_COPIE:</h2></br><p><h3>09/04/2025 - Version 2.4: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 2.3: </h3> - Optimisation pour le TT.</p></br><p><h3>03/04/2025 - Version 2.2: </h3> - Mise a jour de securite.</p></br><p><h3>07/01/2025 - Version 2.1: </h3> - ByPass du certif ssl ci erreur.</br></p><p><h3>22/10/2024 - Version 2:</h3>- Refonte du code.</p></br><p><h3>13/09/2024 - Version 1.5:</h3>- Ajoute d'un changelog et vérification de mise à jour.</p>
# Tags are comma separated with spaces allowed # Tags are comma separated with spaces allowed
tags=cenra, database, table tags=cenra, database, table
@@ -1,34 +1,3 @@
import sys
import socket
import os
IPAddr=socket.gethostbyname(socket.gethostname())
if IPAddr[0:11] == "100.100.100": #4269
host = "100.100.100.11"
port = "5432"
dbname = "sig4269"
sigdb="sig4269"
refdb="ref_geo4269"
password = "McVities"
if IPAddr[0:9] == "192.168.0": #01
host = "192.168.0.201"
port = "5432"
dbname = "sig01"
sigdb="sig01"
refdb="ref_geo01"
password = "McVities"
if IPAddr[0:9] == "192.168.1": #0726
host = "192.168.1.201"
port = "5432"
dbname = "sig0726"
sigdb="sig0726"
refdb="ref_geo0726"
password = "McVities"
if sys.platform == 'linux':
os_user = os.environ['USER']
else:
os_user = os.environ['USERNAME']
if os_user == 'STAGE':
os_user='stage'
geom = "geom" geom = "geom"
champ_travaux_prevus_multipolygon="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))""" champ_travaux_prevus_multipolygon="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))"""
+11 -19
View File
@@ -6,6 +6,7 @@ import tempfile
import base64 import base64
import psycopg2 import psycopg2
import psycopg2.extras import psycopg2.extras
import os
from os.path import abspath, join, pardir, dirname from os.path import abspath, join, pardir, dirname
from qgis.PyQt import uic from qgis.PyQt import uic
@@ -89,7 +90,7 @@ def resources_path(*args):
:return: Absolute path to the resources folder. :return: Absolute path to the resources folder.
:rtype: str :rtype: str
""" """
path = abspath(abspath(join(plugin_path(), "CenRa_Copie\\tools"))) path = abspath(abspath(join(plugin_path(), "CenRa_COPIE\\tools")))
for item in args: for item in args:
path = abspath(join(path, item)) path = abspath(join(path, item))
return path return path
@@ -107,24 +108,15 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None): def pyperclip():
from CenRa_Metabase.resources.PythonSQL import host,port,dbname,password,os_user dst = dirname(dirname(__file__))+"\\tools\\"
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) if os.access('N:/',os.R_OK):
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") try:
res_ident = first_cur.fetchone() shutil.copy(src, dst)
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') except:
user = res_ident[1] print('404')
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels): def send_issues(url,titre,body,labels):
import requests import requests
import json import json
@@ -157,7 +149,7 @@ def maj_verif(NAME):
url = qgis.utils.pluginMetadata(NAME,'repository') url = qgis.utils.pluginMetadata(NAME,'repository')
#URL = url+'/raw/branch/main/plugins.xml' #URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version) len_version = len(version)
+7 -1
View File
@@ -12,13 +12,15 @@ import qgis
#include <QSettings> #include <QSettings>
import socket
import os import os
from .tools.resources import ( from .tools.resources import (
plugin_path, plugin_path,
pyperclip,
resources_path, resources_path,
maj_verif, maj_verif,
) )
pyperclip()
from .flux_editor import Flux_Editor from .flux_editor import Flux_Editor
from .about_form import AboutDialog from .about_form import AboutDialog
@@ -63,9 +65,13 @@ class PgFlux:
if not self.action_editor: if not self.action_editor:
self.action_editor = Flux_Editor() self.action_editor = Flux_Editor()
self.flux_editor = QAction(icon, 'SigCEN',None) self.flux_editor = QAction(icon, 'SigCEN',None)
self.toolBar.addAction(self.flux_editor) self.toolBar.addAction(self.flux_editor)
self.flux_editor.triggered.connect(self.open_editor) self.flux_editor.triggered.connect(self.open_editor)
self.flux_editor.setEnabled(False)
if os.access('N:/',os.R_OK):
self.flux_editor.setEnabled(True)
def open_about_dialog(self): def open_about_dialog(self):
""" """
+297 -9
View File
@@ -29,15 +29,20 @@ from qgis.PyQt.QtWidgets import (
QMessageBox, QMessageBox,
QVBoxLayout, QVBoxLayout,
) )
from .tools.PythonSQL import * from .tools.SQLRequet import *
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base,
send_issues, send_issues,
) )
try:
from .tools.PythonSQL import login_base
except:
print('Pas de fichier PythonSQL')
from .issues import CenRa_Issues from .issues import CenRa_Issues
from ast import literal_eval
from qgis.utils import iface from qgis.utils import iface
import os.path import os.path
import webbrowser, os import webbrowser, os
@@ -45,17 +50,136 @@ import psycopg2
import psycopg2.extras import psycopg2.extras
import base64 import base64
global DeBUG
DeBUG = 0
try: try:
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base('account')
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
first_conn.close() sigdb = account[5]
refdb = account[6]
except: except:
print('') print('')
EDITOR_CLASS = load_ui('CenRa_Flux_base.ui') EDITOR_CLASS = load_ui('CenRa_Flux_base.ui')
html = '''<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
crossorigin=""></script>
<style>
body { padding: 0; margin: 0; }
html, body, #map { height: 100%; }
.leaflet-control-layers-toggle {
background-image: url(https://intranet.cenra-outils.org/Intranet/css/images/layers.png);
}
.legend_parc {
border-radius: 15px;
box-shadow: 2px 2px 3px 0 #6a6a6a;
background-color: #fefafab3;
opacity:0;
}
.legend_parc:hover{
opacity:1;
}
.popup-with-no-events {
pointer-events: none;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="map.js"></script>
</body>
</html>
<script>'''
font = '''var OrthoIGN = L.tileLayer('https://wmts.geopf.fr/wmts?'+
'&LAYER={ignLayer}&STYLE={style}&TILEMATRIXSET=PM'+
'&SERVICE={service}&REQUEST=GetTile&VERSION=1.0.0'+
'&FORMAT={format}&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}',
{
ignLayer: 'ORTHOIMAGERY.ORTHOPHOTOS',
style: 'normal',
service: 'WMTS',
format: 'image/jpeg',
minZoom: 0,
maxZoom: 19,
attribution: '&copy; IGN'
}).addTo(map);
// Plan IGN avec une transparence de 50%
var PlanIGN = L.tileLayer('https://wmts.geopf.fr/wmts?'+
'&LAYER={ignLayer}&STYLE={style}&TILEMATRIXSET=PM'+
'&SERVICE={service}&REQUEST=GetTile&VERSION=1.0.0'+
'&FORMAT={format}&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}',
{
ignLayer: 'GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2',
style: 'normal',
service: 'WMTS',
format: 'image/png',
minZoom: 0,
maxZoom: 19,
attribution: '&copy; IGN'
});
var baseMaps = {
// "BDORTHO2" : bdortho,
// "Openstreetmap": openStreetMap,
// "Opentopomap": openTopoMap,
"BDORTHO" : OrthoIGN,
"PlanIGN": PlanIGN
};
var overlayMaps = {
"Sites": Sites,
//"Parcelle":JSON
};
L.control.layers(baseMaps,overlayMaps).addTo(map);
var scale = L.control.scale({position: 'bottomleft', metric:true, imperial:false});
scale.addTo(map);
var legend = L.control({position: 'bottomleft'});
legend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'info legend_parc'),
labels = [];
labels.push('<i style="background:#73004c;width:18px;height:18px;float:left;margin-right:8px;opacity: 0.7;"></i> Acquisition')
labels.push('<i style="background:#ff00c5;width:18px;height:18px;float:left;margin-right:8px;opacity: 0.7;"></i> Acquis en partie BND')
labels.push('<i style="background:#f0ade1ab;width:18px;height:18px;float:left;margin-right:8px;opacity: 0.7;"></i> Acquisition pour partie')
labels.push('<i style="background:#73462e;width:18px;height:18px;float:left;margin-right:8px;opacity: 0.7;"></i> Acquisition / Convention')
labels.push('<i style="background:#e69800;width:18px;height:18px;float:left;margin-right:8px;opacity: 0.7;"></i> Convention')
labels.push('<i style="background:#ffd37f;width:18px;height:18px;float:left;margin-right:8px;opacity: 0.7;"></i> Convention en partie BND')
labels.push('<i style="background:#ffebaf;width:18px;height:18px;float:left;margin-right:8px;opacity: 0.7;"></i> Convention pour partie')
labels.push('<i style="background:#c8c8c8;width:18px;height:18px;float:left;margin-right:8px;opacity: 0.7;"></i> Autre')
labels.push('<i style="background:#f9ff08;width:18px;height:18px;float:left;margin-right:8px;opacity: 0.7;"></i> Projet en cours')
labels.push('<i style="background:#fe0000;width:18px;height:18px;float:left;margin-right:8px;opacity: 0.7;"></i> Problème de mise à jour')
labels.push('<i style="background:#000;width:18px;height:18px;float:left;margin-right:8px;opacity: 0.7;"></i> Pas de maitrise')
div.innerHTML = labels.join('<br>');
return div;
};
legend.addTo(map);
</script>'''
targetCrs = QgsCoordinateReferenceSystem('EPSG:4326')
layerCrs = QgsCoordinateReferenceSystem('EPSG:2154')
TranformCRS = QgsCoordinateTransform(layerCrs, targetCrs,QgsProject.instance())
class Flux_Editor(QDialog, EDITOR_CLASS): class Flux_Editor(QDialog, EDITOR_CLASS):
@@ -84,10 +208,20 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
self.commandLinkButton_2.clicked.connect(self.suppression_flux) self.commandLinkButton_2.clicked.connect(self.suppression_flux)
self.tableWidget_2.itemDoubleClicked.connect(self.suppression_flux) self.tableWidget_2.itemDoubleClicked.connect(self.suppression_flux)
self.comboBox_2.currentIndexChanged.connect(self.bd_source) self.comboBox_2.currentIndexChanged.connect(self.bd_source)
self.checkBox.hide()
self.checkBox.stateChanged.connect(self.modeCarte)
self.toolButton.clicked.connect(self.getCanevas) self.toolButton.clicked.connect(self.getCanevas)
layout = QVBoxLayout() layout = QVBoxLayout()
self.lineEdit.textChanged.connect(self.filtre_dynamique) self.lineEdit.textChanged.connect(self.filtre_dynamique)
self.viewer.titleChanged.connect(self.NewTitle)
layout.addWidget(self.lineEdit) layout.addWidget(self.lineEdit)
self.viewer.hide()
self.DeBUG.addItem('')
self.DeBUG.addItem('01')
self.DeBUG.addItem('0726')
self.DeBUG.addItem('4269')
self.DeBUG.hide()
#self.lineEdit.mousePressEvent = self._mousePressEvent #self.lineEdit.mousePressEvent = self._mousePressEvent
#metadonnees_plugin = open(self.plugin_path + '/metadata.txt') #metadonnees_plugin = open(self.plugin_path + '/metadata.txt')
@@ -96,6 +230,141 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
def raise_(self): def raise_(self):
"""Run method that performs all the real work""" """Run method that performs all the real work"""
self.bd_source() self.bd_source()
def ModeDeBUG(self):
self.DeBUG.show()
def mousePressEvent(self, event):
global DeBUG
if 330 <= event.pos().x() <= 560 and 5 <= event.pos().y() <= 75:
DeBUG = DeBUG+1
if DeBUG == 3:
DeBUG = 0
self.ModeDeBUG()
else:
DeBUG = 0
self.DeBUG.hide()
def NewTitle(self):
if self.viewer.title() != '':
Tsplit = ((self.viewer.title()).split('.'))
print(Tsplit[0],Tsplit[1])
self.openPostGIS(Tsplit[0],Tsplit[1])
def modeCarte(self):
if self.checkBox.isChecked():
self.viewer.show()
cur.execute("SELECT ST_AsGeoJSON(st_centroid(ST_Transform(geom,4326))) FROM _agregation_ra._agreg_contour")
varcenter = literal_eval(cur.fetchall()[0][0])
varcenter = [varcenter['coordinates'][1],varcenter['coordinates'][0]]
cur.execute("SELECT ST_AsGeoJSON(ST_Transform(st_collect(geom),4326)),tschema,tname FROM _agregation_ra._agreg_contour WHERE geom IS NOT NULL GROUP BY tschema,tname;" )
varSite = cur.fetchall()
cur.execute("SELECT ST_AsGeoJSON(ST_Transform(st_collect(geom),4326)),tschema,tname FROM _agregation_ra._agreg_travaux_prevus_poly WHERE geom IS NOT NULL GROUP BY tschema,tname;")
varTravaux = cur.fetchall()
cur.execute("SELECT ST_AsGeoJSON(ST_Transform(geom,4326)),milieu_libelle ,lb_eu_01,tschema,tname FROM _agregation_ra._agreg_eu_habitat WHERE geom IS NOT NULL;")
varHabitat = cur.fetchall()
vargeomS = literal_eval(varSite[0][0])
vargeomT = literal_eval(varTravaux[0][0])
vargeomH = literal_eval(varHabitat[0][0])
#new_objectS = self.SwitchGeom(vargeomS)
#new_objectT = self.SwitchGeom(vargeomT)
#new_objectH = self.SwitchGeom(vargeomH)
script = 'var map = L.map("map").setView('+str(varcenter)+', 13);'
id = 0
varSiteJSON = '''var ParcelleJSON = {
"type": "FeatureCollection",
"features":['''
for varP in varSite:
id = id+1
varSiteJSON = varSiteJSON+'{"properties": {"code": "'+str(varP[1])+'.'+str(varP[2])+'" },'+str(varP[0][1:])+','
varSiteJSON = varSiteJSON[:-1]+''']};
var Sites = L.geoJSON(ParcelleJSON,{
style: function(feature) {
switch (feature.geometry.properties.code) {
case 'Ensemble de sites': return {fillColor: "#9a7863",color:"white",weight: 1,fillOpacity: 0.7};
case 'Sous-site conservatoire': return {fillColor: "#e69800",color:"white",weight: 1,fillOpacity: 0.7};
case 'Site non géré': return {fillColor: "#73004c",color:"white",weight: 1,fillOpacity: 0.7};
case 'Animation territoriale': return {fillColor: "#ffebaf",color:"white",weight: 1,fillOpacity: 0.7};
case 'Site conservatoire': return {fillColor: "#f9ff08",color:"white",weight: 1,fillOpacity: 0.7};
default: return {fillColor: "#c8c8c8",color:"white",weight: 1,fillOpacity: 0.7};
}
},
onEachFeature: function (feature,layer) {
layer.on('click', function(e) {
map.fitBounds(layer.getBounds());
document.title = feature.properties.code.toString();
});
layer.on('mouseover', function(e) {
layer.setStyle({
weight: 5,
color: '#fe0000',
dashArray: '',
});
});
//layer.on('mousemove', function(e) {
//layer.openPopup(e.latlng);
//});
layer.on('mouseout', function(e) {
layer.setStyle({
color:"white",
weight: 1,
});
});
layer.bindTooltip(feature.properties.code.toString(), {
sticky: true,
permanent: false,
direction: 'right',
className: 'label_parc'
});
}
}).addTo(map);'''
id = 0
varTravauxJSON = '''var TravauxJSON = {
"type": "FeatureCollection",
"features":['''
for varT in varTravaux:
id = id+1
varTravauxJSON = varTravauxJSON+'{"properties": {"code": "'+str(varT[1])+'.'+str(varT[2])+'" },'+str(varT[0][1:])+','
varTravauxJSON = varTravauxJSON[:-1]+''']};
var Travaux = L.geoJSON(TravauxJSON,{
onEachFeature: function (feature,layer) {
layer.on('click', function(e) {
map.fitBounds(layer.getBounds());
document.title = feature.properties.code.toString();
});
layer.on('mouseover', function(e) {
layer.setStyle({
weight: 5,
color: '#fe0000',
dashArray: '',
});
});
//layer.on('mousemove', function(e) {
//layer.openPopup(e.latlng);
//});
layer.on('mouseout', function(e) {
layer.setStyle({
color:"white",
weight: 1,
});
});
layer.bindTooltip(feature.properties.code.toString(), {
sticky: true,
permanent: false,
direction: 'right',
className: 'label_parc'
});
}
}).addTo(map);'''
script = script+varSiteJSON+varTravauxJSON
self.viewer.setHtml(html+script+font)
else:
self.viewer.hide()
def bd_source(self): def bd_source(self):
self.activateWindow() self.activateWindow()
@@ -223,6 +492,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
self.tableWidget.setColumnWidth(1, 300) self.tableWidget.setColumnWidth(1, 300)
self.tableWidget.setColumnWidth(2, 300) self.tableWidget.setColumnWidth(2, 300)
self.tableWidget.setHorizontalHeaderLabels(["Code","Schema","Table"]) self.tableWidget.setHorizontalHeaderLabels(["Code","Schema","Table"])
def selection_flux(self): def selection_flux(self):
selected_row = 0 selected_row = 0
selected_items = self.tableWidget.selectedItems() selected_items = self.tableWidget.selectedItems()
@@ -268,6 +538,15 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
if self.tableWidget_2.rowCount() <= 5: if self.tableWidget_2.rowCount() <= 5:
self.chargement_flux() self.chargement_flux()
def openPostGIS(self,schema,table):
uri = QgsDataSourceUri()
uri.setConnection(host ,port ,sigdb ,user ,mdp)
uri.setDataSource(schema, table, "geom")
uri.setKeyColumn('gid')
uri.setSrid('2154')
layer = QgsVectorLayer(uri.uri(), table, "postgres")
# Ajout de la couche au canevas QGIS
QgsProject.instance().addMapLayer(layer)
def chargement_flux(self): def chargement_flux(self):
@@ -285,6 +564,7 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
return switcher.get(type, "nothing") return switcher.get(type, "nothing")
def displayOnWindows(type, uri, name): def displayOnWindows(type, uri, name):
p = [] p = []
@@ -427,6 +707,14 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
if self.lineEdit.text() != 'Recherche par mots-clés': if self.lineEdit.text() != 'Recherche par mots-clés':
self.filtre_dynamique(self.lineEdit.text()) self.filtre_dynamique(self.lineEdit.text())
def SwitchGeom(self,vargeom):
new_object = '['
obj = vargeom['coordinates'][0][0]
for obj_X in obj:
new_object = new_object+'['+str(obj_X[1])+','+str(obj_X[0])+'],'
new_object = new_object[:-1]+']'
return(new_object)
def popup(self): def popup(self):
self.dialog = Popup() # +++ - self self.dialog = Popup() # +++ - self
+2 -2
View File
@@ -6,7 +6,7 @@
name=CenRa_FLUX name=CenRa_FLUX
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
description=Permet d'ouvrire une table dans la base PostGis description=Permet d'ouvrire une table dans la base PostGis
version=2.5 version=2.9
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@@ -32,7 +32,7 @@ icon=icon.png
# experimental flag # experimental flag
experimental=False experimental=False
changelog=<h1>CenRA_FLUX:</h1></br><p><h3>20/03/2025 - Version 2.5: </h3> - Visualisation distincte des couches ne se trouvant pas dans l'antenne.</p></br><p><h3>13/02/2025 - Version 2.4: </h3> - Ajoute redimensionnement et déplacement mollette.</p></br><p><h3>05/02/2025 - Version 2.3: </h3> - Bouton de visualisation des couches se trouvent uniquement dans le canva de la carte.</p></br><p><h3>07/01/2025 - Version 2.2: </h3> - ByPass du certif ssl ci erreur.</p></br><p><h3>22/10/2024 - Version 2.1:</h3> - Correctif de bug.</br> - Evolution de la limit de 3 à 5. </br></p></br><p><h3>22/10/2024 - Version 2.0:</h3> - Reformatage du code.</br></p></br><p><h3>03/10/2024 - Version 1.14:</h3> - Remonte la fênetre dans la pille.</br></p><p><h3>13/09/2024 - Version 1.13:</h3>- MAJ sur le lien du changelog</br>- Bug-fix: Ouvre MultiPolygone et Polygon séparément.</p></br><p><h3>10/09/2024 - Version 1.11:</h3>- Ouverture de table contenant plusieurs géométries.</p></br><p><h3>26/08/2024 - Version 1.10:</h3>- Ajoute d'un changelog et vérification de mise à jour.</p> changelog=<h2>CenRa_FLUX:</h2></br><p><h3>09/04/2025 - Version 2.9: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 2.8: </h3> - Optimisation pour le TT.</p></br><p><h3>07/04/2025 - Version 2.7: </h3> - mode debug.</p></br><p><h3>03/04/2025 - Version 2.6: </h3> - Mise a jour de securite.</p></br><p><h3>20/03/2025 - Version 2.5: </h3> - Visualisation distincte des couches ne se trouvant pas dans l'antenne.</p></br><p><h3>13/02/2025 - Version 2.4: </h3> - Ajoute redimensionnement et déplacement mollette.</p></br><p><h3>05/02/2025 - Version 2.3: </h3> - Bouton de visualisation des couches se trouvent uniquement dans le canva de la carte.</p></br><p><h3>07/01/2025 - Version 2.2: </h3> - ByPass du certif ssl ci erreur.</p></br><p><h3>22/10/2024 - Version 2.1:</h3> - Correctif de bug.</br> - Evolution de la limit de 3 à 5. </br></p></br><p><h3>22/10/2024 - Version 2.0:</h3> - Reformatage du code.</br></p></br><p><h3>03/10/2024 - Version 1.14:</h3> - Remonte la fênetre dans la pille.</br></p><p><h3>13/09/2024 - Version 1.13:</h3>- MAJ sur le lien du changelog</br>- Bug-fix: Ouvre MultiPolygone et Polygon séparément.</p></br><p><h3>10/09/2024 - Version 1.11:</h3>- Ouverture de table contenant plusieurs géométries.</p></br><p><h3>26/08/2024 - Version 1.10:</h3>- Ajoute d'un changelog et vérification de mise à jour.</p>
# deprecated flag (applies to the whole plugin, not just a single version) # deprecated flag (applies to the whole plugin, not just a single version)
deprecated=False deprecated=False
@@ -1,37 +1,14 @@
import sys
import socket
import os
IPAddr=socket.gethostbyname(socket.gethostname())
if IPAddr[0:11] == "100.100.100": #4269
host = "100.100.100.11"
port = "5432"
dbname = "sig4269"
sigdb="sig4269"
refdb="ref_geo4269"
password = "McVities"
if IPAddr[0:9] == "192.168.0": #01
host = "192.168.0.201"
port = "5432"
dbname = "sig01"
sigdb="sig01"
refdb="ref_geo01"
password = "McVities"
if IPAddr[0:9] == "192.168.1": #0726
host = "192.168.1.201"
port = "5432"
dbname = "sig0726"
sigdb="sig0726"
refdb="ref_geo0726"
password = "McVities"
if sys.platform == 'linux':
os_user = os.environ['USER']
else:
os_user = os.environ['USERNAME']
if os_user == 'STAGE':
os_user='stage'
if os_user == 'Administrateur':
os_user = 'stage'
schemaname_distinct="""SELECT DISTINCT schemaname from pg_catalog.pg_tables
WHERE schemaname NOT LIKE '_archives' AND schemaname NOT LIKE 'topology' AND schemaname NOT LIKE 'information_schema' AND schemaname NOT LIKE 'pg_catalog' and schemaname NOT LIKE 'public' AND schemaname NOT LIKE '_trier'
order by schemaname;"""
schemaname_list_ref="""SELECT schemaname,tablename from pg_catalog.pg_tables
WHERE schemaname NOT LIKE '_archives' AND schemaname NOT LIKE 'topology' AND schemaname NOT LIKE 'information_schema' AND schemaname NOT LIKE 'pg_catalog' and schemaname NOT LIKE 'public' AND schemaname NOT LIKE '_trier'
order by schemaname,tablename;"""
schemaname_list="""(SELECT schemaname,tablename from pg_catalog.pg_tables
where schemaname like 'trav%' or schemaname like '\_ag%' or schemaname like '\_00%' or schemaname like '\_01%' or schemaname like '\_07%' or schemaname like '\_26%' or schemaname like '\_form%' or schemaname like '\_42%' or schemaname like '\_69%' order by schemaname,tablename)
UNION
(SELECT schemaname,matviewname AS tablename FROM pg_catalog.pg_matviews order by schemaname,tablename) order by schemaname,tablename;"""
geom = "geom" geom = "geom"
champ_travaux_prevus_multipolygon="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))""" champ_travaux_prevus_multipolygon="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))"""
champ_travaux_prevus_multilinestring="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, longueur_m double precision, longueur_km double precision, date_creation date, date_maj date, geom geometry(MultiLineString,2154))""" champ_travaux_prevus_multilinestring="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, longueur_m double precision, longueur_km double precision, date_creation date, date_maj date, geom geometry(MultiLineString,2154))"""
+10 -23
View File
@@ -2,10 +2,8 @@
import configparser import configparser
import shutil import shutil
import os
import tempfile import tempfile
import base64
import psycopg2
import psycopg2.extras
from os.path import abspath, join, pardir, dirname from os.path import abspath, join, pardir, dirname
from qgis.PyQt import uic from qgis.PyQt import uic
@@ -79,6 +77,14 @@ def plugin_test_data_path(*args, copy=False):
else: else:
return path return path
def pyperclip():
dst = dirname(dirname(__file__))+"\\tools\\"
if os.access('N:/',os.R_OK):
src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
try:
shutil.copy(src, dst)
except:
print('404')
def resources_path(*args): def resources_path(*args):
"""Get the path to our resources folder. """Get the path to our resources folder.
@@ -106,25 +112,6 @@ def load_ui(*args):
ui_class, _ = uic.loadUiType(resources_path("ui", *args)) ui_class, _ = uic.loadUiType(resources_path("ui", *args))
return ui_class return ui_class
def login_base(take=None):
from .tools.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels): def send_issues(url,titre,body,labels):
import requests import requests
import json import json
@@ -157,7 +144,7 @@ def maj_verif(NAME):
url = qgis.utils.pluginMetadata(NAME,'repository') url = qgis.utils.pluginMetadata(NAME,'repository')
#URL = url+'/raw/branch/main/plugins.xml' #URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version) len_version = len(version)
+75
View File
@@ -326,11 +326,86 @@
</size> </size>
</property> </property>
</widget> </widget>
<widget class="QWebView" name="viewer" native="true">
<property name="geometry">
<rect>
<x>90</x>
<y>10</y>
<width>730</width>
<height>730</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(255, 255, 255,0.50);</string>
</property>
<property name="url" stdset="0">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
<widget class="QCheckBox" name="checkBox">
<property name="geometry">
<rect>
<x>830</x>
<y>20</y>
<width>70</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="DeBUG">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>71</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="currentText">
<string notr="true"/>
</property>
</widget>
<zorder>viewer</zorder>
<zorder>commandLinkButton_2</zorder>
<zorder>pushButton_2</zorder>
<zorder>label</zorder>
<zorder>tableWidget_2</zorder>
<zorder>comboBox</zorder>
<zorder>lineEdit</zorder>
<zorder>toolButton</zorder>
<zorder>tableWidget</zorder>
<zorder>label_2</zorder>
<zorder>label_3</zorder>
<zorder>comboBox_2</zorder>
<zorder>commandLinkButton</zorder>
<zorder>checkBox</zorder>
<zorder>DeBUG</zorder>
</widget> </widget>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>
+2
View File
@@ -26,9 +26,11 @@ from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger
import os import os
from .tools.resources import ( from .tools.resources import (
plugin_path, plugin_path,
pyperclip,
resources_path, resources_path,
maj_verif, maj_verif,
) )
pyperclip()
from .dock import CenRa_Metabase from .dock import CenRa_Metabase
from .editor import Metabase_Editor from .editor import Metabase_Editor
from .about_form import MetabaseAboutDialog from .about_form import MetabaseAboutDialog
+4 -1
View File
@@ -47,11 +47,14 @@ from pg_metadata.connection_manager import (
settings_connections_names, settings_connections_names,
) )
''' '''
try:
from .tools.PythonSQL import login_base
except:
print('Pas de fichier PythonSQL')
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base,
) )
DOCK_CLASS = load_ui('CenRa_Metabase_dockwidget_base.ui') DOCK_CLASS = load_ui('CenRa_Metabase_dockwidget_base.ui')
+5 -1
View File
@@ -38,10 +38,14 @@ from qgis.PyQt.QtWidgets import (
) )
from qgis.utils import iface from qgis.utils import iface
try:
from .tools.PythonSQL import login_base
except:
print('Pas de fichier PythonSQL')
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base,
send_issues, send_issues,
) )
from .issues import CenRa_Issues from .issues import CenRa_Issues
+2 -2
View File
@@ -6,7 +6,7 @@
name=CenRa_Metabase name=CenRa_Metabase
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
description=CenRa_METABASE description=CenRa_METABASE
version=0.2.0 version=0.2.3
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@@ -21,7 +21,7 @@ tracker=https://gitea.cenra-outils.org/api/v1/repos/CEN-RA/Plugin_QGIS/issues
hasProcessingProvider=no hasProcessingProvider=no
# Uncomment the following line and add your changelog: # Uncomment the following line and add your changelog:
changelog=<h2>CenRa_Metabase:</h2></br><p><h3>07/01/2025 - Version 0.1.6: </h3> - Deployment sur serveur SIG.</p></br><p><h3>07/01/2025 - Version 0.1.6: </h3> - ByPass du certif ssl ci erreur</p></br><p><h3>19/12/2024 - Version 0.1.5: </h3> - Fix les problem de lenteur qu'en la base est down.</p></br><p><h3>12/12/2024 - Version 0.1.4: </h3> - Crash Fix .</p></br><p><h3>08/10/2024 - Version 0.1.3: </h3> - Lecture de métadonnée des flux WMS/WFS.</p></br><p><h3>07/10/2024 - Version 0.1.2: </h3> - Correctif de bug.</p></br><p><h3>03/10/2024 - Version 0.1.1: </h3> - Remonte la fênetre dans la pille.</p></br><p><h3>26/08/2024 - Version 0.1.0: </h3> - Lancement du plugin CenRa_Metabase </p> changelog=<h2>CenRa_METABASE:</h2></br><p><h3>09/04/2025 - Version 0.2.3: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 0.2.2: </h3> - Optimisation pour le TT.</p></br><p><h3>03/04/2025 - Version 0.2.1: </h3> - Mise a jour de securite.</p></br><p><h3>07/01/2025 - Version 0.2.0: </h3> - Deployment sur serveur SIG.</p></br><p><h3>07/01/2025 - Version 0.1.6: </h3> - ByPass du certif ssl ci erreur</p></br><p><h3>19/12/2024 - Version 0.1.5: </h3> - Fix les problem de lenteur qu'en la base est down.</p></br><p><h3>12/12/2024 - Version 0.1.4: </h3> - Crash Fix .</p></br><p><h3>08/10/2024 - Version 0.1.3: </h3> - Lecture de métadonnée des flux WMS/WFS.</p></br><p><h3>07/10/2024 - Version 0.1.2: </h3> - Correctif de bug.</p></br><p><h3>03/10/2024 - Version 0.1.1: </h3> - Remonte la fênetre dans la pille.</p></br><p><h3>26/08/2024 - Version 0.1.0: </h3> - Lancement du plugin CenRa_Metabase </p>
# Tags are comma separated with spaces allowed # Tags are comma separated with spaces allowed
tags=python tags=python
-34
View File
@@ -1,34 +0,0 @@
import sys
import socket
import os
IPAddr=socket.gethostbyname(socket.gethostname())
#print(IPAddr)
if IPAddr[0:11] == "100.100.100": #4269
host = "100.100.100.11"
port = "5432"
dbname = "sig4269"
sigdb="sig4269"
refdb="ref_geo4269"
password = "McVities"
if IPAddr[0:9] == "192.168.0": #01
host = "192.168.0.201"
port = "5432"
dbname = "sig01"
sigdb="sig01"
refdb="ref_geo01"
password = "McVities"
if IPAddr[0:9] == "192.168.1": #0726
host = "192.168.1.201"
port = "5432"
dbname = "sig0726"
sigdb="sig0726"
refdb="ref_geo0726"
password = "McVities"
if sys.platform == 'linux':
os_user = os.environ['USER']
else:
os_user = os.environ['USERNAME']
if os_user == 'STAGE':
os_user='stage'
if os_user == 'Administrateur':
os_user='stage'
Binary file not shown.
+10 -23
View File
@@ -3,9 +3,7 @@
import configparser import configparser
import shutil import shutil
import tempfile import tempfile
import base64 import os
import psycopg2
import psycopg2.extras
from os.path import abspath, join, pardir, dirname from os.path import abspath, join, pardir, dirname
from qgis.PyQt.QtWidgets import QApplication from qgis.PyQt.QtWidgets import QApplication
from qgis.PyQt import uic from qgis.PyQt import uic
@@ -94,6 +92,14 @@ def resources_path(*args):
path = abspath(join(path, item)) path = abspath(join(path, item))
return path return path
def pyperclip():
dst = dirname(dirname(__file__))+"\\tools\\"
if os.access('N:/',os.R_OK):
src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
try:
shutil.copy(src, dst)
except:
print('404')
def load_ui(*args): def load_ui(*args):
"""Get compile UI file. """Get compile UI file.
@@ -107,25 +113,6 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None):
from CenRa_METABASE.tools.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels): def send_issues(url,titre,body,labels):
import requests import requests
import json import json
@@ -158,7 +145,7 @@ def maj_verif(NAME):
url = qgis.utils.pluginMetadata(NAME,'repository') url = qgis.utils.pluginMetadata(NAME,'repository')
#URL = url+'/raw/branch/main/plugins.xml' #URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version) len_version = len(version)
-1
View File
@@ -65,7 +65,6 @@ import glob
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base,
send_issues, send_issues,
) )
from .issues import CenRa_Issues from .issues import CenRa_Issues
+2 -2
View File
@@ -6,7 +6,7 @@
name=CenRa_PageRender name=CenRa_PageRender
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
description=CenRa_PageRender description=CenRa_PageRender
version=0.1.5 version=0.1.6
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@@ -21,7 +21,7 @@ tracker=https://gitea.cenra-outils.org/api/v1/repos/CEN-RA/Plugin_QGIS/issues
hasProcessingProvider=no hasProcessingProvider=no
# Uncomment the following line and add your changelog: # Uncomment the following line and add your changelog:
changelog=<h2>CenRa_PageRender:</h2></br><p><h3>07/01/2025 - Version 0.1.5: </h3> - ByPass du certif ssl ci erreur.</br></p><p><h3>14/11/2024 - Version 0.1.4: </h3> - Implementation de la mollet. </br> - Implementation du dragging pour déplacer et modification de la taille </br></p></br><p><h3>08/11/2024 - Version 0.1.3: </h3> - Correctif de bug. </br><p><h3>21/10/2024 - Version 0.1.1: </h3> - Les match en if. </br> - Bouton de scroll et adaptation portrait.</p></br><p><h3>09/10/2024 - Version 0.1.0: </h3> - Création.</p> changelog=<h2>CenRa_PAGERENDER:</h2></br><p><h3>03/04/2025 - Version 0.1.6: </h3> - Mise a jour de securite.</p></br><p><h3>07/01/2025 - Version 0.1.5: </h3> - ByPass du certif ssl ci erreur.</br></p><p><h3>14/11/2024 - Version 0.1.4: </h3> - Implementation de la mollet. </br> - Implementation du dragging pour déplacer et modification de la taille </br></p></br><p><h3>08/11/2024 - Version 0.1.3: </h3> - Correctif de bug. </br><p><h3>21/10/2024 - Version 0.1.1: </h3> - Les match en if. </br> - Bouton de scroll et adaptation portrait.</p></br><p><h3>09/10/2024 - Version 0.1.0: </h3> - Création.</p>
# Tags are comma separated with spaces allowed # Tags are comma separated with spaces allowed
tags=python tags=python
-34
View File
@@ -1,34 +0,0 @@
import sys
import socket
import os
IPAddr=socket.gethostbyname(socket.gethostname())
#print(IPAddr)
if IPAddr[0:11] == "100.100.100": #4269
host = "100.100.100.81"
port = "5432"
dbname = "sig4269"
sigdb="sig4269"
refdb="ref_geo4269"
password = "McVities"
if IPAddr[0:9] == "192.168.0": #01
host = "192.168.0.201"
port = "5432"
dbname = "sig01"
sigdb="sig01"
refdb="ref_geo01"
password = "McVities"
if IPAddr[0:9] == "192.168.1": #0726
host = "192.168.1.201"
port = "5432"
dbname = "sig0726"
sigdb="sig0726"
refdb="ref_geo0726"
password = "McVities"
if sys.platform == 'linux':
os_user = os.environ['USER']
else:
os_user = os.environ['USERNAME']
if os_user == 'STAGE':
os_user='stage'
if os_user == 'Administrateur':
os_user='stage'
Binary file not shown.
+1 -20
View File
@@ -107,25 +107,6 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None):
from CenRa_METABASE.tools.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels): def send_issues(url,titre,body,labels):
import requests import requests
import json import json
@@ -158,7 +139,7 @@ def maj_verif(NAME):
url = qgis.utils.pluginMetadata(NAME,'repository') url = qgis.utils.pluginMetadata(NAME,'repository')
#URL = url+'/raw/branch/main/plugins.xml' #URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version) len_version = len(version)
+27 -7
View File
@@ -13,12 +13,16 @@ import qgis
#include <QSettings> #include <QSettings>
import socket
import os import os
from .tools.resources import ( from .tools.resources import (
plugin_path, plugin_path,
pyperclip,
resources_path, resources_path,
maj_verif, maj_verif,
) )
pyperclip()
from .postgis_editor import Postgis_Editor from .postgis_editor import Postgis_Editor
from .postgis_creator import Postgis_Creator from .postgis_creator import Postgis_Creator
from .postgis_rename import Postgis_Rename from .postgis_rename import Postgis_Rename
@@ -26,6 +30,8 @@ from .about_form import AboutDialog
from PyQt5.QtCore import * from PyQt5.QtCore import *
IPAddr=socket.gethostbyname(socket.gethostname())
class PgPostgis: class PgPostgis:
def __init__(self): def __init__(self):
""" Constructor. """ """ Constructor. """
@@ -72,12 +78,22 @@ class PgPostgis:
self.postgis_creator = QAction(icon, 'dossier_creator',None) self.postgis_creator = QAction(icon, 'dossier_creator',None)
self.toolBar.addAction(self.postgis_creator) self.toolBar.addAction(self.postgis_creator)
self.postgis_creator.triggered.connect(self.open_creator) self.postgis_creator.triggered.connect(self.open_creator)
self.postgis_creator.setEnabled(False)
if os.access('N:/',os.R_OK):
self.postgis_creator.setEnabled(True)
if not self.action_editor: if not self.action_editor:
self.action_editor = Postgis_Editor() self.action_editor = Postgis_Editor()
self.postgis_editor = QAction(icon2, 'dossier_editor',None) self.postgis_editor = QAction(icon2, 'dossier_editor',None)
self.toolBar.addAction(self.postgis_editor) self.toolBar.addAction(self.postgis_editor)
self.postgis_editor.triggered.connect(self.open_editor) self.postgis_editor.triggered.connect(self.open_editor)
self.postgis_editor.setEnabled(False)
if os.access('N:/',os.R_OK):
self.postgis_editor.setEnabled(True)
if not self.action_rename: if not self.action_rename:
self.action_rename = Postgis_Rename() self.action_rename = Postgis_Rename()
@@ -85,14 +101,18 @@ class PgPostgis:
self.toolBar.addAction(self.postgis_rename) self.toolBar.addAction(self.postgis_rename)
self.postgis_rename.triggered.connect(self.open_rename) self.postgis_rename.triggered.connect(self.open_rename)
if os.environ['USERNAME'] == 'tlaveille' or os.environ['USERNAME'] == 'lpoulin' or os.environ['USERNAME'] == 'rclement': if os.environ['USERNAME'] == 'tlaveille' or os.environ['USERNAME'] == 'lpoulin' or os.environ['USERNAME'] == 'rclement':
self.action_rename.setEnabled(True) self.action_rename.setEnabled(True)
self.postgis_rename.setEnabled(True) self.postgis_rename.setEnabled(True)
self.postgis_rename.setVisible(1) self.postgis_rename.setVisible(1)
else: else:
self.action_rename.setEnabled(False) self.action_rename.setEnabled(False)
self.postgis_rename.setEnabled(False)
self.postgis_rename.setVisible(0)
self.postgis_rename.setEnabled(False) self.postgis_rename.setEnabled(False)
self.postgis_rename.setVisible(0) if os.access('N:/',os.R_OK):
self.postgis_rename.setEnabled(True)
def open_about_dialog(self): def open_about_dialog(self):
""" """
+2 -2
View File
@@ -12,7 +12,7 @@
name=CenRa_POSTGIS name=CenRa_POSTGIS
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
description=Permet de crée un dossier dans la base PostGis description=Permet de crée un dossier dans la base PostGis
version=2.6 version=2.9
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@@ -21,7 +21,7 @@ email=si_besoin@cen-rhonealpes.fr
# Optional items: # Optional items:
# Uncomment the following line and add your changelog entries: # Uncomment the following line and add your changelog entries:
changelog=<h2>CenRa_POSTGIS:</h2></br><p><h3>12/02/2025 - Version 2.6: </h3> - InDev:renomé les schema et table.</p></br><p><h3>04/02/2025 - Version 2.5: </h3> - Correctif bug création de couche.</p></br><p><h3>23/01/2025 - Version 2.4: </h3> - Correctif sur les pkey.</p></br><p><h3>22/01/2025 - Version 2.3: </h3> - Correctif sur la creation de projet.</p></br><p><h3>21/01/2025 - Version 2.2: </h3> - Correctif sur la longeur des nom.</p></br><p><h3>07/01/2025 - Version 2.1: </h3> - ByPass du certif ssl ci erreur.</p></br><p><h3>22/10/2024 - Version 2.0:</h3>- Refont du code.</p> changelog=<h2>CenRa_POSTGIS:</h2></br><p><h3>09/04/2025 - Version 2.9: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 2.8: </h3> - Optimisation pour le TT.</p></br><p><h3>03/04/2025 - Version 2.7: </h3> - Mise a jour de securite.</p></br><p><h3>12/02/2025 - Version 2.6: </h3> - InDev:renomé les schema et table.</p></br><p><h3>04/02/2025 - Version 2.5: </h3> - Correctif bug création de couche.</p></br><p><h3>23/01/2025 - Version 2.4: </h3> - Correctif sur les pkey.</p></br><p><h3>22/01/2025 - Version 2.3: </h3> - Correctif sur la creation de projet.</p></br><p><h3>21/01/2025 - Version 2.2: </h3> - Correctif sur la longeur des nom.</p></br><p><h3>07/01/2025 - Version 2.1: </h3> - ByPass du certif ssl ci erreur.</p></br><p><h3>22/10/2024 - Version 2.0:</h3>- Refont du code.</p>
# tags are comma separated with spaces allowed # tags are comma separated with spaces allowed
tags=cenra, postgis, database tags=cenra, postgis, database
+15 -11
View File
@@ -15,11 +15,16 @@ from PyQt5 import QtGui
from qgis.core import * from qgis.core import *
from qgis.core import QgsDataSourceUri from qgis.core import QgsDataSourceUri
from .tools.PythonSQL import * try:
from .tools.PythonSQL import login_base
except:
print('Pas de fichier PythonSQL')
from .tools.SQLRequet import *
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base,
send_issues, send_issues,
create_vierge, create_vierge,
create_contour, create_contour,
@@ -75,15 +80,14 @@ class Postgis_Creator(QDialog, EDITOR_CLASS):
if self.nom.text().find(car) != -1 : if self.nom.text().find(car) != -1 :
QMessageBox.warning(None, "Oups :", u"Le nom de dossier ne doit pas comporter de caractères spéciaux, ni d'espaces !\n\n\t" + self.nom.text().lower() ) QMessageBox.warning(None, "Oups :", u"Le nom de dossier ne doit pas comporter de caractères spéciaux, ni d'espaces !\n\n\t" + self.nom.text().lower() )
return return
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) cur = account[7]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor) con = account[8]
first_conn.close()
SQL_schema = "CREATE SCHEMA " + schema + ";" SQL_schema = "CREATE SCHEMA " + schema + ";"
SQL_GRANT_SCHEMA="GRANT CREATE, USAGE ON SCHEMA "+schema+" TO grp_qgis; GRANT CREATE, USAGE ON SCHEMA "+schema+" TO grp_sig;" SQL_GRANT_SCHEMA="GRANT CREATE, USAGE ON SCHEMA "+schema+" TO grp_qgis; GRANT CREATE, USAGE ON SCHEMA "+schema+" TO grp_sig;"
+22 -21
View File
@@ -15,11 +15,15 @@ from PyQt5 import QtGui
from qgis.core import * from qgis.core import *
from qgis.core import QgsDataSourceUri from qgis.core import QgsDataSourceUri
from .tools.PythonSQL import * try:
from .tools.PythonSQL import login_base
except:
print('Pas de fichier PythonSQL')
from .tools.SQLRequet import *
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base,
send_issues, send_issues,
create_vierge, create_vierge,
create_contour, create_contour,
@@ -51,16 +55,14 @@ class Postgis_Editor(QDialog, EDITOR_CLASS):
### Outil Ajout de nouvelles couche a un dossier ### Outil Ajout de nouvelles couche a un dossier
def raise_(self): def raise_(self):
self.activateWindow() self.activateWindow()
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
cur = account[7]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) con = account[8]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
# Creation de la liste des schemas de la base de donnees # Creation de la liste des schemas de la base de donnees
SQL = """WITH list_schema AS ( SQL = """WITH list_schema AS (
select schemaname,'sig' as group from pg_catalog.pg_tables select schemaname,'sig' as group from pg_catalog.pg_tables
@@ -91,15 +93,14 @@ class Postgis_Editor(QDialog, EDITOR_CLASS):
# See if OK was pressed # See if OK was pressed
if result == 1: if result == 1:
#******************************debut script********************************* #******************************debut script*********************************
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) cur = account[7]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor) con = account[8]
first_conn.close()
if self.schema.currentIndex() == -1 : if self.schema.currentIndex() == -1 :
QMessageBox.warning(None, "Oups :", "Veuillez choisir un nom de dossier.") QMessageBox.warning(None, "Oups :", "Veuillez choisir un nom de dossier.")
+14 -11
View File
@@ -15,11 +15,15 @@ from PyQt5 import QtGui
from qgis.core import * from qgis.core import *
from qgis.core import QgsDataSourceUri from qgis.core import QgsDataSourceUri
from .tools.PythonSQL import * try:
from .tools.PythonSQL import login_base
except:
print('Pas de fichier PythonSQL')
from .tools.SQLRequet import *
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base,
send_issues, send_issues,
create_vierge, create_vierge,
create_contour, create_contour,
@@ -38,15 +42,14 @@ from qgis.utils import iface
EDITOR_CLASS = load_ui('CenRa_PostgisRename_base.ui') EDITOR_CLASS = load_ui('CenRa_PostgisRename_base.ui')
ch = [u"à", u"À", u"â", u"Â", u"ä", u"Ä", u"å", u"Å", u"ç", u"Ç", u"é", u"É", u"è", u"È", u"ê", u"Ê", u"ë", u"Ë", u"î", u"Î", u"ï", u"Ï", u"ô", u"Ô", u"ö", u"Ö", u"ù", u"Ù", u"û", u"Û", u"ü", u"Ü", u"ÿ", u"Ÿ", u"'", u"-", u" "] ch = [u"à", u"À", u"â", u"Â", u"ä", u"Ä", u"å", u"Å", u"ç", u"Ç", u"é", u"É", u"è", u"È", u"ê", u"Ê", u"ë", u"Ë", u"î", u"Î", u"ï", u"Ï", u"ô", u"Ô", u"ö", u"Ö", u"ù", u"Ù", u"û", u"Û", u"ü", u"Ü", u"ÿ", u"Ÿ", u"'", u"-", u" "]
try: try:
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
first_conn.close() cur = account[7]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) con = account[8]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
except: except:
print('') print('')
class Postgis_Rename(QDialog, EDITOR_CLASS): class Postgis_Rename(QDialog, EDITOR_CLASS):
-21
View File
@@ -1,21 +0,0 @@
from qgis.core import QgsApplication
def gitea():
file_url = QgsApplication.qgisSettingsDirPath()+'QGIS/QGIS3.ini'
recherche_1 = 'plugin_repositories\\github\\url=https://github.com/CEN-Rhone-Alpes/Plugin_QGIS/releases/latest/download/plugins.xml'
replace_1 = 'plugin_repositories\\gitea\\url=https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
recherche_2 = 'github'
replace_2 = 'gitea'
# Read in the file
with open(file_url, 'r') as file:
filedata = file.read()
# Replace the target string
filedata = filedata.replace(recherche_1, replace_1)
filedata = filedata.replace(recherche_2, replace_2)
# Write the file out again
with open(file_url, 'w') as file:
file.write(filedata)
@@ -1,36 +1,3 @@
import sys
import socket
import os
IPAddr=socket.gethostbyname(socket.gethostname())
if IPAddr[0:11] == "100.100.100": #4269
host = "100.100.100.11"
port = "5432"
dbname = "sig4269"
sigdb="sig4269"
refdb="ref_geo4269"
password = "McVities"
if IPAddr[0:9] == "192.168.0": #01
host = "192.168.0.201"
port = "5432"
dbname = "sig01"
sigdb="sig01"
refdb="ref_geo01"
password = "McVities"
if IPAddr[0:9] == "192.168.1": #0726
host = "192.168.1.201"
port = "5432"
dbname = "sig0726"
sigdb="sig0726"
refdb="ref_geo0726"
password = "McVities"
if sys.platform == 'linux':
os_user = os.environ['USER']
else:
os_user = os.environ['USERNAME']
if os_user == 'STAGE':
os_user='stage'
if os_user == 'Administrateur':
os_user='stage'
geom = "geom" geom = "geom"
champ_travaux_prevus_multipolygon="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))""" champ_travaux_prevus_multipolygon="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))"""
+12 -21
View File
@@ -6,10 +6,10 @@ import tempfile
import base64 import base64
import psycopg2 import psycopg2
import psycopg2.extras import psycopg2.extras
import os
from os.path import abspath, join, pardir, dirname from os.path import abspath, join, pardir, dirname
from qgis.core import QgsDataSourceUri from qgis.core import QgsDataSourceUri
from .PythonSQL import * from .SQLRequet import *
from qgis.PyQt import uic from qgis.PyQt import uic
__copyright__ = "Copyright 2019, 3Liz" __copyright__ = "Copyright 2019, 3Liz"
@@ -109,24 +109,15 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None): def pyperclip():
from .PythonSQL import host,port,dbname,password,os_user dst = dirname(dirname(__file__))+"\\tools\\"
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) if os.access('N:/',os.R_OK):
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") try:
res_ident = first_cur.fetchone() shutil.copy(src, dst)
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') except:
user = res_ident[1] print('404')
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels): def send_issues(url,titre,body,labels):
import requests import requests
import json import json
@@ -159,7 +150,7 @@ def maj_verif(NAME):
url = qgis.utils.pluginMetadata(NAME,'repository') url = qgis.utils.pluginMetadata(NAME,'repository')
#URL = url+'/raw/branch/main/plugins.xml' #URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version) len_version = len(version)
@@ -233,7 +224,7 @@ def create_contour(self,schema,cur,con,host ,port ,dbname ,user ,mdp):
uri.setDataSource(schema, tablename, geom) uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres") layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
def create_travaux(self,schema,cur,con,host ,port ,dbname ,user ,mdp): def create_travaux(self,schema,cur,con,host,port,dbname,user,mdp):
### Creation de la table travaux prevus ### Creation de la table travaux prevus
if self.couche_travaux_prevus.isChecked(): if self.couche_travaux_prevus.isChecked():
#**********Poly #**********Poly
+2 -2
View File
@@ -12,7 +12,7 @@
name=CenRa SICEN name=CenRa SICEN
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
description=Filtre des données saisies dans SICEN et export d'une liste d'espèces. description=Filtre des données saisies dans SICEN et export d'une liste d'espèces.
version=1.8 version=1.11
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@@ -21,7 +21,7 @@ email=si_besoin@cen-rhonealpes.fr
# Optional items: # Optional items:
# Uncomment the following line and add your changelog entries: # Uncomment the following line and add your changelog entries:
changelog=<h2>CenRa_SICEN:</h2></br><p><h3>07/01/2025 - Version 1.8: </h3> - ByPass du certif ssl ci erreur.</br></p><p><h3>13/09/2024 - Version 1.7:</h3> - Il est maintenant possible de sélectionné plusieurs entité pour le filtre par Emprise.</br>- Ajoute d'un changelog.</br>- Ajoute une vérification de mise à jour.</p> changelog=<h2>CenRa_SICEN:</h2></br><p><h3>09/04/2025 - Version 1.11: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 1.10: </h3> - Optimisation pour le TT.</p></br><p><h3>03/04/2025 - Version 1.9: </h3> - Mise a jour de securite.</p></br><p><h3>07/01/2025 - Version 1.8: </h3> - ByPass du certif ssl ci erreur.</br></p><p><h3>13/09/2024 - Version 1.7:</h3> - Il est maintenant possible de sélectionné plusieurs entité pour le filtre par Emprise.</br>- Ajoute d'un changelog.</br>- Ajoute une vérification de mise à jour.</p>
# tags are comma separated with spaces allowed # tags are comma separated with spaces allowed
tags=cenra, postgis, sicen tags=cenra, postgis, sicen
+59 -51
View File
@@ -45,8 +45,13 @@ from qgis.PyQt.QtWidgets import QMenu, QAction, QDialog, QDialogButtonBox, QLabe
from . import resources_rc from . import resources_rc
# Import the code for the dialog # Import the code for the dialog
from .sicendialog import SICENDialog from .sicendialog import SICENDialog
from .tools.PythonSQL import *
from .tools.resources import maj_verif from .tools.resources import maj_verif,pyperclip
pyperclip()
try:
from .tools.PythonSQL import login_base
except:
print('Pas de fichier PythonSQL')
import os.path import os.path
import qgis import qgis
import datetime import datetime
@@ -57,7 +62,7 @@ from .forms.about_form import AboutDialog
import psycopg2 import psycopg2
import psycopg2.extras import psycopg2.extras
import base64 import base64
#import socket import socket
import os import os
#import sys #import sys
@@ -100,6 +105,9 @@ class SICEN(object):
self.action = QAction( self.action = QAction(
QIcon(":/plugins/sicen/sicen.png"), QIcon(":/plugins/sicen/sicen.png"),
u"Ouverture des données SICEN", self.iface.mainWindow()) u"Ouverture des données SICEN", self.iface.mainWindow())
self.action.setEnabled(False)
if os.access('N:/',os.R_OK):
self.action.setEnabled(True)
# connect the action to the run method # connect the action to the run method
self.action.triggered.connect(self.ouverture) self.action.triggered.connect(self.ouverture)
@@ -111,6 +119,14 @@ class SICEN(object):
self.action = QAction( self.action = QAction(
QIcon(":/plugins/sicen/sicen_export.png"), QIcon(":/plugins/sicen/sicen_export.png"),
u"Export liste d'espèces", self.iface.mainWindow()) u"Export liste d'espèces", self.iface.mainWindow())
self.action.setEnabled(False)
IPAddr=socket.gethostbyname(socket.gethostname())
if IPAddr[0:11] == "100.100.100":
self.action.setEnabled(True)
elif IPAddr[0:9] == "192.168.0":
self.action.setEnabled(True)
elif IPAddr[0:9] == "192.168.1":
self.action.setEnabled(True)
# connect the action to the run method # connect the action to the run method
self.action.triggered.connect(self.export) self.action.triggered.connect(self.export)
@@ -146,16 +162,14 @@ class SICEN(object):
# run method that performs all the real work # run method that performs all the real work
def ouverture(self): def ouverture(self):
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
cur = account[7]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) con = account[8]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
## Creation des listes deroulantes ## Creation des listes deroulantes
# Listing de valeur des champs # Listing de valeur des champs
@@ -255,16 +269,14 @@ class SICEN(object):
# See if OK was pressed # See if OK was pressed
if result == 1: if result == 1:
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
cur = account[7]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) con = account[8]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
# Requete filtre observateur # Requete filtre observateur
if self.dlg.observateur_1.currentIndex() != -1 : if self.dlg.observateur_1.currentIndex() != -1 :
@@ -620,15 +632,14 @@ class SICEN(object):
else : else :
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) cur = account[7]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor) con = account[8]
first_conn.close()
# Creation group de couches # Creation group de couches
#i = qgis.utils.iface #i = qgis.utils.iface
@@ -753,15 +764,14 @@ class SICEN(object):
else : else :
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) cur = account[7]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor) con = account[8]
first_conn.close()
# Creation group de couches # Creation group de couches
i = qgis.utils.iface i = qgis.utils.iface
@@ -862,16 +872,14 @@ class SICEN(object):
buffer = '100' buffer = '100'
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
cur = account[7]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) con = account[8]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
SQL_list_sp = u"""SELECT DISTINCT classe::text,ordre::text,nom_complet::text,split_part(nom_vern::text,',',1) as nom_vern,cd_ref::text as cd_ref,max(COALESCE(date_obs, date_debut_obs))::text AS derniere_obs FROM _agregation_ra.observations_table WHERE ST_intersects(geometrie,ST_Buffer(ST_geomFromText('""" + poly + "',2154), " + buffer + " ))GROUP BY classe::text, ordre::text, nom_complet::text, nom_vern::text, cd_ref::text ORDER BY nom_complet::text""" SQL_list_sp = u"""SELECT DISTINCT classe::text,ordre::text,nom_complet::text,split_part(nom_vern::text,',',1) as nom_vern,cd_ref::text as cd_ref,max(COALESCE(date_obs, date_debut_obs))::text AS derniere_obs FROM _agregation_ra.observations_table WHERE ST_intersects(geometrie,ST_Buffer(ST_geomFromText('""" + poly + "',2154), " + buffer + " ))GROUP BY classe::text, ordre::text, nom_complet::text, nom_vern::text, cd_ref::text ORDER BY nom_complet::text"""
cur.execute(SQL_list_sp) cur.execute(SQL_list_sp)
-21
View File
@@ -1,21 +0,0 @@
from qgis.core import QgsApplication
def gitea():
file_url = QgsApplication.qgisSettingsDirPath()+'QGIS/QGIS3.ini'
recherche_1 = 'plugin_repositories\\github\\url=https://github.com/CEN-Rhone-Alpes/Plugin_QGIS/releases/latest/download/plugins.xml'
replace_1 = 'plugin_repositories\\gitea\\url=https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
recherche_2 = 'github'
replace_2 = 'gitea'
# Read in the file
with open(file_url, 'r') as file:
filedata = file.read()
# Replace the target string
filedata = filedata.replace(recherche_1, replace_1)
filedata = filedata.replace(recherche_2, replace_2)
# Write the file out again
with open(file_url, 'w') as file:
file.write(filedata)
+11 -19
View File
@@ -3,6 +3,7 @@
import configparser import configparser
import shutil import shutil
import tempfile import tempfile
import os
import base64 import base64
import psycopg2 import psycopg2
import psycopg2.extras import psycopg2.extras
@@ -89,7 +90,7 @@ def resources_path(*args):
:return: Absolute path to the resources folder. :return: Absolute path to the resources folder.
:rtype: str :rtype: str
""" """
path = abspath(abspath(join(plugin_path(), "CenRa_Metabase\\tools"))) path = abspath(abspath(join(plugin_path(), "CenRa_SICEN\\tools")))
for item in args: for item in args:
path = abspath(join(path, item)) path = abspath(join(path, item))
return path return path
@@ -107,24 +108,15 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None): def pyperclip():
from .tools.PythonSQL import host,port,dbname,password,os_user dst = dirname(dirname(__file__))+"\\tools\\"
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) if os.access('N:/',os.R_OK):
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") try:
res_ident = first_cur.fetchone() shutil.copy(src, dst)
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') except:
user = res_ident[1] print('404')
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels): def send_issues(url,titre,body,labels):
import requests import requests
import json import json
@@ -157,7 +149,7 @@ def maj_verif(NAME):
url = qgis.utils.pluginMetadata(NAME,'repository') url = qgis.utils.pluginMetadata(NAME,'repository')
#URL = url+'/raw/branch/main/plugins.xml' #URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version) len_version = len(version)
+1 -1
View File
@@ -5,7 +5,7 @@ Pour la création et le partage :heart:
|Nom|Version|Statue|Date de création| |Nom|Version|Statue|Date de création|
|---|---|---|---| |---|---|---|---|
|CenRa_AUTOMAP|1.2|Releases|2024-09-25| |CenRa_AUTOMAP|1.2|Releases|2024-09-25|
|CenRa_COPIE|2.1|Releases|06-02-2024| |CenRa_COPIE|2.2|Releases|06-02-2024|
|CenRa_FLUX|2.5|Releases|06-02-2024| |CenRa_FLUX|2.5|Releases|06-02-2024|
|CenRa_METABASE|0.2.0|Alpha|12-09-2024| |CenRa_METABASE|0.2.0|Alpha|12-09-2024|
|CenRa_PAGERENDER|0.1.5|Alpha|09-10-2024| |CenRa_PAGERENDER|0.1.5|Alpha|09-10-2024|
+30 -31
View File
@@ -1,8 +1,7 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<plugins> <plugins>
<pyqgis_plugin name="CenRa_POSTGIS" version="2.6"> <pyqgis_plugin name="CenRa_POSTGIS" version="2.9">
<description><![CDATA[Dépôt pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.]]></description> <description>Depot pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.</description>
<version>2.6</version> <version>2.9</version>
<qgis_minimum_version>3.16</qgis_minimum_version> <qgis_minimum_version>3.16</qgis_minimum_version>
<homepage>https://plateformesig.cenra-outils.org/</homepage> <homepage>https://plateformesig.cenra-outils.org/</homepage>
<file_name>CenRa_POSTGIS.zip</file_name> <file_name>CenRa_POSTGIS.zip</file_name>
@@ -11,15 +10,15 @@
<download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_POSTGIS.zip</download_url> <download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_POSTGIS.zip</download_url>
<uploaded_by>CEN-Rhone-Alpes</uploaded_by> <uploaded_by>CEN-Rhone-Alpes</uploaded_by>
<create_date>2024-02-06</create_date> <create_date>2024-02-06</create_date>
<update_date>2025-02-12</update_date> <update_date>2025-04-09</update_date>
<experimental>False</experimental> <experimental>False</experimental>
<deprecated>False</deprecated> <deprecated>False</deprecated>
<tags>cenra,postgis</tags> <tags>cenra,postgis</tags>
</pyqgis_plugin> </pyqgis_plugin>
<pyqgis_plugin name="CenRa_COPIE" version="2.1"> <pyqgis_plugin name="CenRa_COPIE" version="2.4">
<description><![CDATA[Dépôt pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.]]></description> <description>Depot pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.</description>
<version>2.1</version> <version>2.4</version>
<qgis_minimum_version>3.16</qgis_minimum_version> <qgis_minimum_version>3.16</qgis_minimum_version>
<homepage>https://plateformesig.cenra-outils.org/</homepage> <homepage>https://plateformesig.cenra-outils.org/</homepage>
<file_name>CenRa_COPIE.zip</file_name> <file_name>CenRa_COPIE.zip</file_name>
@@ -28,15 +27,15 @@
<download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_COPIE.zip</download_url> <download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_COPIE.zip</download_url>
<uploaded_by>CEN-Rhone-Alpes</uploaded_by> <uploaded_by>CEN-Rhone-Alpes</uploaded_by>
<create_date>2024-02-06</create_date> <create_date>2024-02-06</create_date>
<update_date>2025-01-07</update_date> <update_date>2025-04-09</update_date>
<experimental>False</experimental> <experimental>False</experimental>
<deprecated>False</deprecated> <deprecated>False</deprecated>
<tags>cenra,copie</tags> <tags>cenra,copie</tags>
</pyqgis_plugin> </pyqgis_plugin>
<pyqgis_plugin name="CenRa_SICEN" version="1.8"> <pyqgis_plugin name="CenRa_SICEN" version="1.11">
<description><![CDATA[Dépôt pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.]]></description> <description>Depot pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.</description>
<version>1.8</version> <version>1.11</version>
<qgis_minimum_version>3.16</qgis_minimum_version> <qgis_minimum_version>3.16</qgis_minimum_version>
<homepage>https://plateformesig.cenra-outils.org/</homepage> <homepage>https://plateformesig.cenra-outils.org/</homepage>
<file_name>CenRa_SICEN.zip</file_name> <file_name>CenRa_SICEN.zip</file_name>
@@ -45,15 +44,15 @@
<download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_SICEN.zip</download_url> <download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_SICEN.zip</download_url>
<uploaded_by>CEN-Rhone-Alpes</uploaded_by> <uploaded_by>CEN-Rhone-Alpes</uploaded_by>
<create_date>2024-02-06</create_date> <create_date>2024-02-06</create_date>
<update_date>2025-01-07</update_date> <update_date>2025-04-09</update_date>
<experimental>False</experimental> <experimental>False</experimental>
<deprecated>False</deprecated> <deprecated>False</deprecated>
<tags>cenra,sicen</tags> <tags>cenra,sicen</tags>
</pyqgis_plugin> </pyqgis_plugin>
<pyqgis_plugin name="CenRa_FLUX" version="2.5"> <pyqgis_plugin name="CenRa_FLUX" version="2.9">
<description><![CDATA[Dépôt pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.]]></description> <description>Depot pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.</description>
<version>2.5</version> <version>2.9</version>
<qgis_minimum_version>3.16</qgis_minimum_version> <qgis_minimum_version>3.16</qgis_minimum_version>
<homepage>https://plateformesig.cenra-outils.org/</homepage> <homepage>https://plateformesig.cenra-outils.org/</homepage>
<file_name>CenRa_FLUX.zip</file_name> <file_name>CenRa_FLUX.zip</file_name>
@@ -62,15 +61,15 @@
<download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_FLUX.zip</download_url> <download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_FLUX.zip</download_url>
<uploaded_by>CEN-Rhone-Alpes</uploaded_by> <uploaded_by>CEN-Rhone-Alpes</uploaded_by>
<create_date>2024-02-06</create_date> <create_date>2024-02-06</create_date>
<update_date>2025-03-20</update_date> <update_date>2025-04-09</update_date>
<experimental>False</experimental> <experimental>False</experimental>
<deprecated>False</deprecated> <deprecated>False</deprecated>
<tags>cenra,flux</tags> <tags>cenra,flux</tags>
</pyqgis_plugin> </pyqgis_plugin>
<pyqgis_plugin name="CenRa_METABASE" version="0.2.0"> <pyqgis_plugin name="CenRa_METABASE" version="0.2.3">
<description><![CDATA[Dépôt pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.]]></description> <description>Depot pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.</description>
<version>0.2.0</version> <version>0.2.3</version>
<qgis_minimum_version>3.16</qgis_minimum_version> <qgis_minimum_version>3.16</qgis_minimum_version>
<homepage>https://plateformesig.cenra-outils.org/</homepage> <homepage>https://plateformesig.cenra-outils.org/</homepage>
<file_name>CenRa_METABASE.zip</file_name> <file_name>CenRa_METABASE.zip</file_name>
@@ -79,15 +78,15 @@
<download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_METABASE.zip</download_url> <download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_METABASE.zip</download_url>
<uploaded_by>CEN-Rhone-Alpes</uploaded_by> <uploaded_by>CEN-Rhone-Alpes</uploaded_by>
<create_date>2024-09-12</create_date> <create_date>2024-09-12</create_date>
<update_date>2025-01-24</update_date> <update_date>2025-04-09</update_date>
<experimental>True</experimental> <experimental>True</experimental>
<deprecated>False</deprecated> <deprecated>False</deprecated>
<tags>cenra,metabase</tags> <tags>cenra,metabase</tags>
</pyqgis_plugin> </pyqgis_plugin>
<pyqgis_plugin name="CenRa_AUTOMAP" version="1.3"> <pyqgis_plugin name="CenRa_AUTOMAP" version="1.6">
<description><![CDATA[Dépôt pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.]]></description> <description>Depot pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.</description>
<version>1.3</version> <version>1.6</version>
<qgis_minimum_version>3.16</qgis_minimum_version> <qgis_minimum_version>3.16</qgis_minimum_version>
<homepage>https://plateformesig.cenra-outils.org/</homepage> <homepage>https://plateformesig.cenra-outils.org/</homepage>
<file_name>CenRa_AUTOMAP.zip</file_name> <file_name>CenRa_AUTOMAP.zip</file_name>
@@ -96,15 +95,15 @@
<download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_AUTOMAP.zip</download_url> <download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_AUTOMAP.zip</download_url>
<uploaded_by>CEN-Rhone-Alpes</uploaded_by> <uploaded_by>CEN-Rhone-Alpes</uploaded_by>
<create_date>2024-09-25</create_date> <create_date>2024-09-25</create_date>
<update_date>2025-03-20</update_date> <update_date>2025-04-09</update_date>
<experimental>False</experimental> <experimental>False</experimental>
<deprecated>False</deprecated> <deprecated>False</deprecated>
<tags>cenra,mise en page,atlas</tags> <tags>cenra,mise en page,atlas</tags>
</pyqgis_plugin> </pyqgis_plugin>
<pyqgis_plugin name="CenRa_PAGERENDER" version="0.1.5"> <pyqgis_plugin name="CenRa_PAGERENDER" version="0.1.6">
<description><![CDATA[Dépôt pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.]]></description> <description>Depot pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.</description>
<version>0.1.5</version> <version>0.1.6</version>
<qgis_minimum_version>3.16</qgis_minimum_version> <qgis_minimum_version>3.16</qgis_minimum_version>
<homepage>https://plateformesig.cenra-outils.org/</homepage> <homepage>https://plateformesig.cenra-outils.org/</homepage>
<file_name>CenRa_PAGERENDER.zip</file_name> <file_name>CenRa_PAGERENDER.zip</file_name>
@@ -113,14 +112,14 @@
<download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_PAGERENDER.zip</download_url> <download_url>https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_PAGERENDER.zip</download_url>
<uploaded_by>CEN-Rhone-Alpes</uploaded_by> <uploaded_by>CEN-Rhone-Alpes</uploaded_by>
<create_date>2024-10-09</create_date> <create_date>2024-10-09</create_date>
<update_date>2025-01-07</update_date> <update_date>2025-04-03</update_date>
<experimental>True</experimental> <experimental>True</experimental>
<deprecated>False</deprecated> <deprecated>False</deprecated>
<tags>cenra,mise en page,atlas</tags> <tags>cenra,mise en page,atlas</tags>
</pyqgis_plugin> </pyqgis_plugin>
<pyqgis_plugin name="CenRa_gn2qgis" version="0.1.0"> <pyqgis_plugin name="CenRa_gn2qgis" version="0.1.0">
<description><![CDATA[Dépôt pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.]]></description> <description>Depot pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.</description>
<version>0.1.0</version> <version>0.1.0</version>
<qgis_minimum_version>3.16</qgis_minimum_version> <qgis_minimum_version>3.16</qgis_minimum_version>
<homepage>https://plateformesig.cenra-outils.org/</homepage> <homepage>https://plateformesig.cenra-outils.org/</homepage>
@@ -137,7 +136,7 @@
</pyqgis_plugin> </pyqgis_plugin>
<pyqgis_plugin name="BiodivAURA" version="0.1.0"> <pyqgis_plugin name="BiodivAURA" version="0.1.0">
<description><![CDATA[Dépôt pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.]]></description> <description>Depot pour les extensiont QGIS du CEN Rhone-Alpes, sur GitHub.</description>
<version>0.1.0</version> <version>0.1.0</version>
<qgis_minimum_version>3.16</qgis_minimum_version> <qgis_minimum_version>3.16</qgis_minimum_version>
<homepage>https://plateformesig.cenra-outils.org/</homepage> <homepage>https://plateformesig.cenra-outils.org/</homepage>