flake8 sicen
This commit is contained in:
parent
ca1d895eb1
commit
fd5d516f14
@ -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_SICEN\\tools")))
|
path = abspath(abspath(join(plugin_path(), "CenRa_COPIE\\tools")))
|
||||||
for item in args:
|
for item in args:
|
||||||
path = abspath(join(path, item))
|
path = abspath(join(path, item))
|
||||||
return path
|
return path
|
||||||
@ -108,72 +108,77 @@ 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:
|
except FileNotFoundError:
|
||||||
|
print('404')
|
||||||
|
except UnboundLocalError:
|
||||||
print('404')
|
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)
|
||||||
version = qgis.utils.pluginMetadata(NAME,'version')
|
version = qgis.utils.pluginMetadata(NAME, 'version')
|
||||||
len_version = len(version)
|
len_version = len(version)
|
||||||
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:
|
||||||
version_web = str(urllib.request.urlopen(URL).read())
|
version_web = str(urllib.request.urlopen(URL).read())
|
||||||
plugin_num = version_web.find(NAME)
|
plugin_num = version_web.find(NAME)
|
||||||
valeur_version_web = version_web.find('<version>',plugin_num)+9
|
valeur_version_web = version_web.find('<version>', plugin_num) + 9
|
||||||
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)
|
||||||
#return version_plugin
|
|
||||||
|
|
||||||
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>'
|
||||||
devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog')
|
devmaj = devmaj + qgis.utils.pluginMetadata(NAME, 'changelog')
|
||||||
return devmaj
|
return devmaj
|
||||||
Loading…
x
Reference in New Issue
Block a user