Compare commits
No commits in common. "6c1af3c61c742d0810d454b3644079794ee1e27c" and "7df08ae02adf9b952d4240f33e6309f222a11867" have entirely different histories.
6c1af3c61c
...
7df08ae02a
@ -4,25 +4,27 @@ __email__ = "info@3liz.org"
|
|||||||
|
|
||||||
|
|
||||||
from qgis.core import QgsApplication
|
from qgis.core import QgsApplication
|
||||||
from qgis.PyQt.QtCore import QSettings, QUrl
|
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl
|
||||||
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
||||||
from qgis.PyQt.QtWidgets import QAction
|
from qgis.PyQt.QtWidgets import QAction, QMessageBox
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
import qgis
|
import qgis
|
||||||
|
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
import socket
|
||||||
import os
|
import os
|
||||||
from .about_form import AboutDialog
|
|
||||||
from .tools.resources import (
|
from .tools.resources import (
|
||||||
# plugin_path,
|
plugin_path,
|
||||||
pyperclip,
|
pyperclip,
|
||||||
resources_path,
|
resources_path,
|
||||||
maj_verif,
|
maj_verif,
|
||||||
)
|
)
|
||||||
pyperclip()
|
pyperclip()
|
||||||
from .copie_editor import Copie_Editor
|
from .copie_editor import Copie_Editor
|
||||||
|
from .about_form import AboutDialog
|
||||||
|
|
||||||
|
from qgis.PyQt.QtCore import *
|
||||||
|
|
||||||
class PgCopie:
|
class PgCopie:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -67,7 +69,7 @@ class PgCopie:
|
|||||||
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)
|
self.copie_editor.setEnabled(False)
|
||||||
# IPAddr = socket.gethostbyname(socket.gethostname())
|
IPAddr=socket.gethostbyname(socket.gethostname())
|
||||||
if os.access('N:/',os.R_OK):
|
if os.access('N:/',os.R_OK):
|
||||||
self.copie_editor.setEnabled(True)
|
self.copie_editor.setEnabled(True)
|
||||||
|
|
||||||
@ -77,7 +79,6 @@ class PgCopie:
|
|||||||
"""
|
"""
|
||||||
dialog = AboutDialog(iface)
|
dialog = AboutDialog(iface)
|
||||||
dialog.exec()
|
dialog.exec()
|
||||||
|
|
||||||
def open_help():
|
def open_help():
|
||||||
""" Open the online help. """
|
""" Open the online help. """
|
||||||
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
|
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
|
||||||
@ -91,6 +92,7 @@ class PgCopie:
|
|||||||
if self.action_editor:
|
if self.action_editor:
|
||||||
iface.removePluginMenu('CenRa_Copie',self.copie_editor)
|
iface.removePluginMenu('CenRa_Copie',self.copie_editor)
|
||||||
|
|
||||||
|
|
||||||
if self.provider:
|
if self.provider:
|
||||||
QgsApplication.processingRegistry().removeProvider(self.provider)
|
QgsApplication.processingRegistry().removeProvider(self.provider)
|
||||||
del self.provider
|
del self.provider
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import os.path
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from qgis.PyQt import uic
|
from qgis.PyQt import uic
|
||||||
# from qgis.PyQt.QtGui import QPixmap
|
from qgis.PyQt.QtGui import QPixmap
|
||||||
from qgis.PyQt.QtWidgets import QDialog
|
from qgis.PyQt.QtWidgets import QDialog
|
||||||
|
|
||||||
from .tools.resources import devlog
|
from .tools.resources import devlog
|
||||||
|
|||||||
@ -4,37 +4,43 @@ from __future__ import absolute_import
|
|||||||
# Import the PyQt and QGIS libraries
|
# Import the PyQt and QGIS libraries
|
||||||
from builtins import next
|
from builtins import next
|
||||||
from builtins import str
|
from builtins import str
|
||||||
# from builtins import object
|
from builtins import object
|
||||||
# import qgis
|
import qgis
|
||||||
from qgis.PyQt.QtCore import QSettings
|
from qgis.PyQt.QtCore import QSettings
|
||||||
from qgis.PyQt.QtWidgets import QDialog, QMessageBox
|
from qgis.PyQt.QtWidgets import QAction, QMenu, QDialog
|
||||||
|
from qgis.PyQt.QtGui import QIcon
|
||||||
|
|
||||||
|
from qgis.PyQt.QtCore import *
|
||||||
|
from qgis.PyQt.QtGui import *
|
||||||
from qgis.PyQt import QtGui
|
from qgis.PyQt import QtGui
|
||||||
from qgis.core import QgsDataSourceUri, QgsSettings, QgsWkbTypes
|
|
||||||
|
from qgis.core import *
|
||||||
|
from qgis.core import QgsDataSourceUri
|
||||||
|
import os
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from .tools.PythonSQL import login_base
|
from .tools.PythonSQL import login_base
|
||||||
except ValueError:
|
except:
|
||||||
print('Pas de fichier PythonSQL')
|
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,
|
||||||
# send_issues,
|
send_issues,
|
||||||
)
|
)
|
||||||
# from .issues import CenRa_Issues
|
from .issues import CenRa_Issues
|
||||||
|
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
# import os
|
import os.path
|
||||||
# import os.path
|
import webbrowser, os
|
||||||
# import webbrowser
|
import psycopg2
|
||||||
# import psycopg2
|
import psycopg2.extras
|
||||||
# import psycopg2.extras
|
import base64
|
||||||
# import base64
|
|
||||||
|
|
||||||
EDITOR_CLASS = load_ui('CenRa_Copie_base.ui')
|
EDITOR_CLASS = load_ui('CenRa_Copie_base.ui')
|
||||||
|
|
||||||
|
|
||||||
class Copie_Editor(QDialog, EDITOR_CLASS):
|
class Copie_Editor(QDialog, EDITOR_CLASS):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
_ = parent
|
_ = parent
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -48,9 +54,9 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
|
|||||||
"""Run method that performs all the real work"""
|
"""Run method that performs all the real work"""
|
||||||
layer = self.iface.activeLayer()
|
layer = self.iface.activeLayer()
|
||||||
|
|
||||||
if layer is None:
|
if layer == None :
|
||||||
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner une table !", level=QgsMessageBar.WARNING, duration=5)
|
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner une table !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner une table !", level=1, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner une table !", level=Qgis.Warning, duration=5)
|
||||||
|
|
||||||
else :
|
else :
|
||||||
# Récupération des sources de la couche active
|
# Récupération des sources de la couche active
|
||||||
@ -62,12 +68,14 @@ 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")
|
account = login_base("account")
|
||||||
sigdb = account[5]
|
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=2, 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]
|
user = account[0]
|
||||||
mdp = account[1]
|
mdp = account[1]
|
||||||
@ -101,11 +109,10 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
self.schema.clear()
|
self.schema.clear()
|
||||||
self.schema.addItems(listItems)
|
self.schema.addItems(listItems)
|
||||||
# Pour ne pas commencer la liste au premier schema
|
self.schema.setCurrentIndex(-1) # Pour ne pas commencer la liste au premier schema
|
||||||
self.schema.setCurrentIndex(-1)
|
|
||||||
|
|
||||||
# Affiche le nom de la table source
|
|
||||||
self.table_source.setText(source_schema + "." + source_tablename)
|
self.table_source.setText(source_schema + "." + source_tablename) # Affiche le nom de la table source
|
||||||
# show the dialog
|
# show the dialog
|
||||||
self.show()
|
self.show()
|
||||||
# Run the dialog event loop
|
# Run the dialog event loop
|
||||||
@ -113,6 +120,8 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
|
|||||||
# See if OK was pressed
|
# See if OK was pressed
|
||||||
if result:
|
if result:
|
||||||
#******************************debut script*********************************
|
#******************************debut script*********************************
|
||||||
|
|
||||||
|
|
||||||
account = login_base("account")
|
account = login_base("account")
|
||||||
user = account[0]
|
user = account[0]
|
||||||
mdp = account[1]
|
mdp = account[1]
|
||||||
@ -195,12 +204,12 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
con.commit()
|
con.commit()
|
||||||
|
|
||||||
# Affichage de la table
|
### Affichage de la table
|
||||||
uri = QgsDataSourceUri()
|
uri = QgsDataSourceUri()
|
||||||
# set host name, port, database name, username and password
|
# set host name, port, database name, username and password
|
||||||
uri.setConnection(host ,port ,dbname ,user ,mdp)
|
uri.setConnection(host ,port ,dbname ,user ,mdp)
|
||||||
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
|
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
|
||||||
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")
|
||||||
|
|
||||||
@ -208,5 +217,5 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
|
|||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
#self.iface.messageBar().pushMessage("Table \"" + source_schema + "." + source_tablename + u"\" copiée dans \"" + schema + "." + tablename + "\"." , level=QgsMessageBar.INFO, duration=10)
|
#self.iface.messageBar().pushMessage("Table \"" + source_schema + "." + source_tablename + u"\" copiée dans \"" + schema + "." + tablename + "\"." , level=QgsMessageBar.INFO, duration=10)
|
||||||
self.iface.messageBar().pushMessage("Bravo!", "Table \"" + source_schema + "." + source_tablename + u"\" copiée dans \"" + schema + "." + tablename + "\".", level=3, duration=5)
|
self.iface.messageBar().pushMessage("Bravo!", "Table \"" + source_schema + "." + source_tablename + u"\" copiée dans \"" + schema + "." + tablename + "\".", level=Qgis.Success, duration=5)
|
||||||
pass
|
pass
|
||||||
|
|||||||
141
CenRa_COPIE/tools/SQLRequet.py
Normal file
141
CenRa_COPIE/tools/SQLRequet.py
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
|
||||||
|
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_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_point = """(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, x_wgs84 double precision, y_wgs84 double precision, date_creation date, date_maj date, geom geometry(Point,2154))"""
|
||||||
|
|
||||||
|
champ_viergePolygone = """(gid serial NOT NULL, commentaire text, surface_m2 double precision, surface_ha double precision, geom geometry(MultiPolygon,2154))"""
|
||||||
|
champ_viergeLigne = """(gid serial NOT NULL, commentaire text, longueur_m double precision, longueur_km double precision, geom geometry(MultiLineString,2154))"""
|
||||||
|
champ_viergePoint = """(gid serial NOT NULL, commentaire text, x_wgs84 double precision, y_wgs84 double precision, geom geometry(Point,2154))"""
|
||||||
|
|
||||||
|
champ_habitat = """(gid serial NOT NULL, cd_cb_01 text, lb_cb97_fr_01 text, occupation_01 integer, cd_cb_02 text, lb_cb97_fr_02 text, occupation_02 integer, cd_cb_03 text, lb_cb97_fr_03 text, occupation_03 integer, milieu_code text, milieu_libelle text, surface_m2 double precision, surface_ha double precision, commentaire text, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))"""
|
||||||
|
|
||||||
|
champ_contour="""(gid serial NOT NULL, date_creation date, date_maj date, utilisateur character varying, dept character(2), nom character varying, surface_m2 double precision, surface_ha double precision, type_site character varying, type_milieu character varying, date_premier_pg integer, date_debut_pg integer, date_fin_pg integer, referent character varying, gestion_deleguee character varying, terrain_militaire character(3), ens character(3), zh character(3), adapt_pmr character(3), inform character(3), guide character(3), ouverture_public character(3), obs character(3), anim character(3), n2000_anim character(3), contrat_n2000_conseil character(3), n2000_op character(3), contrat_n2000_benef character(3), contrat_agri character(3), bc_habitat integer, bc_amphibien integer, bc_coleoptere integer, bc_crustace integer, bc_mammifere integer, bc_chiroptere integer, bc_mollusque integer, bc_odonate integer, bc_oiseau integer, bc_orthoptere integer, bc_poisson integer, bc_reptile integer, bc_rhopalocere integer, bc_heterocere integer, bc_autre_invertebre integer, bc_flore integer, bc_bryophyte integer, bc_champignon integer, suiv_analyse_sol character(3), suiv_piezo character(3), suiv_climat character(3), suiv_topo character(3), suiv_habitat character(3), suiv_amphibien character(3), suiv_coleoptere character(3), suiv_crustace character(3), suiv_mammifere character(3), suiv_chiroptere character(3), suiv_mollusque character(3), suiv_odonate character(3), suiv_oiseau character(3), suiv_orthoptere character(3), suiv_poisson character(3), suiv_reptile character(3), suiv_rhopalocere character(3), suiv_heterocere character(3), suiv_autre_invertebre character(3), suiv_flore character(3), suiv_bryophyte character(3), suiv_champignon character(3), suiv_analyse_eau character(3), suiv_phenologie character(3), suiv_frequentation character(3), suiv_paysager character(3), suiv_autre character(3), commentaire text, geom geometry(MultiPolygon,2154))
|
||||||
|
"""
|
||||||
|
|
||||||
|
champ_vegethab_point = """(
|
||||||
|
gid serial NOT NULL ,
|
||||||
|
cd_eu_01 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lb_eu_01 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
occupati_1 bigint,
|
||||||
|
cd_eu_02 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lb_eu_02 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
occupati_2 bigint,
|
||||||
|
cd_eu_03 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lb_eu_03 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
occupati_3 bigint,
|
||||||
|
milieu_cod character varying(254) COLLATE pg_catalog."default",
|
||||||
|
milieu_lib character varying(254) COLLATE pg_catalog."default",
|
||||||
|
surface_m2 numeric,
|
||||||
|
surface_ha numeric,
|
||||||
|
commentair character varying(254) COLLATE pg_catalog."default",
|
||||||
|
date_creat date,
|
||||||
|
date_maj date,
|
||||||
|
num_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
type_unite character varying(254) COLLATE pg_catalog."default",
|
||||||
|
dynamique character varying(254) COLLATE pg_catalog."default",
|
||||||
|
gestio_obs character varying(254) COLLATE pg_catalog."default",
|
||||||
|
degrad_obs character varying(254) COLLATE pg_catalog."default",
|
||||||
|
eta_conser character varying(254) COLLATE pg_catalog."default",
|
||||||
|
clas_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
alli_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
syntaxon character varying(254) COLLATE pg_catalog."default",
|
||||||
|
n2000 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lrr_aura character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lrr_cbna character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
|
||||||
|
vege_enjeu character varying(254) COLLATE pg_catalog."default",
|
||||||
|
num_photo character varying(254) COLLATE pg_catalog."default",
|
||||||
|
nature_obs character varying(254) COLLATE pg_catalog."default",
|
||||||
|
date_sais date,
|
||||||
|
s_al_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
alli_name character varying(254) COLLATE pg_catalog."default",
|
||||||
|
salli_name character varying(254) COLLATE pg_catalog."default",
|
||||||
|
class_name character varying(254) COLLATE pg_catalog."default",
|
||||||
|
geom geometry(Point,2154)
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
champ_vegethab_multilinestring = """(
|
||||||
|
gid serial NOT NULL ,
|
||||||
|
cd_eu_01 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lb_eu_01 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
occupati_1 bigint,
|
||||||
|
cd_eu_02 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lb_eu_02 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
occupati_2 bigint,
|
||||||
|
cd_eu_03 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lb_eu_03 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
occupati_3 bigint,
|
||||||
|
milieu_cod character varying(254) COLLATE pg_catalog."default",
|
||||||
|
milieu_lib character varying(254) COLLATE pg_catalog."default",
|
||||||
|
surface_m2 numeric,
|
||||||
|
surface_ha numeric,
|
||||||
|
commentair character varying(254) COLLATE pg_catalog."default",
|
||||||
|
date_creat date,
|
||||||
|
date_maj date,
|
||||||
|
num_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
type_unite character varying(254) COLLATE pg_catalog."default",
|
||||||
|
dynamique character varying(254) COLLATE pg_catalog."default",
|
||||||
|
gestio_obs character varying(254) COLLATE pg_catalog."default",
|
||||||
|
degrad_obs character varying(254) COLLATE pg_catalog."default",
|
||||||
|
eta_conser character varying(254) COLLATE pg_catalog."default",
|
||||||
|
clas_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
alli_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
syntaxon character varying(254) COLLATE pg_catalog."default",
|
||||||
|
n2000 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lrr_aura character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lrr_cbna character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
|
||||||
|
vege_enjeu character varying(254) COLLATE pg_catalog."default",
|
||||||
|
num_photo character varying(254) COLLATE pg_catalog."default",
|
||||||
|
nature_obs character varying(254) COLLATE pg_catalog."default",
|
||||||
|
date_sais date,
|
||||||
|
s_al_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
alli_name character varying(254) COLLATE pg_catalog."default",
|
||||||
|
salli_name character varying(254) COLLATE pg_catalog."default",
|
||||||
|
class_name character varying(254) COLLATE pg_catalog."default",
|
||||||
|
geom geometry(MultiLineString,2154)
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
champ_vegethab_multipolygon = """(
|
||||||
|
gid serial NOT NULL ,
|
||||||
|
cd_eu_01 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lb_eu_01 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
occupati_1 bigint,
|
||||||
|
cd_eu_02 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lb_eu_02 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
occupati_2 bigint,
|
||||||
|
cd_eu_03 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lb_eu_03 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
occupati_3 bigint,
|
||||||
|
milieu_cod character varying(254) COLLATE pg_catalog."default",
|
||||||
|
milieu_lib character varying(254) COLLATE pg_catalog."default",
|
||||||
|
surface_m2 numeric,
|
||||||
|
surface_ha numeric,
|
||||||
|
commentair character varying(254) COLLATE pg_catalog."default",
|
||||||
|
date_creat date,
|
||||||
|
date_maj date,
|
||||||
|
num_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
type_unite character varying(254) COLLATE pg_catalog."default",
|
||||||
|
dynamique character varying(254) COLLATE pg_catalog."default",
|
||||||
|
gestio_obs character varying(254) COLLATE pg_catalog."default",
|
||||||
|
degrad_obs character varying(254) COLLATE pg_catalog."default",
|
||||||
|
eta_conser character varying(254) COLLATE pg_catalog."default",
|
||||||
|
clas_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
alli_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
syntaxon character varying(254) COLLATE pg_catalog."default",
|
||||||
|
n2000 character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lrr_aura character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lrr_cbna character varying(254) COLLATE pg_catalog."default",
|
||||||
|
lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
|
||||||
|
vege_enjeu character varying(254) COLLATE pg_catalog."default",
|
||||||
|
num_photo character varying(254) COLLATE pg_catalog."default",
|
||||||
|
nature_obs character varying(254) COLLATE pg_catalog."default",
|
||||||
|
date_sais date,
|
||||||
|
s_al_phyto character varying(254) COLLATE pg_catalog."default",
|
||||||
|
alli_name character varying(254) COLLATE pg_catalog."default",
|
||||||
|
salli_name character varying(254) COLLATE pg_catalog."default",
|
||||||
|
class_name character varying(254) COLLATE pg_catalog."default",
|
||||||
|
geom geometry(MultiPolygon,2154)
|
||||||
|
)
|
||||||
|
"""
|
||||||
@ -3,9 +3,9 @@
|
|||||||
import configparser
|
import configparser
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
# import base64
|
import base64
|
||||||
# import psycopg2
|
import psycopg2
|
||||||
# import psycopg2.extras
|
import psycopg2.extras
|
||||||
import os
|
import os
|
||||||
from os.path import abspath, join, pardir, dirname
|
from os.path import abspath, join, pardir, dirname
|
||||||
|
|
||||||
@ -108,51 +108,46 @@ def load_ui(*args):
|
|||||||
|
|
||||||
return ui_class
|
return ui_class
|
||||||
|
|
||||||
|
|
||||||
def pyperclip():
|
def pyperclip():
|
||||||
dst = dirname(dirname(__file__))+"\\tools\\"
|
dst = dirname(dirname(__file__))+"\\tools\\"
|
||||||
if os.access('N:/',os.R_OK):
|
if os.access('N:/',os.R_OK):
|
||||||
src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
|
src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
|
||||||
try:
|
try:
|
||||||
shutil.copy(src, dst)
|
shutil.copy(src, dst)
|
||||||
except FileNotFoundError:
|
except:
|
||||||
print('404')
|
print('404')
|
||||||
except UnboundLocalError:
|
|
||||||
print('404')
|
|
||||||
|
|
||||||
|
|
||||||
def send_issues(url,titre,body,labels):
|
def send_issues(url,titre,body,labels):
|
||||||
import requests
|
import requests
|
||||||
import urllib.request
|
|
||||||
import json
|
import json
|
||||||
# import os
|
import os
|
||||||
# import qgis
|
import qgis
|
||||||
|
|
||||||
# usr = os.environ['USERNAME']
|
usr = os.environ['USERNAME']
|
||||||
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
|
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
|
||||||
url=url+'?token='+token
|
url=url+'?token='+token
|
||||||
|
|
||||||
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
|
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
|
||||||
|
|
||||||
|
|
||||||
payload = {'title': titre, 'body': body, 'labels': labels}
|
payload = {'title': titre, 'body': body, 'labels': labels}
|
||||||
try:
|
try:
|
||||||
urllib.request.urlopen('https://google.com')
|
urllib.request.urlopen('https://google.com')
|
||||||
binar = True
|
binar = True
|
||||||
except ValueError:
|
except:
|
||||||
binar = False
|
binar = False
|
||||||
r = ''
|
r = ''
|
||||||
if binar:
|
if binar:
|
||||||
r = requests.post(url, data=json.dumps(payload), headers=headers)
|
r = requests.post(url, data=json.dumps(payload), headers=headers)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def maj_verif(NAME):
|
def maj_verif(NAME):
|
||||||
import qgis
|
import qgis
|
||||||
import urllib.request
|
import urllib.request
|
||||||
iface = qgis.utils.iface
|
iface = qgis.utils.iface
|
||||||
from qgis.core import Qgis
|
from qgis.core import Qgis
|
||||||
|
|
||||||
# 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/latest/plugins.xml'
|
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
|
||||||
# print(URL)
|
# print(URL)
|
||||||
@ -161,7 +156,7 @@ def maj_verif(NAME):
|
|||||||
try:
|
try:
|
||||||
urllib.request.urlopen('https://google.com')
|
urllib.request.urlopen('https://google.com')
|
||||||
binar = True
|
binar = True
|
||||||
except urllib.error.URLError:
|
except:
|
||||||
binar = False
|
binar = False
|
||||||
if binar:
|
if binar:
|
||||||
try:
|
try:
|
||||||
@ -171,12 +166,11 @@ def maj_verif(NAME):
|
|||||||
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
|
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
|
||||||
if version_plugin != version:
|
if version_plugin != version:
|
||||||
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
|
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
|
||||||
except urllib.error.URLError:
|
except:
|
||||||
print("error gitea version ssl")
|
print("error gitea version ssl")
|
||||||
else:
|
else:
|
||||||
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
|
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
|
||||||
|
|
||||||
|
|
||||||
def devlog(NAME):
|
def devlog(NAME):
|
||||||
import qgis
|
import qgis
|
||||||
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
|
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
|
||||||
|
|||||||
@ -1,13 +1,35 @@
|
|||||||
import os
|
import os
|
||||||
# from qgis.gui import *
|
from qgis.gui import *
|
||||||
|
|
||||||
from qgis.core import QgsSettings
|
from qgis.core import (
|
||||||
from qgis.PyQt.QtWidgets import QDialog
|
NULL,
|
||||||
|
QgsApplication,
|
||||||
|
QgsDataSourceUri,
|
||||||
|
QgsProject,
|
||||||
|
QgsProviderConnectionException,
|
||||||
|
QgsProviderRegistry,
|
||||||
|
QgsRasterLayer,
|
||||||
|
QgsSettings,
|
||||||
|
QgsVectorLayer,
|
||||||
|
QgsGeometry,
|
||||||
|
)
|
||||||
|
from qgis.PyQt.QtWidgets import (
|
||||||
|
QDialog,
|
||||||
|
QAction,
|
||||||
|
QDockWidget,
|
||||||
|
QFileDialog,
|
||||||
|
QInputDialog,
|
||||||
|
QMenu,
|
||||||
|
QToolButton,
|
||||||
|
QTableWidget,
|
||||||
|
QTableWidgetItem,
|
||||||
|
)
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
|
|
||||||
|
|
||||||
from .tools.resources import (
|
from .tools.resources import (
|
||||||
load_ui,
|
load_ui,
|
||||||
|
# resources_path,
|
||||||
send_issues,
|
send_issues,
|
||||||
)
|
)
|
||||||
plugin_dir = os.path.dirname(__file__)
|
plugin_dir = os.path.dirname(__file__)
|
||||||
@ -60,11 +82,11 @@ class CenRa_Issues(QDialog, EDITOR_CLASS):
|
|||||||
else:
|
else:
|
||||||
code = 423
|
code = 423
|
||||||
if code == 201:
|
if code == 201:
|
||||||
iface.messageBar().pushMessage("Envoyer :", "Votre messages à bien été envoyer.", level=0, duration=20)
|
iface.messageBar().pushMessage("Envoyer :", "Votre messages à bien été envoyer.", level=Qgis.Success, duration=20)
|
||||||
self.close()
|
self.close()
|
||||||
elif code == 422:
|
elif code == 422:
|
||||||
iface.messageBar().pushMessage("Erreur :", "Erreur dans le contenu du messages.", level=2, duration=20)
|
iface.messageBar().pushMessage("Erreur :", "Erreur dans le contenu du messages.", level=Qgis.Critical, duration=20)
|
||||||
elif code == 423:
|
elif code == 423:
|
||||||
iface.messageBar().pushMessage("Erreur :", "Pas de sujet sélectionné.", level=2, duration=20)
|
iface.messageBar().pushMessage("Erreur :", "Pas de sujet sélectionné.", level=Qgis.Critical, duration=20)
|
||||||
elif code == 404:
|
elif code == 404:
|
||||||
iface.messageBar().pushMessage("Missing :", "Le serveur de messagerie est injoignable.", level=1, duration=20)
|
iface.messageBar().pushMessage("Missing :", "Le serveur de messagerie est injoignable.", level=Qgis.Warning, duration=20)
|
||||||
|
|||||||
@ -4,12 +4,13 @@ __email__ = "info@3liz.org"
|
|||||||
|
|
||||||
|
|
||||||
from qgis.core import QgsApplication
|
from qgis.core import QgsApplication
|
||||||
from qgis.PyQt.QtCore import Qt, QUrl, QSettings
|
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl
|
||||||
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
||||||
from qgis.PyQt.QtWidgets import QAction
|
from qgis.PyQt.QtWidgets import QAction, QMessageBox
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
import qgis
|
import qgis
|
||||||
|
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
'''
|
'''
|
||||||
from pg_metadata.connection_manager import (
|
from pg_metadata.connection_manager import (
|
||||||
@ -23,9 +24,8 @@ from pg_metadata.processing.provider import PgMetadataProvider
|
|||||||
from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger
|
from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger
|
||||||
'''
|
'''
|
||||||
import os
|
import os
|
||||||
from .about_form import MetabaseAboutDialog
|
|
||||||
from .tools.resources import (
|
from .tools.resources import (
|
||||||
# plugin_path,
|
plugin_path,
|
||||||
pyperclip,
|
pyperclip,
|
||||||
resources_path,
|
resources_path,
|
||||||
maj_verif,
|
maj_verif,
|
||||||
@ -33,9 +33,11 @@ from .tools.resources import (
|
|||||||
pyperclip()
|
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 CenRa_Metabase.issues import CenRa_Issues
|
#from CenRa_Metabase.issues import CenRa_Issues
|
||||||
|
|
||||||
|
from qgis.PyQt.QtCore import *
|
||||||
|
|
||||||
|
|
||||||
class PgMetadata:
|
class PgMetadata:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -98,6 +100,7 @@ class PgMetadata:
|
|||||||
if not self.editor:
|
if not self.editor:
|
||||||
self.editor = Metabase_Editor()
|
self.editor = Metabase_Editor()
|
||||||
|
|
||||||
|
|
||||||
self.editor_action = QAction(icon2, 'CenRa_Metabase',None)
|
self.editor_action = QAction(icon2, 'CenRa_Metabase',None)
|
||||||
self.toolBar.addAction(self.editor_action)
|
self.toolBar.addAction(self.editor_action)
|
||||||
self.editor_action.triggered.connect(self.open_editor)
|
self.editor_action.triggered.connect(self.open_editor)
|
||||||
@ -156,7 +159,6 @@ class PgMetadata:
|
|||||||
"""
|
"""
|
||||||
dialog = MetabaseAboutDialog(iface)
|
dialog = MetabaseAboutDialog(iface)
|
||||||
dialog.exec()
|
dialog.exec()
|
||||||
|
|
||||||
def open_help():
|
def open_help():
|
||||||
""" Open the online help. """
|
""" Open the online help. """
|
||||||
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
|
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
|
||||||
@ -200,6 +202,7 @@ class PgMetadata:
|
|||||||
iface.pluginMenu().removeAction(self.dock_action)
|
iface.pluginMenu().removeAction(self.dock_action)
|
||||||
del self.dock_action
|
del self.dock_action
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run_tests(pattern='test_*.py', package=None):
|
def run_tests(pattern='test_*.py', package=None):
|
||||||
"""Run the test inside QGIS."""
|
"""Run the test inside QGIS."""
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import os.path
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from qgis.PyQt import uic
|
from qgis.PyQt import uic
|
||||||
# from qgis.PyQt.QtGui import QPixmap
|
from qgis.PyQt.QtGui import QPixmap
|
||||||
from qgis.PyQt.QtWidgets import QDialog
|
from qgis.PyQt.QtWidgets import QDialog
|
||||||
|
|
||||||
from .tools.resources import devlog
|
from .tools.resources import devlog
|
||||||
@ -16,7 +16,6 @@ ABOUT_FORM_CLASS, _ = uic.loadUiType(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MetabaseAboutDialog(QDialog, ABOUT_FORM_CLASS):
|
class MetabaseAboutDialog(QDialog, ABOUT_FORM_CLASS):
|
||||||
|
|
||||||
""" About - Let the user display the about dialog. """
|
""" About - Let the user display the about dialog. """
|
||||||
|
|||||||
@ -14,31 +14,48 @@ from pathlib import Path
|
|||||||
from xml.dom.minidom import parseString
|
from xml.dom.minidom import parseString
|
||||||
|
|
||||||
from qgis.core import (
|
from qgis.core import (
|
||||||
|
NULL,
|
||||||
QgsApplication,
|
QgsApplication,
|
||||||
|
QgsDataSourceUri,
|
||||||
|
QgsProject,
|
||||||
|
QgsProviderConnectionException,
|
||||||
QgsProviderRegistry,
|
QgsProviderRegistry,
|
||||||
|
QgsRasterLayer,
|
||||||
QgsSettings,
|
QgsSettings,
|
||||||
|
QgsVectorLayer,
|
||||||
)
|
)
|
||||||
from qgis.PyQt.QtCore import QLocale, QUrl
|
from qgis.PyQt.QtCore import QLocale, QUrl
|
||||||
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
||||||
from qgis.PyQt.QtPrintSupport import QPrinter
|
from qgis.PyQt.QtPrintSupport import QPrinter
|
||||||
#from qgis.PyQt.QtWebKitWidgets import QWebPage
|
#from qgis.PyQt.QtWebKitWidgets import QWebPage
|
||||||
from qgis.PyQt.QtWidgets import (
|
from qgis.PyQt.QtWidgets import (
|
||||||
|
QDialog,
|
||||||
QAction,
|
QAction,
|
||||||
QDockWidget,
|
QDockWidget,
|
||||||
QFileDialog,
|
QFileDialog,
|
||||||
|
QInputDialog,
|
||||||
QMenu,
|
QMenu,
|
||||||
QToolButton,
|
QToolButton,
|
||||||
)
|
)
|
||||||
|
from qgis.gui import *
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
import qgis
|
import qgis
|
||||||
|
'''
|
||||||
|
from pg_metadata.connection_manager import (
|
||||||
|
check_pgmetadata_is_installed,
|
||||||
|
connections_list,
|
||||||
|
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,
|
||||||
)
|
)
|
||||||
try:
|
|
||||||
from .tools.PythonSQL import login_base
|
|
||||||
except ValueError:
|
|
||||||
print('Pas de fichier PythonSQL')
|
|
||||||
|
|
||||||
DOCK_CLASS = load_ui('CenRa_Metabase_dockwidget_base.ui')
|
DOCK_CLASS = load_ui('CenRa_Metabase_dockwidget_base.ui')
|
||||||
LOGGER = logging.getLogger('CenRa_Metabase')
|
LOGGER = logging.getLogger('CenRa_Metabase')
|
||||||
@ -133,11 +150,11 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
|||||||
#self.default_html_content_not_installed()
|
#self.default_html_content_not_installed()
|
||||||
#else:
|
#else:
|
||||||
self.default_html_content_not_pg_layer()
|
self.default_html_content_not_pg_layer()
|
||||||
iface.layerTreeView().currentLayerChanged.connect(self.layer_changed)
|
|
||||||
try:
|
try:
|
||||||
login_base()
|
login_base()
|
||||||
iface.layerTreeView().currentLayerChanged.connect(self.layer_changed)
|
iface.layerTreeView().currentLayerChanged.connect(self.layer_changed)
|
||||||
except ValueError:
|
except:
|
||||||
#qgis.utils.plugins['CenRa_METABASE'].initGui()
|
#qgis.utils.plugins['CenRa_METABASE'].initGui()
|
||||||
qgis.utils.plugins['CenRa_METABASE'].unload()
|
qgis.utils.plugins['CenRa_METABASE'].unload()
|
||||||
#self.default_html_content_not_pg_layer()
|
#self.default_html_content_not_pg_layer()
|
||||||
@ -214,15 +231,43 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
|||||||
def save_auto_open_dock(self):
|
def save_auto_open_dock(self):
|
||||||
""" Save settings about the dock. """
|
""" Save settings about the dock. """
|
||||||
self.settings.setValue("pgmetadata/auto_open_dock", self.auto_open_dock_action.isChecked())
|
self.settings.setValue("pgmetadata/auto_open_dock", self.auto_open_dock_action.isChecked())
|
||||||
|
|
||||||
def sql_to_xml(self,dataall):
|
def sql_to_xml(self,dataall):
|
||||||
distribution=''
|
distribution=''
|
||||||
for y in dataall[1]:
|
for y in dataall[1]:
|
||||||
distribution = distribution + ('<dcat:distribution>' + '<dcat:Distribution>' + '<dct:title>{data}</dct:title>'.format(data=y[0]) + '<dcat:downloadURL>{data}</dcat:downloadURL>'.format(data=y[1]) + '<dcat:mediaType>{data}</dcat:mediaType>'.format(data=y[2]) + '<dct:format>{data}</dct:format>'.format(data=y[3]) + '<dct:bytesize>{data}</dct:bytesize>'.format(data=y[4]) + '</dcat:Distribution>' + '</dcat:distribution>')
|
distribution = distribution + (
|
||||||
|
'<dcat:distribution>'+
|
||||||
|
'<dcat:Distribution>'+
|
||||||
|
'<dct:title>{data}</dct:title>'.format(data=y[0])+
|
||||||
|
'<dcat:downloadURL>{data}</dcat:downloadURL>'.format(data=y[1])+
|
||||||
|
'<dcat:mediaType>{data}</dcat:mediaType>'.format(data=y[2])+
|
||||||
|
'<dct:format>{data}</dct:format>'.format(data=y[3])+
|
||||||
|
'<dct:bytesize>{data}</dct:bytesize>'.format(data=y[4])+
|
||||||
|
'</dcat:Distribution>'+
|
||||||
|
'</dcat:distribution>')
|
||||||
publisher=''
|
publisher=''
|
||||||
for z in dataall[2]:
|
for z in dataall[2]:
|
||||||
publisher = publisher + ('<dct:publisher>' + '<foaf:Organization>' + '<foaf:name>{data}</foaf:name>'.format(data=z[1]) + '<foaf:mbox>{data}</foaf:mbox>'.format(data=z[3]) + '</foaf:Organization>' + '</dct:publisher>')
|
publisher = publisher + (
|
||||||
data_str = [[dataall[0][26], '<dct:identifier>{data}</dct:identifier>'.format(data=dataall[0][1]) + '<dct:title>{data}</dct:title>'.format(data=dataall[0][4]) + '<dct:description>{data}</dct:description>'.format(data=dataall[0][5]) + '<dct:language>{data}</dct:language>'.format(data=dataall[0][26]) + '<dct:spatial>{data}</dct:spatial>'.format(data=dataall[0][28]) + '<dct:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:created>'.format(data=dataall[0][20]) + '<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:issued>'.format(data=dataall[0][11]) + '<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:modified>'.format(data=dataall[0][21]) + '<dct:license>{data}</dct:license>'.format(data=dataall[0][13]) + distribution + publisher + '<dcat:theme>{data}</dcat:theme>'.format(data=", ".join(str(x) for x in dataall[0][24])) + '<dcat:keyword>{data}</dcat:keyword>'.format(data=", ".join(str(x) for x in dataall[0][6])) + '<dct:accrualPeriodicity>{data}</dct:accrualPeriodicity>'.format(data=dataall[0][12])]]
|
'<dct:publisher>'+
|
||||||
|
'<foaf:Organization>'+
|
||||||
|
'<foaf:name>{data}</foaf:name>'.format(data=z[1])+
|
||||||
|
'<foaf:mbox>{data}</foaf:mbox>'.format(data=z[3])+
|
||||||
|
'</foaf:Organization>'+
|
||||||
|
'</dct:publisher>')
|
||||||
|
data_str = [[dataall[0][26],
|
||||||
|
'<dct:identifier>{data}</dct:identifier>'.format(data=dataall[0][1])+
|
||||||
|
'<dct:title>{data}</dct:title>'.format(data=dataall[0][4])+
|
||||||
|
'<dct:description>{data}</dct:description>'.format(data=dataall[0][5])+
|
||||||
|
'<dct:language>{data}</dct:language>'.format(data=dataall[0][26])+
|
||||||
|
'<dct:spatial>{data}</dct:spatial>'.format(data=dataall[0][28])+
|
||||||
|
'<dct:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:created>'.format(data=dataall[0][20])+
|
||||||
|
'<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:issued>'.format(data=dataall[0][11])+
|
||||||
|
'<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:modified>'.format(data=dataall[0][21])+
|
||||||
|
'<dct:license>{data}</dct:license>'.format(data=dataall[0][13])+
|
||||||
|
distribution+
|
||||||
|
publisher+
|
||||||
|
'<dcat:theme>{data}</dcat:theme>'.format(data=", ".join(str(x) for x in dataall[0][24]))+
|
||||||
|
'<dcat:keyword>{data}</dcat:keyword>'.format(data=", ".join(str(x) for x in dataall[0][6]))+
|
||||||
|
'<dct:accrualPeriodicity>{data}</dct:accrualPeriodicity>'.format(data=dataall[0][12])]]
|
||||||
|
|
||||||
return data_str
|
return data_str
|
||||||
|
|
||||||
@ -247,6 +292,7 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
|||||||
self.current_connection = None
|
self.current_connection = None
|
||||||
self.ce_trouve_dans_psql(layer)
|
self.ce_trouve_dans_psql(layer)
|
||||||
|
|
||||||
|
|
||||||
def add_flatten_dataset_table(self):
|
def add_flatten_dataset_table(self):
|
||||||
""" Add a flatten dataset table with all links and contacts. """
|
""" Add a flatten dataset table with all links and contacts. """
|
||||||
'''
|
'''
|
||||||
@ -291,7 +337,7 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
|||||||
|
|
||||||
def set_html_content(self, title=None, body=None):
|
def set_html_content(self, title=None, body=None):
|
||||||
""" Set the content in the dock. """
|
""" Set the content in the dock. """
|
||||||
# ink_logo=resources_path('icons', 'CEN_RA.png')
|
#link_logo=resources_path('icons', 'CEN_RA.png')
|
||||||
css_file = resources_path('css', 'dock.css')
|
css_file = resources_path('css', 'dock.css')
|
||||||
with open(css_file, 'r', encoding='utf8') as f:
|
with open(css_file, 'r', encoding='utf8') as f:
|
||||||
css = f.read()
|
css = f.read()
|
||||||
@ -310,13 +356,13 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
|||||||
html += '</body></html>'
|
html += '</body></html>'
|
||||||
|
|
||||||
# It must be a file, even if it does not exist on the file system.
|
# It must be a file, even if it does not exist on the file system.
|
||||||
# base_url = QUrl.fromLocalFile(resources_path('images', 'must_be_a_file.png'))
|
base_url = QUrl.fromLocalFile(resources_path('images', 'must_be_a_file.png'))
|
||||||
self.viewer.setHtml(html)
|
self.viewer.setHtml(html)#, base_url)
|
||||||
|
|
||||||
def ce_trouve_dans_psql(self,layer):
|
def ce_trouve_dans_psql(self,layer):
|
||||||
try:
|
try:
|
||||||
uri = layer.dataProvider().uri()
|
uri = layer.dataProvider().uri()
|
||||||
except AttributeError:
|
except:
|
||||||
self.default_html_content_not_pg_layer()
|
self.default_html_content_not_pg_layer()
|
||||||
self.save_button.setEnabled(False)
|
self.save_button.setEnabled(False)
|
||||||
uri=''
|
uri=''
|
||||||
@ -346,7 +392,7 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
|||||||
data_url=dataall[1]
|
data_url=dataall[1]
|
||||||
data_contact=dataall[2]
|
data_contact=dataall[2]
|
||||||
#print(len(data_url))
|
#print(len(data_url))
|
||||||
# data_collonne = [field.name() for field in layer.dataProvider().fields()]
|
data_collonne=[field.name() for field in layer.dataProvider().fields()]
|
||||||
|
|
||||||
body += '<div><h3>Identification</h3><table class="table table-condensed">'
|
body += '<div><h3>Identification</h3><table class="table table-condensed">'
|
||||||
body += '<tr><th>Titre</th><td>{data[4]}</td></tr>'.format(data=data)
|
body += '<tr><th>Titre</th><td>{data[4]}</td></tr>'.format(data=data)
|
||||||
@ -411,12 +457,10 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
|||||||
def set_html_to_wms(self,layer):
|
def set_html_to_wms(self,layer):
|
||||||
self.set_html_content(
|
self.set_html_content(
|
||||||
'CenRa Metadata',(layer.htmlMetadata()))
|
'CenRa Metadata',(layer.htmlMetadata()))
|
||||||
|
|
||||||
def default_html_content_not_pg_layer(self):
|
def default_html_content_not_pg_layer(self):
|
||||||
""" When it's not a PostgreSQL layer. """
|
""" When it's not a PostgreSQL layer. """
|
||||||
self.set_html_content(
|
self.set_html_content(
|
||||||
'CenRa Metadata', ('Vous devez cliquer sur une couche dans la légende qui est stockée dans PostgreSQL.'))
|
'CenRa Metadata', ('Vous devez cliquer sur une couche dans la légende qui est stockée dans PostgreSQL.'))
|
||||||
|
|
||||||
def default_html_content_not_metadata(self):
|
def default_html_content_not_metadata(self):
|
||||||
self.set_html_content(
|
self.set_html_content(
|
||||||
'CenRa Metadata', ('La couche ne contien pas de métadonnée.'))
|
'CenRa Metadata', ('La couche ne contien pas de métadonnée.'))
|
||||||
@ -451,3 +495,4 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
|
|||||||
data_contact = cur.fetchall()
|
data_contact = cur.fetchall()
|
||||||
cur.close()
|
cur.close()
|
||||||
return data_general[0],data_url,data_contact
|
return data_general[0],data_url,data_contact
|
||||||
|
|
||||||
|
|||||||
@ -1,47 +1,60 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# from collections import namedtuple
|
from collections import namedtuple
|
||||||
# from enum import Enum
|
from enum import Enum
|
||||||
# from functools import partial
|
from functools import partial
|
||||||
# from pathlib import Path
|
from pathlib import Path
|
||||||
# from xml.dom.minidom import parseString
|
from xml.dom.minidom import parseString
|
||||||
# from qgis.gui import *
|
from qgis.gui import *
|
||||||
from qgis.core import (
|
from qgis.core import (
|
||||||
|
NULL,
|
||||||
QgsApplication,
|
QgsApplication,
|
||||||
|
QgsDataSourceUri,
|
||||||
|
QgsProject,
|
||||||
|
QgsProviderConnectionException,
|
||||||
|
QgsProviderRegistry,
|
||||||
|
QgsRasterLayer,
|
||||||
QgsSettings,
|
QgsSettings,
|
||||||
|
QgsVectorLayer,
|
||||||
QgsGeometry,
|
QgsGeometry,
|
||||||
QgsWkbTypes,
|
QgsWkbTypes,
|
||||||
)
|
)
|
||||||
from qgis.PyQt import QtGui, QtCore
|
from qgis.PyQt import QtGui
|
||||||
from qgis.PyQt.QtGui import QIcon
|
from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime
|
||||||
# from qgis.PyQt.QtPrintSupport import QPrinter
|
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
||||||
|
from qgis.PyQt.QtPrintSupport import QPrinter
|
||||||
#from qgis.PyQt.QtWebKitWidgets import QWebPage
|
#from qgis.PyQt.QtWebKitWidgets import QWebPage
|
||||||
import psycopg2
|
|
||||||
from qgis.PyQt.QtWidgets import (
|
from qgis.PyQt.QtWidgets import (
|
||||||
QDialog,
|
QDialog,
|
||||||
|
QAction,
|
||||||
|
QDockWidget,
|
||||||
QFileDialog,
|
QFileDialog,
|
||||||
|
QInputDialog,
|
||||||
|
QMenu,
|
||||||
|
QToolButton,
|
||||||
|
QTableWidget,
|
||||||
QTableWidgetItem,
|
QTableWidgetItem,
|
||||||
)
|
)
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from .tools.PythonSQL import login_base
|
from .tools.PythonSQL import login_base
|
||||||
except ValueError:
|
except:
|
||||||
print('Pas de fichier PythonSQL')
|
print('Pas de fichier PythonSQL')
|
||||||
|
|
||||||
from .tools.resources import (
|
from .tools.resources import (
|
||||||
load_ui,
|
load_ui,
|
||||||
resources_path,
|
resources_path,
|
||||||
# send_issues,
|
send_issues,
|
||||||
)
|
)
|
||||||
# from .issues import CenRa_Issues
|
from .issues import CenRa_Issues
|
||||||
|
|
||||||
EDITOR_CLASS = load_ui('CenRa_Metabase_editorwidget_base.ui')
|
EDITOR_CLASS = load_ui('CenRa_Metabase_editorwidget_base.ui')
|
||||||
LOGGEr = logging.getLogger('CenRa_Metabase')
|
LOGGER = logging.getLogger('CenRa_Metabase')
|
||||||
|
|
||||||
|
|
||||||
class Metabase_Editor(QDialog, EDITOR_CLASS):
|
class Metabase_Editor(QDialog, EDITOR_CLASS):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
_ = parent
|
_ = parent
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -61,7 +74,7 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.auto_adding.show()
|
self.auto_adding.show()
|
||||||
|
|
||||||
self.auto_adding.clicked.connect(self.auto_run)
|
self.auto_adding.clicked.connect(self.auto_run)
|
||||||
# self.issues_app.clicked.connect(self.issues_open)
|
self.issues_app.clicked.connect(self.issues_open)
|
||||||
self.categories_select_view.itemDoubleClicked.connect(self.add_categories_view)
|
self.categories_select_view.itemDoubleClicked.connect(self.add_categories_view)
|
||||||
self.categories_view.itemDoubleClicked.connect(self.deleter_categories_view)
|
self.categories_view.itemDoubleClicked.connect(self.deleter_categories_view)
|
||||||
self.themes_select_view.itemDoubleClicked.connect(self.add_themes_view)
|
self.themes_select_view.itemDoubleClicked.connect(self.add_themes_view)
|
||||||
@ -89,7 +102,6 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.format_box.setCurrentIndex(0)
|
self.format_box.setCurrentIndex(0)
|
||||||
self.taille_line.setText('45')
|
self.taille_line.setText('45')
|
||||||
self.add_lien()
|
self.add_lien()
|
||||||
|
|
||||||
def add_metadata(self):
|
def add_metadata(self):
|
||||||
table_name = layer.dataProvider().uri().table()
|
table_name = layer.dataProvider().uri().table()
|
||||||
schema_name = layer.dataProvider().uri().schema()
|
schema_name = layer.dataProvider().uri().schema()
|
||||||
@ -238,12 +250,12 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.new_data(layer)
|
self.new_data(layer)
|
||||||
else:
|
else:
|
||||||
self.close()
|
self.close()
|
||||||
iface.messageBar().pushMessage("Information:", "Cette couche n'est pas stockée dans PostgreSQL", level=1, duration=30)
|
iface.messageBar().pushMessage("Information :", "Cette couche n'est pas stockée dans PostgreSQL", level=Qgis.Warning, duration=30)
|
||||||
|
|
||||||
def is_in_psql(self,layer):
|
def is_in_psql(self,layer):
|
||||||
try:
|
try:
|
||||||
uri = layer.dataProvider().uri()
|
uri = layer.dataProvider().uri()
|
||||||
except AttributeError:
|
except:
|
||||||
uri=''
|
uri=''
|
||||||
return False
|
return False
|
||||||
if uri != '':
|
if uri != '':
|
||||||
@ -312,6 +324,7 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
role_list=all_list[10]
|
role_list=all_list[10]
|
||||||
organisation_list=all_list[11]
|
organisation_list=all_list[11]
|
||||||
|
|
||||||
|
|
||||||
#langue_box
|
#langue_box
|
||||||
self.langue_box.clear()
|
self.langue_box.clear()
|
||||||
self.langue_box.addItem('')
|
self.langue_box.addItem('')
|
||||||
@ -379,6 +392,7 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
crs_code = str(layer.crs().authid())
|
crs_code = str(layer.crs().authid())
|
||||||
self.crscode_plaintext.setPlainText(crs_code)
|
self.crscode_plaintext.setPlainText(crs_code)
|
||||||
|
|
||||||
|
|
||||||
self.frequence_box.addItem('')
|
self.frequence_box.addItem('')
|
||||||
self.restriction_box.addItem('')
|
self.restriction_box.addItem('')
|
||||||
self.licence_box.addItem('')
|
self.licence_box.addItem('')
|
||||||
@ -447,7 +461,7 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
try:
|
try:
|
||||||
in_index = sql_dataload[6].index(categorie_select_data[0])
|
in_index = sql_dataload[6].index(categorie_select_data[0])
|
||||||
in_index=False
|
in_index=False
|
||||||
except ValueError:
|
except:
|
||||||
in_index=True
|
in_index=True
|
||||||
if in_index:
|
if in_index:
|
||||||
self.categories_select_view.setItem(i,0,QTableWidgetItem(categorie_select_data[0]))
|
self.categories_select_view.setItem(i,0,QTableWidgetItem(categorie_select_data[0]))
|
||||||
@ -457,7 +471,7 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
try:
|
try:
|
||||||
in_index = sql_dataload[24].index(themes_select_data[0])
|
in_index = sql_dataload[24].index(themes_select_data[0])
|
||||||
in_index=False
|
in_index=False
|
||||||
except ValueError:
|
except:
|
||||||
in_index=True
|
in_index=True
|
||||||
if in_index:
|
if in_index:
|
||||||
self.themes_select_view.setItem(i,0,QTableWidgetItem(themes_select_data[0]))
|
self.themes_select_view.setItem(i,0,QTableWidgetItem(themes_select_data[0]))
|
||||||
@ -572,7 +586,6 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.categories_select_view.removeRow(self.categories_select_view.currentRow())
|
self.categories_select_view.removeRow(self.categories_select_view.currentRow())
|
||||||
self.categories_view.insertRow(0)
|
self.categories_view.insertRow(0)
|
||||||
self.categories_view.setItem(0,0,QTableWidgetItem(values_add_categories))
|
self.categories_view.setItem(0,0,QTableWidgetItem(values_add_categories))
|
||||||
|
|
||||||
def deleter_categories_view(self):
|
def deleter_categories_view(self):
|
||||||
values_deleter_categories = self.categories_view.selectedItems()[0].text()
|
values_deleter_categories = self.categories_view.selectedItems()[0].text()
|
||||||
self.categories_view.removeRow(self.categories_view.currentRow())
|
self.categories_view.removeRow(self.categories_view.currentRow())
|
||||||
@ -584,7 +597,6 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.themes_select_view.removeRow(self.themes_select_view.currentRow())
|
self.themes_select_view.removeRow(self.themes_select_view.currentRow())
|
||||||
self.themes_view.insertRow(0)
|
self.themes_view.insertRow(0)
|
||||||
self.themes_view.setItem(0,0,QTableWidgetItem(values_add_themes))
|
self.themes_view.setItem(0,0,QTableWidgetItem(values_add_themes))
|
||||||
|
|
||||||
def deleter_themes_view(self):
|
def deleter_themes_view(self):
|
||||||
values_deleter_themes = self.themes_view.selectedItems()[0].text()
|
values_deleter_themes = self.themes_view.selectedItems()[0].text()
|
||||||
self.themes_view.removeRow(self.themes_view.currentRow())
|
self.themes_view.removeRow(self.themes_view.currentRow())
|
||||||
@ -605,10 +617,10 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
cur.execute(sql_sizefile)
|
cur.execute(sql_sizefile)
|
||||||
boolean = True
|
boolean = True
|
||||||
|
|
||||||
except psycopg2.errors.UndefinedTable:
|
except:
|
||||||
boolean = False
|
boolean = False
|
||||||
|
|
||||||
if boolean is True:
|
if boolean == True:
|
||||||
size_file = (cur.fetchall())[0][0]
|
size_file = (cur.fetchall())[0][0]
|
||||||
else:
|
else:
|
||||||
size_file = ''
|
size_file = ''
|
||||||
@ -646,12 +658,9 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
array_contact += "('"+ table +"','"+ schema +"','"+ self.role_box.currentText() +"','"+ self.nom_line.text() +"','"+ self.organisation_box.currentText() +"','"+ self.email_line.text() +"','"+ self.telephone_line.text() +"'),"
|
array_contact += "('"+ table +"','"+ schema +"','"+ self.role_box.currentText() +"','"+ self.nom_line.text() +"','"+ self.organisation_box.currentText() +"','"+ self.email_line.text() +"','"+ self.telephone_line.text() +"'),"
|
||||||
|
|
||||||
def delete_lien(self):
|
def delete_lien(self):
|
||||||
fin = ''
|
|
||||||
global uid_delete_list_link,array_link
|
global uid_delete_list_link,array_link
|
||||||
try:
|
|
||||||
lien_uid = self.table_lien.item(self.table_lien.currentRow(),0).text()
|
lien_uid = self.table_lien.item(self.table_lien.currentRow(),0).text()
|
||||||
except AttributeError:
|
|
||||||
lien_uid = True
|
|
||||||
self.table_lien.removeRow(self.table_lien.currentRow())
|
self.table_lien.removeRow(self.table_lien.currentRow())
|
||||||
if lien_uid == 'new_value':
|
if lien_uid == 'new_value':
|
||||||
position = self.table_lien.currentRow()
|
position = self.table_lien.currentRow()
|
||||||
@ -675,18 +684,12 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
fin+= 1
|
fin+= 1
|
||||||
array_link = array_link[:debut-1]+array_link[fin+1:]
|
array_link = array_link[:debut-1]+array_link[fin+1:]
|
||||||
#print('a:',array_link)
|
#print('a:',array_link)
|
||||||
elif lien_uid is True:
|
|
||||||
print('Pas de ligne "Lien"')
|
|
||||||
else:
|
else:
|
||||||
uid_delete_list_link += "'"+lien_uid+"',"
|
uid_delete_list_link += "'"+lien_uid+"',"
|
||||||
|
|
||||||
def delete_contact(self):
|
def delete_contact(self):
|
||||||
fin = ''
|
|
||||||
global uid_delete_list_contact,array_contact
|
global uid_delete_list_contact,array_contact
|
||||||
try:
|
|
||||||
contact_uid = self.table_contact.item(self.table_contact.currentRow(),0).text()
|
contact_uid = self.table_contact.item(self.table_contact.currentRow(),0).text()
|
||||||
except AttributeError:
|
|
||||||
contact_uid = True
|
|
||||||
self.table_contact.removeRow(self.table_contact.currentRow())
|
self.table_contact.removeRow(self.table_contact.currentRow())
|
||||||
if contact_uid == 'new_value':
|
if contact_uid == 'new_value':
|
||||||
position = self.table_contact.currentRow()
|
position = self.table_contact.currentRow()
|
||||||
@ -710,11 +713,10 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
fin+= 1
|
fin+= 1
|
||||||
array_contact = array_contact[:debut-1]+array_contact[fin+1:]
|
array_contact = array_contact[:debut-1]+array_contact[fin+1:]
|
||||||
#print('a:',array_contact)
|
#print('a:',array_contact)
|
||||||
elif contact_uid is True:
|
|
||||||
print('Pas de ligne "Contact"')
|
|
||||||
else:
|
else:
|
||||||
uid_delete_list_contact += "'"+contact_uid+"',"
|
uid_delete_list_contact += "'"+contact_uid+"',"
|
||||||
|
|
||||||
|
|
||||||
def fletch_ref(self):
|
def fletch_ref(self):
|
||||||
cur=login_base()
|
cur=login_base()
|
||||||
|
|
||||||
@ -768,7 +770,6 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
folder=folder[0]
|
folder=folder[0]
|
||||||
if folder[len(folder)-4:] == '.xml' :
|
if folder[len(folder)-4:] == '.xml' :
|
||||||
print('is .xml')
|
print('is .xml')
|
||||||
|
def issues_open(self):
|
||||||
# def issues_open(self):
|
self.issues = CenRa_Issues()
|
||||||
# self.issues = CenRa_Issues()
|
self.issues.show()
|
||||||
# self.issues.show()
|
|
||||||
|
|||||||
@ -3,12 +3,9 @@
|
|||||||
import configparser
|
import configparser
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
# import base64
|
|
||||||
# import psycopg2
|
|
||||||
# import psycopg2.extras
|
|
||||||
import os
|
import os
|
||||||
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 import uic
|
from qgis.PyQt import uic
|
||||||
|
|
||||||
__copyright__ = "Copyright 2019, 3Liz"
|
__copyright__ = "Copyright 2019, 3Liz"
|
||||||
@ -95,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.
|
||||||
@ -108,51 +113,37 @@ def load_ui(*args):
|
|||||||
|
|
||||||
return ui_class
|
return ui_class
|
||||||
|
|
||||||
|
|
||||||
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 FileNotFoundError:
|
|
||||||
print('404')
|
|
||||||
except UnboundLocalError:
|
|
||||||
print('404')
|
|
||||||
|
|
||||||
|
|
||||||
def send_issues(url,titre,body,labels):
|
def send_issues(url,titre,body,labels):
|
||||||
import requests
|
import requests
|
||||||
import urllib.request
|
|
||||||
import json
|
import json
|
||||||
# import os
|
import os
|
||||||
# import qgis
|
import qgis
|
||||||
|
|
||||||
# usr = os.environ['USERNAME']
|
usr = os.environ['USERNAME']
|
||||||
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
|
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
|
||||||
url=url+'?token='+token
|
url=url+'?token='+token
|
||||||
|
|
||||||
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
|
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
|
||||||
|
|
||||||
|
|
||||||
payload = {'title': titre, 'body': body, 'labels': labels}
|
payload = {'title': titre, 'body': body, 'labels': labels}
|
||||||
try:
|
try:
|
||||||
urllib.request.urlopen('https://google.com')
|
urllib.request.urlopen('https://google.com')
|
||||||
binar = True
|
binar = True
|
||||||
except ValueError:
|
except:
|
||||||
binar = False
|
binar = False
|
||||||
r = ''
|
r = ''
|
||||||
if binar:
|
if binar:
|
||||||
r = requests.post(url, data=json.dumps(payload), headers=headers)
|
r = requests.post(url, data=json.dumps(payload), headers=headers)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def maj_verif(NAME):
|
def maj_verif(NAME):
|
||||||
import qgis
|
import qgis
|
||||||
import urllib.request
|
import urllib.request
|
||||||
iface = qgis.utils.iface
|
iface = qgis.utils.iface
|
||||||
from qgis.core import Qgis
|
from qgis.core import Qgis
|
||||||
|
|
||||||
# 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/latest/plugins.xml'
|
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
|
||||||
# print(URL)
|
# print(URL)
|
||||||
@ -161,7 +152,7 @@ def maj_verif(NAME):
|
|||||||
try:
|
try:
|
||||||
urllib.request.urlopen('https://google.com')
|
urllib.request.urlopen('https://google.com')
|
||||||
binar = True
|
binar = True
|
||||||
except urllib.error.URLError:
|
except:
|
||||||
binar = False
|
binar = False
|
||||||
if binar:
|
if binar:
|
||||||
try:
|
try:
|
||||||
@ -171,11 +162,13 @@ def maj_verif(NAME):
|
|||||||
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
|
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
|
||||||
if version_plugin != version:
|
if version_plugin != version:
|
||||||
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
|
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
|
||||||
except urllib.error.URLError:
|
except:
|
||||||
print("error gitea version ssl")
|
print("error gitea version ssl")
|
||||||
else:
|
else:
|
||||||
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
|
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
|
||||||
|
|
||||||
|
def tr(text, context="@default"):
|
||||||
|
return QApplication.translate(context, text)
|
||||||
|
|
||||||
def devlog(NAME):
|
def devlog(NAME):
|
||||||
import qgis
|
import qgis
|
||||||
|
|||||||
@ -4,9 +4,9 @@ __email__ = "info@3liz.org"
|
|||||||
|
|
||||||
|
|
||||||
from qgis.core import QgsApplication
|
from qgis.core import QgsApplication
|
||||||
from qgis.PyQt.QtCore import QUrl, QSettings
|
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl
|
||||||
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
||||||
from qgis.PyQt.QtWidgets import QAction
|
from qgis.PyQt.QtWidgets import QAction, QMessageBox
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
import qgis
|
import qgis
|
||||||
|
|
||||||
@ -25,13 +25,15 @@ 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,
|
||||||
resources_path,
|
resources_path,
|
||||||
maj_verif,
|
maj_verif,
|
||||||
)
|
)
|
||||||
from .canvas_editor import PageRender_Editor
|
from .canvas_editor import PageRender_Editor
|
||||||
from .about_form import AboutDialog
|
from .about_form import AboutDialog
|
||||||
|
|
||||||
|
from qgis.PyQt.QtCore import *
|
||||||
|
|
||||||
|
|
||||||
class PgPageRender:
|
class PgPageRender:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -72,6 +74,7 @@ class PgPageRender:
|
|||||||
if not self.canvas_editor:
|
if not self.canvas_editor:
|
||||||
self.canvas_editor = PageRender_Editor()
|
self.canvas_editor = PageRender_Editor()
|
||||||
|
|
||||||
|
|
||||||
self.pagerender_action = QAction(icon, 'CenRa_PAGERENDER',None)
|
self.pagerender_action = QAction(icon, 'CenRa_PAGERENDER',None)
|
||||||
self.toolBar.addAction(self.pagerender_action)
|
self.toolBar.addAction(self.pagerender_action)
|
||||||
self.pagerender_action.triggered.connect(self.open_editor)
|
self.pagerender_action.triggered.connect(self.open_editor)
|
||||||
@ -114,7 +117,6 @@ class PgPageRender:
|
|||||||
"""
|
"""
|
||||||
dialog = AboutDialog(iface)
|
dialog = AboutDialog(iface)
|
||||||
dialog.exec()
|
dialog.exec()
|
||||||
|
|
||||||
def open_help():
|
def open_help():
|
||||||
""" Open the online help. """
|
""" Open the online help. """
|
||||||
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
|
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import os.path
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from qgis.PyQt import uic
|
from qgis.PyQt import uic
|
||||||
# from qgis.PyQt.QtGui import QPixmap
|
from qgis.PyQt.QtGui import QPixmap
|
||||||
from qgis.PyQt.QtWidgets import QDialog
|
from qgis.PyQt.QtWidgets import QDialog
|
||||||
|
|
||||||
from .tools.resources import devlog
|
from .tools.resources import devlog
|
||||||
|
|||||||
@ -1,37 +1,76 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
# from collections import namedtuple
|
from collections import namedtuple
|
||||||
# from enum import Enum
|
from enum import Enum
|
||||||
# from functools import partial
|
from functools import partial
|
||||||
# from pathlib import Path
|
from pathlib import Path
|
||||||
# from xml.dom.minidom import parseString
|
from xml.dom.minidom import parseString
|
||||||
# from qgis.gui import *
|
from qgis.gui import *
|
||||||
# import qgis
|
import qgis
|
||||||
from qgis.core import QgsSettings
|
from qgis.core import (
|
||||||
from qgis.PyQt.QtCore import Qt
|
NULL,
|
||||||
# from qgis.PyQt.QtPrintSupport import QPrinter
|
QgsApplication,
|
||||||
|
QgsScaleBarSettings,
|
||||||
|
QgsDataSourceUri,
|
||||||
|
QgsProject,
|
||||||
|
QgsProviderConnectionException,
|
||||||
|
QgsProviderRegistry,
|
||||||
|
QgsRasterLayer,
|
||||||
|
QgsSettings,
|
||||||
|
QgsVectorLayer,
|
||||||
|
QgsGeometry,
|
||||||
|
QgsPrintLayout,
|
||||||
|
QgsReadWriteContext,
|
||||||
|
QgsLayoutItemMap,
|
||||||
|
QgsLayoutItemPage,
|
||||||
|
QgsLayoutSize,
|
||||||
|
QgsUnitTypes,
|
||||||
|
QgsLayoutPoint,
|
||||||
|
QgsLayoutItemLabel,
|
||||||
|
QgsLayoutItemPicture,
|
||||||
|
QgsLayoutItemLegend,
|
||||||
|
QgsLegendStyle,
|
||||||
|
QgsLayoutItemScaleBar,
|
||||||
|
QgsLayerTreeGroup,
|
||||||
|
QgsCoordinateReferenceSystem,
|
||||||
|
QgsCoordinateTransform,
|
||||||
|
QgsLayerTree,
|
||||||
|
QgsLayoutTableColumn,
|
||||||
|
QgsRectangle,
|
||||||
|
QgsLayoutItemMapOverviewStack,
|
||||||
|
QgsLayoutItemHtml,
|
||||||
|
)
|
||||||
|
from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime, Qt
|
||||||
|
from qgis.PyQt.QtGui import QDesktopServices, QIcon, QColor, QFont, QMovie
|
||||||
|
from qgis.PyQt.QtPrintSupport import QPrinter
|
||||||
#from qgis.PyQt.QtWebKitWidgets import QWebPage
|
#from qgis.PyQt.QtWebKitWidgets import QWebPage
|
||||||
from qgis.PyQt.QtWidgets import (
|
from qgis.PyQt.QtWidgets import (
|
||||||
QDialog,
|
QDialog,
|
||||||
|
QAction,
|
||||||
|
QDockWidget,
|
||||||
QFileDialog,
|
QFileDialog,
|
||||||
|
QInputDialog,
|
||||||
|
QMenu,
|
||||||
|
QToolButton,
|
||||||
|
QTableWidget,
|
||||||
QTableWidgetItem,
|
QTableWidgetItem,
|
||||||
|
QVBoxLayout,
|
||||||
)
|
)
|
||||||
|
|
||||||
from qgis.PyQt import QtGui
|
from qgis.PyQt import QtGui
|
||||||
from qgis.PyQt.QtWidgets import QApplication
|
from qgis.PyQt.QtWidgets import QApplication
|
||||||
from qgis.PyQt.QtCore import QSettings
|
from qgis.PyQt.QtCore import QSettings,QPointF
|
||||||
|
|
||||||
# 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.resources import (
|
from .tools.resources import (
|
||||||
load_ui,
|
load_ui,
|
||||||
resources_path,
|
resources_path,
|
||||||
# send_issues,
|
send_issues,
|
||||||
)
|
)
|
||||||
# from .issues import CenRa_Issues
|
from .issues import CenRa_Issues
|
||||||
# from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
last_select = None
|
last_select = None
|
||||||
maxV=210
|
maxV=210
|
||||||
maxH=296
|
maxH=296
|
||||||
@ -41,10 +80,31 @@ url_osm = 'https://osm.datagrandest.fr/mapcache/?crs=EPSG:2154&featureCount=10&f
|
|||||||
url_ortho = 'http://tiles.craig.fr/ortho/service/?crs=EPSG:2154&featureCount=10&format=image/jpeg&layers=ortho&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/ortho/service'
|
url_ortho = 'http://tiles.craig.fr/ortho/service/?crs=EPSG:2154&featureCount=10&format=image/jpeg&layers=ortho&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/ortho/service'
|
||||||
url_mnt = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=relief&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
|
url_mnt = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=relief&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
|
||||||
url_pente = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=pente&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
|
url_pente = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=pente&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
|
||||||
data_source = ['CENRA', 'IGN', 'CRAIG', 'OpenStreetMap', 'Sandre', 'BRGM', 'MUSÉUM NATIONAL D’HISTOIRE NATURELLE', "Muséum national d'Histoire naturelle", 'ONF', '20xx LPO', 'ofb.gouv.fr', 'Stamen Design', 'MTES', 'MTES', 'FEDER', 'DREAL Auvergne-Rhône-Alpes', 'INSEE', 'DGFiP', 'Fédération des Conservatoires d’espaces naturels', 'Plan cadastral informatisé - Etalab - juillet 202X', 'Parcellaire Express - IGN - 202X']
|
data_source = [
|
||||||
|
'CENRA',
|
||||||
|
'IGN',
|
||||||
|
'CRAIG',
|
||||||
|
'OpenStreetMap',
|
||||||
|
'Sandre',
|
||||||
|
'BRGM',
|
||||||
|
'MUSÉUM NATIONAL D’HISTOIRE NATURELLE',
|
||||||
|
"Muséum national d'Histoire naturelle",
|
||||||
|
'ONF',
|
||||||
|
'20xx LPO',
|
||||||
|
'ofb.gouv.fr',
|
||||||
|
'Stamen Design',
|
||||||
|
'MTES',
|
||||||
|
'MTES',
|
||||||
|
'FEDER',
|
||||||
|
'DREAL Auvergne-Rhône-Alpes',
|
||||||
|
'INSEE',
|
||||||
|
'DGFiP',
|
||||||
|
'Fédération des Conservatoires d’espaces naturels',
|
||||||
|
'Plan cadastral informatisé - Etalab - juillet 202X',
|
||||||
|
'Parcellaire Express - IGN - 202X',
|
||||||
|
]
|
||||||
class PageRender_Editor(QDialog, EDITOR_CLASS):
|
class PageRender_Editor(QDialog, EDITOR_CLASS):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
_ = parent
|
_ = parent
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -67,7 +127,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
|
|||||||
'Credit':0,
|
'Credit':0,
|
||||||
'Source':0,
|
'Source':0,
|
||||||
'Echelle_2':0,
|
'Echelle_2':0,
|
||||||
'Logo_2': 0}
|
'Logo_2':0,}
|
||||||
|
|
||||||
path = ''
|
path = ''
|
||||||
ix = 0
|
ix = 0
|
||||||
@ -98,9 +158,8 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.activateWindow()
|
self.activateWindow()
|
||||||
self.setNavigator()
|
self.setNavigator()
|
||||||
self.verticalScrollBar.setValue(self.frame.y())
|
self.verticalScrollBar.setValue(self.frame.y())
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
if self.tableWidget.currentItem() is not None:
|
if self.tableWidget.currentItem() != None:
|
||||||
QApplication.setOverrideCursor(Qt.CursorShape(18))
|
QApplication.setOverrideCursor(Qt.CursorShape(18))
|
||||||
global lastPos
|
global lastPos
|
||||||
lastPos = {'x':event.pos().x(),'y':event.pos().y()}
|
lastPos = {'x':event.pos().x(),'y':event.pos().y()}
|
||||||
@ -119,6 +178,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
|
|||||||
if event.key() == Qt.Key(0x01000012):
|
if event.key() == Qt.Key(0x01000012):
|
||||||
self.horizontalSlider.setValue(self.spinBox.value()-1)
|
self.horizontalSlider.setValue(self.spinBox.value()-1)
|
||||||
|
|
||||||
|
|
||||||
def wheelEvent(self,event):
|
def wheelEvent(self,event):
|
||||||
if (event.angleDelta().y() >= 1):
|
if (event.angleDelta().y() >= 1):
|
||||||
vsb = self.verticalScrollBar.value()+50
|
vsb = self.verticalScrollBar.value()+50
|
||||||
@ -128,7 +188,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
def mouseMoveEvent(self, event):
|
def mouseMoveEvent(self, event):
|
||||||
updated_cursor_position = event.pos()
|
updated_cursor_position = event.pos()
|
||||||
if self.tableWidget.currentItem() is not None:
|
if self.tableWidget.currentItem() != None:
|
||||||
selection_name = (self.tableWidget.currentItem()).text()
|
selection_name = (self.tableWidget.currentItem()).text()
|
||||||
all_children = self.frame.children()
|
all_children = self.frame.children()
|
||||||
selection = 0
|
selection = 0
|
||||||
@ -144,14 +204,14 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
orig_position_w = selection.width()
|
orig_position_w = selection.width()
|
||||||
orig_position_h = selection.height()
|
orig_position_h = selection.height()
|
||||||
if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() is True):
|
if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() == True):
|
||||||
updated_cursor_position_x = orig_position_w+(round(updated_cursor_position.x()-lastPos['x']))
|
updated_cursor_position_x = orig_position_w+(round(updated_cursor_position.x()-lastPos['x']))
|
||||||
lastPos['x'] = event.pos().x()
|
lastPos['x'] = event.pos().x()
|
||||||
selection.resize(updated_cursor_position_x,orig_position_h)
|
selection.resize(updated_cursor_position_x,orig_position_h)
|
||||||
self.horizontalSlider.setValue(round(updated_cursor_position_x/3.5))
|
self.horizontalSlider.setValue(round(updated_cursor_position_x/3.5))
|
||||||
orig_position_w = selection.width()
|
orig_position_w = selection.width()
|
||||||
orig_position_h = selection.height()
|
orig_position_h = selection.height()
|
||||||
if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() is True):
|
if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() == True):
|
||||||
updated_cursor_position_y = orig_position_h+(round(updated_cursor_position.y()-lastPos['y']))
|
updated_cursor_position_y = orig_position_h+(round(updated_cursor_position.y()-lastPos['y']))
|
||||||
lastPos['y'] = event.pos().y()
|
lastPos['y'] = event.pos().y()
|
||||||
selection.resize(orig_position_w,updated_cursor_position_y)
|
selection.resize(orig_position_w,updated_cursor_position_y)
|
||||||
@ -159,7 +219,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
orig_position_x = selection.pos().x()
|
orig_position_x = selection.pos().x()
|
||||||
orig_position_y = selection.pos().y()
|
orig_position_y = selection.pos().y()
|
||||||
if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() is False):
|
if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() == False):
|
||||||
updated_cursor_position_x = orig_position_x+(round(updated_cursor_position.x()-lastPos['x']))
|
updated_cursor_position_x = orig_position_x+(round(updated_cursor_position.x()-lastPos['x']))
|
||||||
lastPos['x'] = event.pos().x()
|
lastPos['x'] = event.pos().x()
|
||||||
#print(updated_cursor_position_x)
|
#print(updated_cursor_position_x)
|
||||||
@ -168,7 +228,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
orig_position_x = selection.pos().x()
|
orig_position_x = selection.pos().x()
|
||||||
orig_position_y = selection.pos().y()
|
orig_position_y = selection.pos().y()
|
||||||
if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() is False):
|
if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() == False):
|
||||||
updated_cursor_position_y = orig_position_y+(round(updated_cursor_position.y()-lastPos['y']))
|
updated_cursor_position_y = orig_position_y+(round(updated_cursor_position.y()-lastPos['y']))
|
||||||
lastPos['y'] = event.pos().y()
|
lastPos['y'] = event.pos().y()
|
||||||
#print(updated_cursor_position_y)
|
#print(updated_cursor_position_y)
|
||||||
@ -177,7 +237,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
def mouseReleaseEvent(self, event):
|
def mouseReleaseEvent(self, event):
|
||||||
#print('x: {0}, y: {1}'.format(event.pos().x(), event.pos().y()))
|
#print('x: {0}, y: {1}'.format(event.pos().x(), event.pos().y()))
|
||||||
if self.tableWidget.currentItem() is not None:
|
if self.tableWidget.currentItem() != None:
|
||||||
QApplication.restoreOverrideCursor()
|
QApplication.restoreOverrideCursor()
|
||||||
|
|
||||||
def select_file(self):
|
def select_file(self):
|
||||||
@ -188,7 +248,6 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
|
|||||||
return folder[0]
|
return folder[0]
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
folder = self.select_file()
|
folder = self.select_file()
|
||||||
logopath = folder
|
logopath = folder
|
||||||
@ -258,13 +317,12 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.tableWidget.removeRow(0)
|
self.tableWidget.removeRow(0)
|
||||||
xR = xR+1
|
xR = xR+1
|
||||||
self.tableWidget.clear()
|
self.tableWidget.clear()
|
||||||
# id = 0
|
id=0
|
||||||
for children in all_children:
|
for children in all_children:
|
||||||
position = self.tableWidget.rowCount()
|
position = self.tableWidget.rowCount()
|
||||||
self.tableWidget.insertRow(position)
|
self.tableWidget.insertRow(position)
|
||||||
self.tableWidget.setItem(position,0,QTableWidgetItem(children.objectName()))
|
self.tableWidget.setItem(position,0,QTableWidgetItem(children.objectName()))
|
||||||
#print(children.objectName())
|
#print(children.objectName())
|
||||||
|
|
||||||
def export(self):
|
def export(self):
|
||||||
self.type_page()
|
self.type_page()
|
||||||
self.type_page()
|
self.type_page()
|
||||||
@ -354,7 +412,6 @@ def fletch_canvas(self):
|
|||||||
sourceFile = open(self.path,'w')
|
sourceFile = open(self.path,'w')
|
||||||
print(export_str, file = sourceFile)
|
print(export_str, file = sourceFile)
|
||||||
sourceFile.close()
|
sourceFile.close()
|
||||||
|
|
||||||
def type_page(self):
|
def type_page(self):
|
||||||
all_children = self.frame.children()
|
all_children = self.frame.children()
|
||||||
if self.toolButton_2.text() == 'Landscape':
|
if self.toolButton_2.text() == 'Landscape':
|
||||||
@ -405,9 +462,8 @@ def fletch_canvas(self):
|
|||||||
frame_x = round(frame_w / 3)
|
frame_x = round(frame_w / 3)
|
||||||
frame_y = self.frame.y()
|
frame_y = self.frame.y()
|
||||||
self.frame.move(frame_x,frame_y)
|
self.frame.move(frame_x,frame_y)
|
||||||
|
|
||||||
def setSlider(self):
|
def setSlider(self):
|
||||||
if self.tableWidget.currentItem() is not None:
|
if self.tableWidget.currentItem() != None:
|
||||||
print(self.tableWidget.tabKeyNavigation())
|
print(self.tableWidget.tabKeyNavigation())
|
||||||
selection_name = (self.tableWidget.currentItem()).text()
|
selection_name = (self.tableWidget.currentItem()).text()
|
||||||
all_children = self.frame.children()
|
all_children = self.frame.children()
|
||||||
@ -420,7 +476,7 @@ def fletch_canvas(self):
|
|||||||
selection = children
|
selection = children
|
||||||
if selection != 0:
|
if selection != 0:
|
||||||
self.rotate_color(selection,last_children)
|
self.rotate_color(selection,last_children)
|
||||||
if self.radioButton.isChecked() is False:
|
if self.radioButton.isChecked() == False:
|
||||||
xx = round(selection.x()/3.5)
|
xx = round(selection.x()/3.5)
|
||||||
yy = round(selection.y()/3.5)
|
yy = round(selection.y()/3.5)
|
||||||
else:
|
else:
|
||||||
@ -434,7 +490,7 @@ def fletch_canvas(self):
|
|||||||
|
|
||||||
def rotate_color(self,selection,last_children):
|
def rotate_color(self,selection,last_children):
|
||||||
global last_select
|
global last_select
|
||||||
if self.radioButton.isChecked() is False:
|
if self.radioButton.isChecked() == False:
|
||||||
ColorCode = "10, 10, 80, 50"
|
ColorCode = "10, 10, 80, 50"
|
||||||
else:
|
else:
|
||||||
ColorCode = "249, 238, 148, 50"
|
ColorCode = "249, 238, 148, 50"
|
||||||
@ -453,7 +509,7 @@ def fletch_canvas(self):
|
|||||||
last_select = selection.objectName()
|
last_select = selection.objectName()
|
||||||
|
|
||||||
def rotate(self):
|
def rotate(self):
|
||||||
if self.tableWidget.currentItem() is not None:
|
if self.tableWidget.currentItem() != None:
|
||||||
selection_name = (self.tableWidget.currentItem()).text()
|
selection_name = (self.tableWidget.currentItem()).text()
|
||||||
all_children = self.frame.children()
|
all_children = self.frame.children()
|
||||||
selection = 0
|
selection = 0
|
||||||
@ -467,7 +523,7 @@ def fletch_canvas(self):
|
|||||||
xx = round(selection.size().width())
|
xx = round(selection.size().width())
|
||||||
yy = round(selection.size().height())
|
yy = round(selection.size().height())
|
||||||
selection.resize(round(yy),round(xx))
|
selection.resize(round(yy),round(xx))
|
||||||
if self.radioButton.isChecked() is True:
|
if self.radioButton.isChecked() == True:
|
||||||
self.spinBox.setValue(yy)
|
self.spinBox.setValue(yy)
|
||||||
self.spinBox_2.setValue(xx)
|
self.spinBox_2.setValue(xx)
|
||||||
self.horizontalSlider.setValue(round(yy/3.5))
|
self.horizontalSlider.setValue(round(yy/3.5))
|
||||||
@ -480,7 +536,7 @@ def fletch_canvas(self):
|
|||||||
self.rotate_color(selection,last_children)
|
self.rotate_color(selection,last_children)
|
||||||
|
|
||||||
def vertical(self):
|
def vertical(self):
|
||||||
if self.tableWidget.currentItem() is not None:
|
if self.tableWidget.currentItem() != None:
|
||||||
selection_name = (self.tableWidget.currentItem()).text()
|
selection_name = (self.tableWidget.currentItem()).text()
|
||||||
all_children = self.frame.children()
|
all_children = self.frame.children()
|
||||||
selection = 0
|
selection = 0
|
||||||
@ -488,7 +544,7 @@ def fletch_canvas(self):
|
|||||||
if selection_name == children.objectName():
|
if selection_name == children.objectName():
|
||||||
selection = children
|
selection = children
|
||||||
if selection != 0:
|
if selection != 0:
|
||||||
if self.radioButton.isChecked() is False:
|
if self.radioButton.isChecked() == False:
|
||||||
selection.move(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5))
|
selection.move(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5))
|
||||||
else:
|
else:
|
||||||
selection.resize(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5))
|
selection.resize(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5))
|
||||||
@ -496,7 +552,7 @@ def fletch_canvas(self):
|
|||||||
self.spinBox_2.setValue(round(self.verticalSlider.value()))
|
self.spinBox_2.setValue(round(self.verticalSlider.value()))
|
||||||
|
|
||||||
def horizontal(self):
|
def horizontal(self):
|
||||||
if self.tableWidget.currentItem() is not None:
|
if self.tableWidget.currentItem() != None:
|
||||||
selection_name = (self.tableWidget.currentItem()).text()
|
selection_name = (self.tableWidget.currentItem()).text()
|
||||||
all_children = self.frame.children()
|
all_children = self.frame.children()
|
||||||
selection = 0
|
selection = 0
|
||||||
@ -504,9 +560,10 @@ def fletch_canvas(self):
|
|||||||
if selection_name == children.objectName():
|
if selection_name == children.objectName():
|
||||||
selection = children
|
selection = children
|
||||||
if selection != 0:
|
if selection != 0:
|
||||||
if self.radioButton.isChecked() is False:
|
if self.radioButton.isChecked() == False:
|
||||||
selection.move(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5))
|
selection.move(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5))
|
||||||
else:
|
else:
|
||||||
selection.resize(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5))
|
selection.resize(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5))
|
||||||
self.spinBox.setValue(round(self.horizontalSlider.value()))
|
self.spinBox.setValue(round(self.horizontalSlider.value()))
|
||||||
self.spinBox_2.setValue(round(self.verticalSlider.value()))
|
self.spinBox_2.setValue(round(self.verticalSlider.value()))
|
||||||
|
|
||||||
|
|||||||
@ -1,167 +0,0 @@
|
|||||||
|
|
||||||
from qgis.core import (
|
|
||||||
QgsLayoutSize,
|
|
||||||
QgsUnitTypes,
|
|
||||||
QgsLayoutPoint,
|
|
||||||
)
|
|
||||||
def fletch_canvas(self):
|
|
||||||
if self.radioButton_6.isChecked():
|
|
||||||
values_page = 'A4'
|
|
||||||
else:
|
|
||||||
values_page = 'A3'
|
|
||||||
if self.radioButton_7.isChecked():
|
|
||||||
page_rotate = 'Portrait'
|
|
||||||
else:
|
|
||||||
page_rotate = 'Landscape'
|
|
||||||
|
|
||||||
if page_rotate == 'Portrait':
|
|
||||||
if values_page == 'A4':
|
|
||||||
self.template_parameters['Carte_size'] = QgsLayoutSize(200.0,200, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_rotate'] = 0
|
|
||||||
self.template_parameters['Carte_2_size'] = QgsLayoutSize(85.71428571428571,69, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(209, 3, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_2_rotate'] = 0
|
|
||||||
self.template_parameters['Legande_size'] = QgsLayoutSize(140.0,147, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Legande_locals'] = QgsLayoutPoint(41, 110, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Legande_rotate'] = 0
|
|
||||||
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286,14, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Arrow_rotate'] = 0
|
|
||||||
self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143,7, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_rotate'] = 0
|
|
||||||
self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715,11, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_rotate'] = 0
|
|
||||||
self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428,11, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Titre_rotate'] = 0
|
|
||||||
self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 197, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Credit_rotate'] = 0
|
|
||||||
self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Source_rotate'] = 0
|
|
||||||
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571,14, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Sous_titre_rotate'] = 0
|
|
||||||
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143,13, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_2_rotate'] = 0
|
|
||||||
self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573,29, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_2_rotate'] = 0
|
|
||||||
if values_page == 'A3':
|
|
||||||
self.template_parameters['Carte_size'] = QgsLayoutSize(282,282, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_rotate'] = 0
|
|
||||||
self.template_parameters['Carte_2_size'] = QgsLayoutSize(121,97, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(294, 4, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_2_rotate'] = 0
|
|
||||||
self.template_parameters['Legande_size'] = QgsLayoutSize(197,207, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Legande_locals'] = QgsLayoutPoint(58, 156, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Legande_rotate'] = 0
|
|
||||||
self.template_parameters['Arrow_size'] = QgsLayoutSize(20,20, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(266, 28, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Arrow_rotate'] = 0
|
|
||||||
self.template_parameters['Echelle_size'] = QgsLayoutSize(73,10, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(12, 278, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_rotate'] = 0
|
|
||||||
self.template_parameters['Logo_size'] = QgsLayoutSize(64,16, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_rotate'] = 0
|
|
||||||
self.template_parameters['Titre_size'] = QgsLayoutSize(218,16, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Titre_locals'] = QgsLayoutPoint(73, 4, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Titre_rotate'] = 0
|
|
||||||
self.template_parameters['Credit_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Credit_locals'] = QgsLayoutPoint(214, 278, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Credit_rotate'] = 0
|
|
||||||
self.template_parameters['Source_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Source_locals'] = QgsLayoutPoint(322, 278, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Source_rotate'] = 0
|
|
||||||
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177,20, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Sous_titre_rotate'] = 0
|
|
||||||
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73,18, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(12, 260, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_2_rotate'] = 0
|
|
||||||
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40,40, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(12, 214, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_2_rotate'] = 0
|
|
||||||
if page_rotate == 'Landscape':
|
|
||||||
if values_page == 'A4':
|
|
||||||
self.template_parameters['Carte_size'] = QgsLayoutSize(200.0,200, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_rotate'] = 0
|
|
||||||
self.template_parameters['Carte_2_size'] = QgsLayoutSize(85.71428571428571,69, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(209, 3, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_2_rotate'] = 0
|
|
||||||
self.template_parameters['Legande_size'] = QgsLayoutSize(140.0,147, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Legande_locals'] = QgsLayoutPoint(49, 15, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Legande_rotate'] = 0
|
|
||||||
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286,14, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Arrow_rotate'] = 0
|
|
||||||
self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143,7, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_rotate'] = 0
|
|
||||||
self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715,11, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_rotate'] = 0
|
|
||||||
self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428,11, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Titre_rotate'] = 0
|
|
||||||
self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 197, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Credit_rotate'] = 0
|
|
||||||
self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Source_rotate'] = 0
|
|
||||||
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571,14, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Sous_titre_rotate'] = 0
|
|
||||||
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143,13, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_2_rotate'] = 0
|
|
||||||
self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573,29, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_2_rotate'] = 0
|
|
||||||
if values_page == 'A3':
|
|
||||||
self.template_parameters['Carte_size'] = QgsLayoutSize(282,282, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_rotate'] = 0
|
|
||||||
self.template_parameters['Carte_2_size'] = QgsLayoutSize(121,97, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(294, 4, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Carte_2_rotate'] = 0
|
|
||||||
self.template_parameters['Legande_size'] = QgsLayoutSize(197,207, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Legande_locals'] = QgsLayoutPoint(69, 21, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Legande_rotate'] = 0
|
|
||||||
self.template_parameters['Arrow_size'] = QgsLayoutSize(20,20, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(266, 28, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Arrow_rotate'] = 0
|
|
||||||
self.template_parameters['Echelle_size'] = QgsLayoutSize(73,10, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(12, 278, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_rotate'] = 0
|
|
||||||
self.template_parameters['Logo_size'] = QgsLayoutSize(64,16, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_rotate'] = 0
|
|
||||||
self.template_parameters['Titre_size'] = QgsLayoutSize(218,16, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Titre_locals'] = QgsLayoutPoint(73, 4, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Titre_rotate'] = 0
|
|
||||||
self.template_parameters['Credit_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Credit_locals'] = QgsLayoutPoint(214, 278, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Credit_rotate'] = 0
|
|
||||||
self.template_parameters['Source_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Source_locals'] = QgsLayoutPoint(322, 278, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Source_rotate'] = 0
|
|
||||||
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177,20, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Sous_titre_rotate'] = 0
|
|
||||||
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73,18, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(12, 260, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Echelle_2_rotate'] = 0
|
|
||||||
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40,40, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(12, 214, QgsUnitTypes.LayoutMillimeters)
|
|
||||||
self.template_parameters['Logo_2_rotate'] = 0
|
|
||||||
return self.template_parameters
|
|
||||||
@ -3,9 +3,9 @@
|
|||||||
import configparser
|
import configparser
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
# import base64
|
import base64
|
||||||
# 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
|
||||||
from qgis.PyQt.QtWidgets import QApplication
|
from qgis.PyQt.QtWidgets import QApplication
|
||||||
from qgis.PyQt import uic
|
from qgis.PyQt import uic
|
||||||
@ -107,38 +107,37 @@ def load_ui(*args):
|
|||||||
|
|
||||||
return ui_class
|
return ui_class
|
||||||
|
|
||||||
|
|
||||||
def send_issues(url,titre,body,labels):
|
def send_issues(url,titre,body,labels):
|
||||||
import requests
|
import requests
|
||||||
import urllib.request
|
|
||||||
import json
|
import json
|
||||||
# import os
|
import os
|
||||||
|
import qgis
|
||||||
|
|
||||||
# usr = os.environ['USERNAME']
|
usr = os.environ['USERNAME']
|
||||||
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
|
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
|
||||||
url=url+'?token='+token
|
url=url+'?token='+token
|
||||||
|
|
||||||
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
|
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
|
||||||
|
|
||||||
|
|
||||||
payload = {'title': titre, 'body': body, 'labels': labels}
|
payload = {'title': titre, 'body': body, 'labels': labels}
|
||||||
try:
|
try:
|
||||||
urllib.request.urlopen('https://google.com')
|
urllib.request.urlopen('https://google.com')
|
||||||
binar = True
|
binar = True
|
||||||
except urllib.requests.URLError:
|
except:
|
||||||
binar = False
|
binar = False
|
||||||
r = ''
|
r = ''
|
||||||
if binar:
|
if binar:
|
||||||
r = requests.post(url, data=json.dumps(payload), headers=headers)
|
r = requests.post(url, data=json.dumps(payload), headers=headers)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def maj_verif(NAME):
|
def maj_verif(NAME):
|
||||||
import qgis
|
import qgis
|
||||||
import urllib.request
|
import urllib.request
|
||||||
iface = qgis.utils.iface
|
iface = qgis.utils.iface
|
||||||
from qgis.core import Qgis
|
from qgis.core import Qgis
|
||||||
|
|
||||||
# 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/latest/plugins.xml'
|
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
|
||||||
# print(URL)
|
# print(URL)
|
||||||
@ -147,7 +146,7 @@ def maj_verif(NAME):
|
|||||||
try:
|
try:
|
||||||
urllib.request.urlopen('https://google.com')
|
urllib.request.urlopen('https://google.com')
|
||||||
binar = True
|
binar = True
|
||||||
except urllib.requests.URLError:
|
except:
|
||||||
binar = False
|
binar = False
|
||||||
if binar:
|
if binar:
|
||||||
try:
|
try:
|
||||||
@ -157,16 +156,14 @@ def maj_verif(NAME):
|
|||||||
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
|
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
|
||||||
if version_plugin != version:
|
if version_plugin != version:
|
||||||
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
|
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
|
||||||
except urllib.requests.URLError:
|
except:
|
||||||
print("error gitea version ssl")
|
print("error gitea version ssl")
|
||||||
else:
|
else:
|
||||||
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
|
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
|
||||||
|
|
||||||
|
|
||||||
def tr(text, context="@default"):
|
def tr(text, context="@default"):
|
||||||
return QApplication.translate(context, text)
|
return QApplication.translate(context, text)
|
||||||
|
|
||||||
|
|
||||||
def devlog(NAME):
|
def devlog(NAME):
|
||||||
import qgis
|
import qgis
|
||||||
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
|
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
|
||||||
|
|||||||
@ -22,7 +22,6 @@ This script initializes the plugin, making it known to QGIS.
|
|||||||
"""
|
"""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
def classFactory(iface):
|
def classFactory(iface):
|
||||||
# load SICEN class from file SICEN
|
# load SICEN class from file SICEN
|
||||||
from .sicen import SICEN
|
from .sicen import SICEN
|
||||||
|
|||||||
@ -5,9 +5,10 @@
|
|||||||
# Created by: The Resource Compiler for PyQt5 (Qt v5.15.2)
|
# Created by: The Resource Compiler for PyQt5 (Qt v5.15.2)
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
try:
|
||||||
from qgis.PyQt import QtCore
|
from PyQt5 import QtCore
|
||||||
|
except:
|
||||||
|
from PyQt6 import QtCore
|
||||||
qt_resource_data = b"\
|
qt_resource_data = b"\
|
||||||
\x00\x00\x0d\x89\
|
\x00\x00\x0d\x89\
|
||||||
\x89\
|
\x89\
|
||||||
@ -557,13 +558,10 @@ else:
|
|||||||
rcc_version = 2
|
rcc_version = 2
|
||||||
qt_resource_struct = qt_resource_struct_v2
|
qt_resource_struct = qt_resource_struct_v2
|
||||||
|
|
||||||
|
|
||||||
def qInitResources():
|
def qInitResources():
|
||||||
QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
|
QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
|
||||||
|
|
||||||
|
|
||||||
def qCleanupResources():
|
def qCleanupResources():
|
||||||
QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
|
QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
|
||||||
|
|
||||||
|
|
||||||
qInitResources()
|
qInitResources()
|
||||||
|
|||||||
@ -1,20 +1,61 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
/***************************************************************************
|
||||||
|
SICEN
|
||||||
|
A QGIS plugin
|
||||||
|
Filtre sur données SICEN
|
||||||
|
-------------------
|
||||||
|
begin : 2014-10-17
|
||||||
|
copyright : (C) 2014 by Guillaume COSTES (CENRA)
|
||||||
|
email : guillaume.costes@espaces-naturels.fr
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
"""
|
||||||
|
"""from __future__ import absolute_import
|
||||||
|
# Import the PyQt and QGIS libraries
|
||||||
|
from builtins import str
|
||||||
|
from builtins import object
|
||||||
|
from PyQt4.QtCore import *
|
||||||
|
from PyQt4.QtGui import *
|
||||||
|
from qgis.core import *
|
||||||
|
from qgis.gui import *
|
||||||
|
from qgis.utils import iface"""
|
||||||
|
|
||||||
from builtins import str
|
from builtins import str
|
||||||
from builtins import object
|
from builtins import object
|
||||||
import os
|
import os
|
||||||
|
try:
|
||||||
|
from PyQt5.QtCore import *
|
||||||
|
from PyQt5.QtGui import *
|
||||||
|
except:
|
||||||
|
from PyQt6.QtCore import *
|
||||||
|
from PyQt6.QtGui import *
|
||||||
|
from qgis.PyQt import uic
|
||||||
|
from qgis.core import *
|
||||||
|
from qgis.core import QgsDataSourceUri, QgsWkbTypes, QgsLayerTreeGroup, QgsLayerTreeLayer
|
||||||
|
from qgis.PyQt.QtGui import QFont
|
||||||
|
from qgis.PyQt.QtWidgets import QMenu, QAction, QDialog, QDialogButtonBox, QLabel, QApplication, QTabWidget, QWidget, QGroupBox, QGridLayout, QComboBox, QCheckBox, QCalendarWidget, QToolBox, QFrame, QLineEdit, QSizePolicy, QFileDialog #Modifié
|
||||||
|
|
||||||
# from qgis.PyQt import uic
|
|
||||||
from qgis.core import QgsDataSourceUri, QgsLayerTreeLayer, QgsProject, QgsVectorLayer
|
|
||||||
from qgis.PyQt.QtGui import QIcon
|
|
||||||
from qgis.PyQt.QtWidgets import QMenu, QAction, QFileDialog
|
|
||||||
from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication, qVersion
|
|
||||||
|
|
||||||
# Initialize Qt resources from file resources.py
|
# Initialize Qt resources from file resources.py
|
||||||
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.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
|
||||||
@ -22,19 +63,11 @@ import csv
|
|||||||
|
|
||||||
from .forms.about_form import AboutDialog
|
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
|
||||||
|
|
||||||
from .tools.resources import maj_verif, pyperclip
|
|
||||||
pyperclip()
|
|
||||||
try:
|
|
||||||
from .tools.PythonSQL import login_base
|
|
||||||
except ValueError:
|
|
||||||
print('Pas de fichier PythonSQL')
|
|
||||||
|
|
||||||
#import sys
|
#import sys
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +105,7 @@ class SICEN(object):
|
|||||||
self.toolBar = self.iface.addToolBar("SICEN")
|
self.toolBar = self.iface.addToolBar("SICEN")
|
||||||
self.toolBar.setObjectName("SICEN")
|
self.toolBar.setObjectName("SICEN")
|
||||||
|
|
||||||
# Create action that will start plugin configuration
|
## Create action that will start plugin configuration
|
||||||
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())
|
||||||
@ -86,7 +119,7 @@ class SICEN(object):
|
|||||||
self.toolBar.addAction(self.action)
|
self.toolBar.addAction(self.action)
|
||||||
self.iface.addPluginToMenu(u"SICEN", self.action)
|
self.iface.addPluginToMenu(u"SICEN", self.action)
|
||||||
|
|
||||||
# Create action that will start plugin configuration
|
## Create action that will start plugin configuration
|
||||||
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())
|
||||||
@ -142,7 +175,7 @@ class SICEN(object):
|
|||||||
cur = account[7]
|
cur = account[7]
|
||||||
con = account[8]
|
con = account[8]
|
||||||
|
|
||||||
# Creation des listes deroulantes
|
## Creation des listes deroulantes
|
||||||
# Listing de valeur des champs
|
# Listing de valeur des champs
|
||||||
SQL_observateur = u"""SELECT DISTINCT nom || '_' || prenom as nom FROM md.personne ORDER BY nom"""
|
SQL_observateur = u"""SELECT DISTINCT nom || '_' || prenom as nom FROM md.personne ORDER BY nom"""
|
||||||
SQL_nom_com = u"""SELECT DISTINCT nom FROM saisie.commune ORDER BY nom"""
|
SQL_nom_com = u"""SELECT DISTINCT nom FROM saisie.commune ORDER BY nom"""
|
||||||
@ -168,14 +201,14 @@ class SICEN(object):
|
|||||||
|
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
# Ajout des items dans les combobox
|
# Ajout des items dans les combobox
|
||||||
self.dlg.observateur_1.clear()
|
self.dlg.observateur_1.clear()
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(list_observateur):
|
while i < len(list_observateur):
|
||||||
self.dlg.observateur_1.addItems(list_observateur[i])
|
self.dlg.observateur_1.addItems(list_observateur[i])
|
||||||
i=i+1
|
i=i+1
|
||||||
# Pour ne pas commencer la liste au premier item
|
self.dlg.observateur_1.setCurrentIndex(-1) # Pour ne pas commencer la liste au premier item
|
||||||
self.dlg.observateur_1.setCurrentIndex(-1)
|
|
||||||
|
|
||||||
self.dlg.observateur_2.clear()
|
self.dlg.observateur_2.clear()
|
||||||
i = 0
|
i = 0
|
||||||
@ -463,6 +496,7 @@ class SICEN(object):
|
|||||||
else :
|
else :
|
||||||
sql_UICN = ''
|
sql_UICN = ''
|
||||||
|
|
||||||
|
|
||||||
if self.dlg.PATRIMONIALITE.isChecked() == 1 :
|
if self.dlg.PATRIMONIALITE.isChecked() == 1 :
|
||||||
sql_patrimonialite = """"patrimonialite" IS NOT NULL """
|
sql_patrimonialite = """"patrimonialite" IS NOT NULL """
|
||||||
else :
|
else :
|
||||||
@ -508,6 +542,7 @@ class SICEN(object):
|
|||||||
else :
|
else :
|
||||||
sql_patri74 = ''
|
sql_patri74 = ''
|
||||||
|
|
||||||
|
|
||||||
if self.dlg.ZNIEFF.isChecked() == 1 :
|
if self.dlg.ZNIEFF.isChecked() == 1 :
|
||||||
sql_znieff = """"znieff" IS NOT NULL """
|
sql_znieff = """"znieff" IS NOT NULL """
|
||||||
else :
|
else :
|
||||||
@ -538,7 +573,7 @@ class SICEN(object):
|
|||||||
else :
|
else :
|
||||||
sql_pr = ''
|
sql_pr = ''
|
||||||
|
|
||||||
reqwhere_pat = sql_lrd01 + 'OR' + sql_lrd07 + 'OR' + sql_lrd26 + 'OR' + sql_lrd38 + 'OR' + sql_lrd42 + 'OR' + sql_lrd69 + 'OR' + sql_lrd73 + 'OR' + sql_lrd74 + 'OR' + sql_lre + 'OR' + sql_LRN_Flore + 'OR' + sql_LRN_Oiseaux + 'OR' + sql_LRN_Ortho + 'OR' + sql_LRN_Autre + 'OR' + sql_LRR_Flore + 'OR' + sql_LRR_Oiseaux + 'OR' + sql_LRR_Autre + 'OR' + sql_UICN + 'OR' + sql_pd38 + 'OR' + sql_pd42 + 'OR' + sql_pn + 'OR' + sql_pr + 'OR' + sql_znieff + 'OR' + sql_dh_an2 + 'OR' + sql_patri01 + 'OR' + sql_patri07 + 'OR' + sql_patri26 + 'OR' + sql_patri38 + 'OR' + sql_patri42 + 'OR' + sql_patri69 + 'OR' + sql_patri73 + 'OR' + sql_patri74 + 'OR' + sql_patrimonialite
|
reqwhere_pat = sql_lrd01 + 'OR' + sql_lrd07 + 'OR' + sql_lrd26 + 'OR' + sql_lrd38 + 'OR' + sql_lrd42 + 'OR' + sql_lrd69 + 'OR' + sql_lrd73 + 'OR' + sql_lrd74 + 'OR' + sql_lre + 'OR' + sql_LRN_Flore + 'OR' + sql_LRN_Oiseaux + 'OR' + sql_LRN_Ortho + 'OR' + sql_LRN_Autre + 'OR' + sql_LRR_Flore + 'OR' + sql_LRR_Oiseaux + 'OR' + sql_LRR_Autre + 'OR' + sql_UICN + 'OR' + sql_pd38 + 'OR' + sql_pd42 + 'OR' + sql_pn + 'OR' + sql_pr + 'OR' + sql_dh_an2 + 'OR' + sql_patri01 + 'OR' + sql_patri07 + 'OR' + sql_patri26 + 'OR' + sql_patri38 + 'OR' + sql_patri42 + 'OR' + sql_patri69 + 'OR' + sql_patri73 + 'OR' + sql_patri74 + 'OR' + sql_patrimonialite
|
||||||
|
|
||||||
while reqwhere_pat.find('OROR') != -1 :
|
while reqwhere_pat.find('OROR') != -1 :
|
||||||
reqwhere_pat = reqwhere_pat.replace('OROR','OR')
|
reqwhere_pat = reqwhere_pat.replace('OROR','OR')
|
||||||
@ -551,9 +586,9 @@ class SICEN(object):
|
|||||||
if self.dlg.bouton_geom.isChecked() == 1 :
|
if self.dlg.bouton_geom.isChecked() == 1 :
|
||||||
|
|
||||||
layer = self.iface.activeLayer()
|
layer = self.iface.activeLayer()
|
||||||
if layer is None:
|
if layer == None :
|
||||||
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner une table !", level=QgsMessageBar.WARNING, duration=5)
|
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner une table !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner une table !", level=1, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner une table !", level=Qgis.Warning, duration=5)
|
||||||
|
|
||||||
else :
|
else :
|
||||||
selection = layer.selectedFeatures()
|
selection = layer.selectedFeatures()
|
||||||
@ -585,14 +620,14 @@ class SICEN(object):
|
|||||||
while reqwhere_final[:3] == 'AND' :
|
while reqwhere_final[:3] == 'AND' :
|
||||||
reqwhere_final = reqwhere_final[3:]
|
reqwhere_final = reqwhere_final[3:]
|
||||||
|
|
||||||
# Affichage des tables
|
## Affichage des tables
|
||||||
table_name = 'observations'
|
table_name = 'observations'
|
||||||
|
|
||||||
uri = QgsDataSourceUri()
|
uri = QgsDataSourceUri()
|
||||||
uri.setConnection(host ,port ,dbname ,user ,mdp)
|
uri.setConnection(host ,port ,dbname ,user ,mdp)
|
||||||
|
|
||||||
if self.dlg.centroide.isChecked() == 1 :
|
if self.dlg.centroide.isChecked() == 1 :
|
||||||
# Centroide
|
### Centroide
|
||||||
if reqwhere_final.find('()') != -1 :
|
if reqwhere_final.find('()') != -1 :
|
||||||
reqwhere_final = ''
|
reqwhere_final = ''
|
||||||
print(reqwhere_final)
|
print(reqwhere_final)
|
||||||
@ -625,9 +660,9 @@ class SICEN(object):
|
|||||||
#groups = toc.
|
#groups = toc.
|
||||||
#groups = toc.groups()
|
#groups = toc.groups()
|
||||||
#index = groups.index(nomgroupe)
|
#index = groups.index(nomgroupe)
|
||||||
# index = 1
|
index = 1
|
||||||
|
|
||||||
# Polygone
|
### Polygone
|
||||||
reqwhere_final_poly = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POLYGON%'" + ')'
|
reqwhere_final_poly = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POLYGON%'" + ')'
|
||||||
if reqwhere_final_poly.find('()') != -1 :
|
if reqwhere_final_poly.find('()') != -1 :
|
||||||
reqwhere_final_poly = "(GeometryType(geometrie) LIKE '%POLYGON%')"
|
reqwhere_final_poly = "(GeometryType(geometrie) LIKE '%POLYGON%')"
|
||||||
@ -646,7 +681,7 @@ class SICEN(object):
|
|||||||
#groupe.addLayer(layer_poly)
|
#groupe.addLayer(layer_poly)
|
||||||
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_poly))
|
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_poly))
|
||||||
|
|
||||||
# Point
|
### Point
|
||||||
reqwhere_final_point = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POINT%'" + ')'
|
reqwhere_final_point = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POINT%'" + ')'
|
||||||
if reqwhere_final_point.find('()') != -1 :
|
if reqwhere_final_point.find('()') != -1 :
|
||||||
reqwhere_final_point = "(GeometryType(geometrie) LIKE '%POINT%')"
|
reqwhere_final_point = "(GeometryType(geometrie) LIKE '%POINT%')"
|
||||||
@ -665,7 +700,7 @@ class SICEN(object):
|
|||||||
#groupe.addLayer(layer_point)
|
#groupe.addLayer(layer_point)
|
||||||
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_point))
|
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_point))
|
||||||
|
|
||||||
# Ligne
|
### Ligne
|
||||||
reqwhere_final_ligne = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%LINE%'" + ')'
|
reqwhere_final_ligne = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%LINE%'" + ')'
|
||||||
if reqwhere_final_ligne.find('()') != -1 :
|
if reqwhere_final_ligne.find('()') != -1 :
|
||||||
reqwhere_final_ligne = "(GeometryType(geometrie) LIKE '%LINE%')"
|
reqwhere_final_ligne = "(GeometryType(geometrie) LIKE '%LINE%')"
|
||||||
@ -688,16 +723,17 @@ class SICEN(object):
|
|||||||
#legende.setGroupExpanded (index, True)
|
#legende.setGroupExpanded (index, True)
|
||||||
|
|
||||||
#self.iface.messageBar().pushMessage(u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=QgsMessageBar.INFO, duration=10)
|
#self.iface.messageBar().pushMessage(u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=QgsMessageBar.INFO, duration=10)
|
||||||
self.iface.messageBar().pushMessage("Info", u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=0, duration=4)
|
self.iface.messageBar().pushMessage("Info", u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=Qgis.Success, duration=4)
|
||||||
|
|
||||||
|
|
||||||
elif layer.selectedFeatureCount() == 0 :
|
elif layer.selectedFeatureCount() == 0 :
|
||||||
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner au moins un polygone !", level=QgsMessageBar.WARNING, duration=5)
|
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner au moins un polygone !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner au moins un polygone !", level=1, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner au moins un polygone !", level=Qgis.Warning, duration=5)
|
||||||
reqwhere_geom = ''
|
reqwhere_geom = ''
|
||||||
|
|
||||||
else :
|
else :
|
||||||
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner qu'un seul polygone !", level=QgsMessageBar.WARNING, duration=5)
|
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner qu'un seul polygone !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous ne devez sélectionner qu'un seul polygone !", level=1, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous ne devez sélectionner qu'un seul polygone !", level=Qgis.Warning, duration=5)
|
||||||
reqwhere_geom = ''
|
reqwhere_geom = ''
|
||||||
else :
|
else :
|
||||||
# Requete finale
|
# Requete finale
|
||||||
@ -717,13 +753,13 @@ class SICEN(object):
|
|||||||
while reqwhere_final[:3] == 'AND' :
|
while reqwhere_final[:3] == 'AND' :
|
||||||
reqwhere_final = reqwhere_final[3:]
|
reqwhere_final = reqwhere_final[3:]
|
||||||
|
|
||||||
# Affichage des tables
|
## Affichage des tables
|
||||||
table_name = 'observations'
|
table_name = 'observations'
|
||||||
|
|
||||||
uri = QgsDataSourceUri()
|
uri = QgsDataSourceUri()
|
||||||
uri.setConnection(host ,port ,dbname ,user ,mdp)
|
uri.setConnection(host ,port ,dbname ,user ,mdp)
|
||||||
|
|
||||||
# Centroide
|
## Centroide
|
||||||
if self.dlg.centroide.isChecked() == 1 :
|
if self.dlg.centroide.isChecked() == 1 :
|
||||||
if reqwhere_final.find('()') != -1 :
|
if reqwhere_final.find('()') != -1 :
|
||||||
reqwhere_final = ''
|
reqwhere_final = ''
|
||||||
@ -756,9 +792,9 @@ class SICEN(object):
|
|||||||
#groups = toc.
|
#groups = toc.
|
||||||
#groups = toc.groups()
|
#groups = toc.groups()
|
||||||
#index = groups.index(nomgroupe)
|
#index = groups.index(nomgroupe)
|
||||||
# index = 1
|
index = 1
|
||||||
|
|
||||||
# Polygone
|
### Polygone
|
||||||
reqwhere_final_poly = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POLYGON%'" + ')'
|
reqwhere_final_poly = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POLYGON%'" + ')'
|
||||||
if reqwhere_final_poly.find('()') != -1 :
|
if reqwhere_final_poly.find('()') != -1 :
|
||||||
reqwhere_final_poly = "(GeometryType(geometrie) LIKE '%POLYGON%')"
|
reqwhere_final_poly = "(GeometryType(geometrie) LIKE '%POLYGON%')"
|
||||||
@ -777,7 +813,7 @@ class SICEN(object):
|
|||||||
#groupe.addLayer(layer_poly)
|
#groupe.addLayer(layer_poly)
|
||||||
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_poly))
|
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_poly))
|
||||||
|
|
||||||
# Point
|
### Point
|
||||||
reqwhere_final_point = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POINT%'" + ')'
|
reqwhere_final_point = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POINT%'" + ')'
|
||||||
if reqwhere_final_point.find('()') != -1 :
|
if reqwhere_final_point.find('()') != -1 :
|
||||||
reqwhere_final_point = "(GeometryType(geometrie) LIKE '%POINT%')"
|
reqwhere_final_point = "(GeometryType(geometrie) LIKE '%POINT%')"
|
||||||
@ -796,7 +832,7 @@ class SICEN(object):
|
|||||||
#groupe.addLayer(layer_point)
|
#groupe.addLayer(layer_point)
|
||||||
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_point))
|
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_point))
|
||||||
|
|
||||||
# Ligne
|
### Ligne
|
||||||
reqwhere_final_ligne = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%LINE%'" + ')'
|
reqwhere_final_ligne = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%LINE%'" + ')'
|
||||||
if reqwhere_final_ligne.find('()') != -1 :
|
if reqwhere_final_ligne.find('()') != -1 :
|
||||||
reqwhere_final_ligne = "(GeometryType(geometrie) LIKE '%LINE%')"
|
reqwhere_final_ligne = "(GeometryType(geometrie) LIKE '%LINE%')"
|
||||||
@ -819,7 +855,7 @@ class SICEN(object):
|
|||||||
#legende.setGroupExpanded (index, True)
|
#legende.setGroupExpanded (index, True)
|
||||||
|
|
||||||
#self.iface.messageBar().pushMessage(u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=QgsMessageBar.INFO, duration=10)
|
#self.iface.messageBar().pushMessage(u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=QgsMessageBar.INFO, duration=10)
|
||||||
self.iface.messageBar().pushMessage("Info", u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=0, duration=10)
|
self.iface.messageBar().pushMessage("Info", u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=Qgis.Success, duration=10)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -827,9 +863,9 @@ class SICEN(object):
|
|||||||
|
|
||||||
layer = self.iface.activeLayer()
|
layer = self.iface.activeLayer()
|
||||||
|
|
||||||
if layer is None:
|
if layer == None :
|
||||||
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner une table !", level=QgsMessageBar.WARNING, duration=5)
|
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner une table !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner une table !", level=1, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner une table !", level=Qgis.Warning, duration=5)
|
||||||
|
|
||||||
else :
|
else :
|
||||||
selection = layer.selectedFeatures()
|
selection = layer.selectedFeatures()
|
||||||
@ -841,13 +877,13 @@ class SICEN(object):
|
|||||||
buffer = '100'
|
buffer = '100'
|
||||||
|
|
||||||
account = login_base("account")
|
account = login_base("account")
|
||||||
# user = account[0]
|
user = account[0]
|
||||||
# mdp = account[1]
|
mdp = account[1]
|
||||||
# host = account[2]
|
host = account[2]
|
||||||
# port = account[3]
|
port = account[3]
|
||||||
# dbname = account[4]
|
dbname = account[4]
|
||||||
cur = account[7]
|
cur = account[7]
|
||||||
# con = account[8]
|
con = account[8]
|
||||||
|
|
||||||
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)
|
||||||
@ -857,51 +893,44 @@ class SICEN(object):
|
|||||||
file = open(chemin_fichier, 'w', newline='', encoding='utf-8')
|
file = open(chemin_fichier, 'w', newline='', encoding='utf-8')
|
||||||
#file.write('\ufeff'.encode('utf8')) # BOM (optionel...Permet a Excel d'ouvrir proprement le fichier en UTF-8)
|
#file.write('\ufeff'.encode('utf8')) # BOM (optionel...Permet a Excel d'ouvrir proprement le fichier en UTF-8)
|
||||||
file.write('\ufeff')
|
file.write('\ufeff')
|
||||||
# délimiteur ';' pour faciliter l'ouverture avec Excel
|
writer = csv.writer(file, delimiter = ';') # délimiteur ';' pour faciliter l'ouverture avec Excel
|
||||||
writer = csv.writer(file, delimiter=';')
|
writer.writerow(['Classe', 'Ordre', 'Nom Complet', 'Nom Vernaculaire','cd_ref', 'Date Derniere Observation']) # Création des entêtes
|
||||||
# Création des entêtes
|
|
||||||
writer.writerow(['Classe', 'Ordre', 'Nom Complet', 'Nom Vernaculaire', 'cd_ref', 'Date Derniere Observation'])
|
|
||||||
|
|
||||||
# Boucle d'écriture ligne par ligne dans le csv
|
for row in data_sp : # Boucle d'écriture ligne par ligne dans le csv
|
||||||
for row in data_sp:
|
|
||||||
#print(1)
|
#print(1)
|
||||||
list_sp = []
|
list_sp = []
|
||||||
# Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
if row[0] == None : # Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
||||||
if row[0] is None:
|
|
||||||
row0 = str(row[0])
|
row0 = str(row[0])
|
||||||
row0 = ''
|
row0 = ''
|
||||||
else :
|
else :
|
||||||
row0 = row[0]
|
row0 = row[0]
|
||||||
#print(row0)
|
#print(row0)
|
||||||
list_sp.append(row0)
|
list_sp.append(row0)
|
||||||
# Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
if row[1] == None : # Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
||||||
if row[1] is None:
|
|
||||||
row1 = str(row[1])
|
row1 = str(row[1])
|
||||||
row1 = ''
|
row1 = ''
|
||||||
else :
|
else :
|
||||||
row1 = row[1]
|
row1 = row[1]
|
||||||
list_sp.append(row1)
|
list_sp.append(row1)
|
||||||
# Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
if row[2] == None : # Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
||||||
if row[2] is None:
|
|
||||||
row2 = str(row[2])
|
row2 = str(row[2])
|
||||||
row2 = ''
|
row2 = ''
|
||||||
else :
|
else :
|
||||||
row2 = row[2]
|
row2 = row[2]
|
||||||
list_sp.append(row2)
|
list_sp.append(row2)
|
||||||
# Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
if row[3] == None : # Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
||||||
if row[3] is None:
|
|
||||||
row3 = str(row[3])
|
row3 = str(row[3])
|
||||||
row3 = ''
|
row3 = ''
|
||||||
else :
|
else :
|
||||||
row3 = row[3]
|
row3 = row[3]
|
||||||
list_sp.append(row3)
|
list_sp.append(row3)
|
||||||
if row[4] is None:
|
if row[4] == None :
|
||||||
row4 = str(row[4])
|
row4 = str(row[4])
|
||||||
row4 = ''
|
row4 = ''
|
||||||
else :
|
else :
|
||||||
row4 = row[4]
|
row4 = row[4]
|
||||||
list_sp.append(row4)
|
list_sp.append(row4)
|
||||||
if row[5] is None:
|
if row[5] == None :
|
||||||
row5 = str(row[5])
|
row5 = str(row[5])
|
||||||
row5 = ''
|
row5 = ''
|
||||||
else :
|
else :
|
||||||
@ -912,12 +941,12 @@ class SICEN(object):
|
|||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
#self.iface.messageBar().pushMessage(u"Export réussi dans " + chemin_fichier , level=QgsMessageBar.INFO, duration=5)
|
#self.iface.messageBar().pushMessage(u"Export réussi dans " + chemin_fichier , level=QgsMessageBar.INFO, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Export réussi dans " + chemin_fichier, level=0, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Export réussi dans " + chemin_fichier, level=Qgis.Success, duration=5)
|
||||||
|
|
||||||
elif (layer.selectedFeatureCount() == 0) :
|
elif (layer.selectedFeatureCount() == 0) :
|
||||||
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner au moins un polygone !", level=QgsMessageBar.WARNING, duration=5)
|
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner au moins un polygone !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner au moins un polygone !", level=1, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner au moins un polygone !", level=Qgis.Warning, duration=5)
|
||||||
|
|
||||||
else :
|
else :
|
||||||
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner qu'un seul polygone !", level=QgsMessageBar.WARNING, duration=5)
|
#self.iface.messageBar().pushMessage(u"Vous devez sélectionner qu'un seul polygone !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous ne devez sélectionner qu'un seul polygone !", level=1, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous ne devez sélectionner qu'un seul polygone !", level=Qgis.Warning, duration=5)
|
||||||
|
|||||||
@ -20,8 +20,8 @@ Filtre sur données SICEN
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# from qgis.PyQt import QtCore, QtGui
|
from qgis.PyQt import QtCore, QtGui
|
||||||
from qgis.PyQt.QtWidgets import QDialog
|
from qgis.PyQt.QtWidgets import QAction, QDialog
|
||||||
from .ui_sicen import Ui_SICEN
|
from .ui_sicen import Ui_SICEN
|
||||||
# create the dialog for zoom to point
|
# create the dialog for zoom to point
|
||||||
|
|
||||||
|
|||||||
@ -3,10 +3,10 @@
|
|||||||
import configparser
|
import configparser
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
# import base64
|
|
||||||
# import psycopg2
|
|
||||||
# import psycopg2.extras
|
|
||||||
import os
|
import os
|
||||||
|
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
|
||||||
@ -90,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_SICEN\\tools")))
|
||||||
for item in args:
|
for item in args:
|
||||||
path = abspath(join(path, item))
|
path = abspath(join(path, item))
|
||||||
return path
|
return path
|
||||||
@ -108,51 +108,46 @@ def load_ui(*args):
|
|||||||
|
|
||||||
return ui_class
|
return ui_class
|
||||||
|
|
||||||
|
|
||||||
def pyperclip():
|
def pyperclip():
|
||||||
dst = dirname(dirname(__file__))+"\\tools\\"
|
dst = dirname(dirname(__file__))+"\\tools\\"
|
||||||
if os.access('N:/',os.R_OK):
|
if os.access('N:/',os.R_OK):
|
||||||
src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
|
src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
|
||||||
try:
|
try:
|
||||||
shutil.copy(src, dst)
|
shutil.copy(src, dst)
|
||||||
except FileNotFoundError:
|
except:
|
||||||
print('404')
|
print('404')
|
||||||
except UnboundLocalError:
|
|
||||||
print('404')
|
|
||||||
|
|
||||||
|
|
||||||
def send_issues(url,titre,body,labels):
|
def send_issues(url,titre,body,labels):
|
||||||
import requests
|
import requests
|
||||||
import urllib.request
|
|
||||||
import json
|
import json
|
||||||
# import os
|
import os
|
||||||
# import qgis
|
import qgis
|
||||||
|
|
||||||
# usr = os.environ['USERNAME']
|
usr = os.environ['USERNAME']
|
||||||
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
|
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
|
||||||
url=url+'?token='+token
|
url=url+'?token='+token
|
||||||
|
|
||||||
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
|
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
|
||||||
|
|
||||||
|
|
||||||
payload = {'title': titre, 'body': body, 'labels': labels}
|
payload = {'title': titre, 'body': body, 'labels': labels}
|
||||||
try:
|
try:
|
||||||
urllib.request.urlopen('https://google.com')
|
urllib.request.urlopen('https://google.com')
|
||||||
binar = True
|
binar = True
|
||||||
except ValueError:
|
except:
|
||||||
binar = False
|
binar = False
|
||||||
r = ''
|
r = ''
|
||||||
if binar:
|
if binar:
|
||||||
r = requests.post(url, data=json.dumps(payload), headers=headers)
|
r = requests.post(url, data=json.dumps(payload), headers=headers)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def maj_verif(NAME):
|
def maj_verif(NAME):
|
||||||
import qgis
|
import qgis
|
||||||
import urllib.request
|
import urllib.request
|
||||||
iface = qgis.utils.iface
|
iface = qgis.utils.iface
|
||||||
from qgis.core import Qgis
|
from qgis.core import Qgis
|
||||||
|
|
||||||
# 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/latest/plugins.xml'
|
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
|
||||||
# print(URL)
|
# print(URL)
|
||||||
@ -161,7 +156,7 @@ def maj_verif(NAME):
|
|||||||
try:
|
try:
|
||||||
urllib.request.urlopen('https://google.com')
|
urllib.request.urlopen('https://google.com')
|
||||||
binar = True
|
binar = True
|
||||||
except urllib.error.URLError:
|
except:
|
||||||
binar = False
|
binar = False
|
||||||
if binar:
|
if binar:
|
||||||
try:
|
try:
|
||||||
@ -171,11 +166,11 @@ def maj_verif(NAME):
|
|||||||
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
|
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
|
||||||
if version_plugin != version:
|
if version_plugin != version:
|
||||||
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
|
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
|
||||||
except urllib.error.URLError:
|
except:
|
||||||
print("error gitea version ssl")
|
print("error gitea version ssl")
|
||||||
else:
|
else:
|
||||||
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
|
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
|
||||||
|
#return version_plugin
|
||||||
|
|
||||||
def devlog(NAME):
|
def devlog(NAME):
|
||||||
import qgis
|
import qgis
|
||||||
|
|||||||
@ -8,10 +8,9 @@
|
|||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
from builtins import object
|
from builtins import object
|
||||||
from qgis.PyQt import QtCore
|
from qgis.PyQt import QtCore, QtGui
|
||||||
from qgis.PyQt.QtGui import QFont
|
from qgis.PyQt.QtGui import QFont
|
||||||
# Modifié
|
from qgis.PyQt.QtWidgets import QAction, QDialog, QDialogButtonBox, QLabel, QApplication, QTabWidget, QWidget, QGroupBox, QGridLayout, QComboBox, QCheckBox, QCalendarWidget, QToolBox, QFrame, QLineEdit, QSizePolicy #Modifié
|
||||||
from qgis.PyQt.QtWidgets import QDialogButtonBox, QLabel, QApplication, QTabWidget, QWidget, QGroupBox, QGridLayout, QComboBox, QCheckBox, QCalendarWidget, QToolBox, QFrame, QLineEdit, QSizePolicy
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -22,14 +21,12 @@ except AttributeError:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
_encoding = QApplication.UnicodeUTF8
|
_encoding = QApplication.UnicodeUTF8
|
||||||
|
|
||||||
def _translate(context, text, disambig):
|
def _translate(context, text, disambig):
|
||||||
return QApplication.translate(context, text, disambig, _encoding)
|
return QApplication.translate(context, text, disambig, _encoding)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
def _translate(context, text, disambig):
|
def _translate(context, text, disambig):
|
||||||
return QApplication.translate(context, text, disambig)
|
return QApplication.translate(context, text, disambig)
|
||||||
|
|
||||||
|
|
||||||
class Ui_SICEN(object):
|
class Ui_SICEN(object):
|
||||||
def setupUi(self, SICEN):
|
def setupUi(self, SICEN):
|
||||||
SICEN.setObjectName(_fromUtf8("SICEN"))
|
SICEN.setObjectName(_fromUtf8("SICEN"))
|
||||||
@ -684,8 +681,7 @@ class Ui_SICEN(object):
|
|||||||
self.Emprise.setCurrentIndex(0)
|
self.Emprise.setCurrentIndex(0)
|
||||||
self.protections.setCurrentIndex(0)
|
self.protections.setCurrentIndex(0)
|
||||||
self.buttonBox.accepted.connect(SICEN.accept)
|
self.buttonBox.accepted.connect(SICEN.accept)
|
||||||
# Modifié
|
self.buttonBox.rejected.connect(SICEN.reject) #Modifié
|
||||||
self.buttonBox.rejected.connect(SICEN.reject)
|
|
||||||
QtCore.QMetaObject.connectSlotsByName(SICEN)
|
QtCore.QMetaObject.connectSlotsByName(SICEN)
|
||||||
|
|
||||||
def retranslateUi(self, SICEN):
|
def retranslateUi(self, SICEN):
|
||||||
@ -757,3 +753,4 @@ class Ui_SICEN(object):
|
|||||||
self.label_11.setText(_translate("SICEN", "4.", None))
|
self.label_11.setText(_translate("SICEN", "4.", None))
|
||||||
self.Emprise.setTabText(self.Emprise.indexOf(self.tab_4), _translate("SICEN", "Filtre par Emprise", None))
|
self.Emprise.setTabText(self.Emprise.indexOf(self.tab_4), _translate("SICEN", "Filtre par Emprise", None))
|
||||||
self.centroide.setText(_translate("SICEN", "Utiliser les centroïdes pour les observations autres que ponctuelles", None))
|
self.centroide.setText(_translate("SICEN", "Utiliser les centroïdes pour les observations autres que ponctuelles", None))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user