Téléverser les fichiers vers "CenRa_COPIE"
This commit is contained in:
parent
c8966c7316
commit
b3f4f1ffa1
172
CenRa_COPIE/PythonSQL.py
Normal file
172
CenRa_COPIE/PythonSQL.py
Normal file
@ -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)
|
||||
)
|
||||
"""
|
||||
33
CenRa_COPIE/README.txt
Normal file
33
CenRa_COPIE/README.txt
Normal file
@ -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$
|
||||
234
CenRa_COPIE/copie_dialog_base.ui
Normal file
234
CenRa_COPIE/copie_dialog_base.ui
Normal file
@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CopieDialogBase</class>
|
||||
<widget class="QDialog" name="CopieDialogBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>386</width>
|
||||
<height>290</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Copie</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="button_box">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>250</y>
|
||||
<width>161</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="schema_label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>100</y>
|
||||
<width>121</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>10000</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dossier de destination </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_nom_table">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>150</y>
|
||||
<width>131</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Nom de la nouvelle table</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="schema">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>130</y>
|
||||
<width>351</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="table_destination">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>180</y>
|
||||
<width>291</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="annee">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>320</x>
|
||||
<y>180</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>aaaa</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="table_vide">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>220</y>
|
||||
<width>271</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cocher cette case pour vider la table de destination</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="table_source">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>60</y>
|
||||
<width>351</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="Titre">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>381</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copie d'une table</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="table_source_label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>75</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Table source </string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CopieDialogBase</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>button_box</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CopieDialogBase</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
37
CenRa_COPIE/metadata.txt
Normal file
37
CenRa_COPIE/metadata.txt
Normal file
@ -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
|
||||
|
||||
134
CenRa_COPIE/plugin_upload.py
Normal file
134
CenRa_COPIE/plugin_upload.py
Normal file
@ -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)
|
||||
Loading…
x
Reference in New Issue
Block a user