diff --git a/CenRa_COPIE/PythonSQL.py b/CenRa_COPIE/PythonSQL.py new file mode 100644 index 00000000..dbb7afc0 --- /dev/null +++ b/CenRa_COPIE/PythonSQL.py @@ -0,0 +1,172 @@ +import sys +import socket +import os +IPAddr=socket.gethostbyname(socket.gethostname()) +if IPAddr[0:11] == "100.100.100": #4269 + host = "100.100.100.11" + port = "5432" + dbname = "sig4269" + sigdb="sig4269" + refdb="ref_geo4269" + password = "McVities" +if IPAddr[0:9] == "192.168.0": #01 + host = "192.168.0.201" + port = "5432" + dbname = "sig01" + sigdb="sig01" + refdb="ref_geo01" + password = "McVities" +if IPAddr[0:9] == "192.168.1": #0726 + host = "192.168.1.201" + port = "5432" + dbname = "sig0726" + sigdb="sig0726" + refdb="ref_geo0726" + password = "McVities" +if sys.platform == 'linux': + os_user = os.environ['USER'] +else: + os_user = os.environ['USERNAME'] +if os_user == 'STAGE': + os_user='stage' + +geom = "geom" +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) +) +""" \ No newline at end of file diff --git a/CenRa_COPIE/README.txt b/CenRa_COPIE/README.txt new file mode 100644 index 00000000..b966603a --- /dev/null +++ b/CenRa_COPIE/README.txt @@ -0,0 +1,33 @@ +Plugin Builder Results + +Your plugin Copie was created in: + C:\Users\gcostes\.qgis2\python\plugins\Copie + +Your QGIS plugin directory is located at: + C:/Users/gcostes/.qgis2/python/plugins + +What's Next: + + * Copy the entire directory containing your new plugin to the QGIS plugin + directory + + * Compile the resources file using pyrcc4 + + * Run the tests (``make test``) + + * Test the plugin by enabling it in the QGIS plugin manager + + * Customize it by editing the implementation file: ``copie.py`` + + * Create your own custom icon, replacing the default icon.png + + * Modify your user interface by opening Copie.ui in Qt Designer + + * You can use the Makefile to compile your Ui and resource files when + you make changes. This requires GNU make (gmake) + +For more information, see the PyQGIS Developer Cookbook at: +http://www.qgis.org/pyqgis-cookbook/index.html + +(C) 2011-2014 GeoApt LLC - geoapt.com +Git revision : $Format:%H$ diff --git a/CenRa_COPIE/copie_dialog_base.ui b/CenRa_COPIE/copie_dialog_base.ui new file mode 100644 index 00000000..fbedefc7 --- /dev/null +++ b/CenRa_COPIE/copie_dialog_base.ui @@ -0,0 +1,234 @@ + + + CopieDialogBase + + + + 0 + 0 + 386 + 290 + + + + Copie + + + + + 100 + 250 + 161 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 20 + 100 + 121 + 29 + + + + + 10000 + 16777215 + + + + Dossier de destination + + + + + + 20 + 150 + 131 + 29 + + + + + 50 + false + + + + Nom de la nouvelle table + + + + + + 20 + 130 + 351 + 20 + + + + + + + 20 + 180 + 291 + 20 + + + + + 50 + false + + + + + + + 320 + 180 + 50 + 20 + + + + + 50 + false + + + + aaaa + + + Qt::AlignCenter + + + + + + 60 + 220 + 271 + 20 + + + + + 50 + false + + + + Cocher cette case pour vider la table de destination + + + + + false + + + + 20 + 60 + 351 + 20 + + + + + 50 + false + + + + + + + 0 + 0 + 381 + 31 + + + + + 14 + 75 + true + + + + Copie d'une table + + + Qt::AlignCenter + + + + + + 20 + 30 + 75 + 29 + + + + + 75 + 16777215 + + + + Table source + + + + + + + button_box + accepted() + CopieDialogBase + accept() + + + 20 + 20 + + + 20 + 20 + + + + + button_box + rejected() + CopieDialogBase + reject() + + + 20 + 20 + + + 20 + 20 + + + + + diff --git a/CenRa_COPIE/metadata.txt b/CenRa_COPIE/metadata.txt new file mode 100644 index 00000000..39c179c2 --- /dev/null +++ b/CenRa_COPIE/metadata.txt @@ -0,0 +1,37 @@ +# This file contains metadata for your plugin. Since +# version 2.0 of QGIS this is the proper way to supply +# information about a plugin. The old method of +# embedding metadata in __init__.py will +# is no longer supported since version 2.0. + +# This file should be included when you package your plugin.# Mandatory items: + +[general] +name=CenRA_COPIE +qgisMinimumVersion=3.0 +description=Permet la copie d'une table dans une base PostGis +version=1.3 +author=Conservatoire d'Espaces Naturels de Rhône-Alpes +email=si_besoin@cen-rhonealpes.fr + +# End of mandatory metadata + +# Recommended items: + +# Uncomment the following line and add your changelog: +changelog=Traduction pour QGIS v3 + +# Tags are comma separated with spaces allowed +tags=cenra, database, table + +repository=https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS +homepage=https://plateformesig.cenra-outils.org/ + +category=Plugins +icon=cenra.png +# experimental flag +experimental=True + +# deprecated flag (applies to the whole plugin, not just a single version) +deprecated=False + diff --git a/CenRa_COPIE/plugin_upload.py b/CenRa_COPIE/plugin_upload.py new file mode 100644 index 00000000..dfa46936 --- /dev/null +++ b/CenRa_COPIE/plugin_upload.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python +# coding=utf-8 +"""This script uploads a plugin package on the server. + Authors: A. Pasotti, V. Picavet + git sha : $TemplateVCSFormat +""" +from __future__ import print_function + +from future import standard_library +standard_library.install_aliases() +from builtins import input +import sys +import getpass +import xmlrpc.client +from optparse import OptionParser + +# Configuration +PROTOCOL = 'http' +SERVER = 'plugins.qgis.org' +PORT = '80' +ENDPOINT = '/plugins/RPC2/' +VERBOSE = False + + +def main(parameters, arguments): + """Main entry point. + + :param parameters: Command line parameters. + :param arguments: Command line arguments. + """ + address = "%s://%s:%s@%s:%s%s" % ( + PROTOCOL, + parameters.username, + parameters.password, + parameters.server, + parameters.port, + ENDPOINT) + # fix_print_with_import + # fix_print_with_import +print("Connecting to: %s" % hide_password(address)) + + server = xmlrpc.client.ServerProxy(address, verbose=VERBOSE) + + try: + plugin_id, version_id = server.plugin.upload( + xmlrpc.client.Binary(open(arguments[0]).read())) + # fix_print_with_import + # fix_print_with_import +print("Plugin ID: %s" % plugin_id) + # fix_print_with_import + # fix_print_with_import +print("Version ID: %s" % version_id) + except xmlrpc.client.ProtocolError as err: + # fix_print_with_import + print("A protocol error occurred") + # fix_print_with_import + # fix_print_with_import +print("URL: %s" % hide_password(err.url, 0)) + # fix_print_with_import + # fix_print_with_import +print("HTTP/HTTPS headers: %s" % err.headers) + # fix_print_with_import + # fix_print_with_import +print("Error code: %d" % err.errcode) + # fix_print_with_import + # fix_print_with_import +print("Error message: %s" % err.errmsg) + except xmlrpc.client.Fault as err: + # fix_print_with_import + print("A fault occurred") + # fix_print_with_import + # fix_print_with_import +print("Fault code: %d" % err.faultCode) + # fix_print_with_import + # fix_print_with_import +print("Fault string: %s" % err.faultString) + + +def hide_password(url, start=6): + """Returns the http url with password part replaced with '*'. + + :param url: URL to upload the plugin to. + :type url: str + + :param start: Position of start of password. + :type start: int + """ + start_position = url.find(':', start) + 1 + end_position = url.find('@') + return "%s%s%s" % ( + url[:start_position], + '*' * (end_position - start_position), + url[end_position:]) + + +if __name__ == "__main__": + parser = OptionParser(usage="%prog [options] plugin.zip") + parser.add_option( + "-w", "--password", dest="password", + help="Password for plugin site", metavar="******") + parser.add_option( + "-u", "--username", dest="username", + help="Username of plugin site", metavar="user") + parser.add_option( + "-p", "--port", dest="port", + help="Server port to connect to", metavar="80") + parser.add_option( + "-s", "--server", dest="server", + help="Specify server name", metavar="plugins.qgis.org") + options, args = parser.parse_args() + if len(args) != 1: + # fix_print_with_import + print("Please specify zip file.\n") + parser.print_help() + sys.exit(1) + if not options.server: + options.server = SERVER + if not options.port: + options.port = PORT + if not options.username: + # interactive mode + username = getpass.getuser() + # fix_print_with_import + # fix_print_with_import +print("Please enter user name [%s] :" % username, end=' ') + res = input() + if res != "": + options.username = res + else: + options.username = username + if not options.password: + # interactive mode + options.password = getpass.getpass() + main(options, args)