flake8 metabase
This commit is contained in:
parent
fd5d516f14
commit
d7267c0542
@ -4,13 +4,12 @@ __email__ = "info@3liz.org"
|
|||||||
|
|
||||||
|
|
||||||
from qgis.core import QgsApplication
|
from qgis.core import QgsApplication
|
||||||
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl
|
from qgis.PyQt.QtCore import Qt, QUrl, QSettings
|
||||||
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
||||||
from qgis.PyQt.QtWidgets import QAction, QMessageBox
|
from qgis.PyQt.QtWidgets import QAction
|
||||||
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 (
|
||||||
@ -24,8 +23,9 @@ 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,10 +33,8 @@ 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 qgis.PyQt.QtCore import *
|
# from CenRa_Metabase.issues import CenRa_Issues
|
||||||
|
|
||||||
|
|
||||||
class PgMetadata:
|
class PgMetadata:
|
||||||
@ -100,7 +98,6 @@ 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)
|
||||||
@ -159,6 +156,7 @@ 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/'))
|
||||||
@ -202,7 +200,6 @@ 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,6 +16,7 @@ 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,48 +14,31 @@ 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')
|
||||||
@ -150,11 +133,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:
|
except ValueError:
|
||||||
# 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()
|
||||||
@ -231,43 +214,15 @@ 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 + (
|
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>')
|
||||||
'<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 + (
|
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>')
|
||||||
'<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])]]
|
||||||
'<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
|
||||||
|
|
||||||
@ -292,7 +247,6 @@ publisher+
|
|||||||
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. """
|
||||||
'''
|
'''
|
||||||
@ -337,7 +291,7 @@ publisher+
|
|||||||
|
|
||||||
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. """
|
||||||
#link_logo=resources_path('icons', 'CEN_RA.png')
|
# ink_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()
|
||||||
@ -356,13 +310,13 @@ publisher+
|
|||||||
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)#, base_url)
|
self.viewer.setHtml(html)
|
||||||
|
|
||||||
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:
|
except AttributeError:
|
||||||
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 = ''
|
||||||
@ -392,7 +346,7 @@ publisher+
|
|||||||
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)
|
||||||
@ -457,10 +411,12 @@ publisher+
|
|||||||
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.'))
|
||||||
@ -495,4 +451,3 @@ publisher+
|
|||||||
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,60 +1,47 @@
|
|||||||
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
|
from qgis.PyQt import QtGui, QtCore
|
||||||
from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime
|
from qgis.PyQt.QtGui import 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
|
||||||
|
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:
|
except ValueError:
|
||||||
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__()
|
||||||
@ -74,7 +61,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)
|
||||||
@ -102,6 +89,7 @@ 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()
|
||||||
@ -250,12 +238,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=Qgis.Warning, duration=30)
|
iface.messageBar().pushMessage("Information:", "Cette couche n'est pas stockée dans PostgreSQL", level=1, 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:
|
except AttributeError:
|
||||||
uri = ''
|
uri = ''
|
||||||
return False
|
return False
|
||||||
if uri != '':
|
if uri != '':
|
||||||
@ -324,7 +312,6 @@ 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('')
|
||||||
@ -392,7 +379,6 @@ 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('')
|
||||||
@ -461,7 +447,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:
|
except ValueError:
|
||||||
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]))
|
||||||
@ -471,7 +457,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:
|
except ValueError:
|
||||||
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]))
|
||||||
@ -586,6 +572,7 @@ 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())
|
||||||
@ -597,6 +584,7 @@ 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())
|
||||||
@ -617,10 +605,10 @@ class Metabase_Editor(QDialog, EDITOR_CLASS):
|
|||||||
cur.execute(sql_sizefile)
|
cur.execute(sql_sizefile)
|
||||||
boolean = True
|
boolean = True
|
||||||
|
|
||||||
except:
|
except psycopg2.errors.UndefinedTable:
|
||||||
boolean = False
|
boolean = False
|
||||||
|
|
||||||
if boolean == True:
|
if boolean is True:
|
||||||
size_file = (cur.fetchall())[0][0]
|
size_file = (cur.fetchall())[0][0]
|
||||||
else:
|
else:
|
||||||
size_file = ''
|
size_file = ''
|
||||||
@ -658,9 +646,12 @@ 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()
|
||||||
@ -684,12 +675,18 @@ 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()
|
||||||
@ -713,10 +710,11 @@ 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()
|
||||||
|
|
||||||
@ -770,6 +768,7 @@ 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):
|
|
||||||
self.issues = CenRa_Issues()
|
# def issues_open(self):
|
||||||
self.issues.show()
|
# self.issues = CenRa_Issues()
|
||||||
|
# self.issues.show()
|
||||||
|
|||||||
@ -3,9 +3,12 @@
|
|||||||
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"
|
||||||
@ -92,14 +95,6 @@ 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.
|
||||||
@ -113,37 +108,51 @@ 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:
|
except ValueError:
|
||||||
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)
|
||||||
@ -152,7 +161,7 @@ def maj_verif(NAME):
|
|||||||
try:
|
try:
|
||||||
urllib.request.urlopen('https://google.com')
|
urllib.request.urlopen('https://google.com')
|
||||||
binar = True
|
binar = True
|
||||||
except:
|
except urllib.error.URLError:
|
||||||
binar = False
|
binar = False
|
||||||
if binar:
|
if binar:
|
||||||
try:
|
try:
|
||||||
@ -162,13 +171,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:
|
except urllib.error.URLError:
|
||||||
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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user