Base pour Gaspard

This commit is contained in:
Marc Ducobu 2021-06-17 10:54:41 +02:00
parent ef06ad583b
commit e602b4c143
4 changed files with 142 additions and 33 deletions

View File

@ -31,4 +31,25 @@ What's Next:
* Modify your user interface by opening WebExporter_dialog_base.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)
you make changes. This requires GNU make (gmake)
## Use docker to test the plugin
Docker test images to test connexions.
Start containers:
```
$ docker-compose up
```
and connect with
| protocol | login | password | address | port |
|----------|-------|----------|---------|------|
| ftps | username | password | localhost | 4567 |
| sftp | foo | pass | localhost | 4522 |
Be sure all file and dirs in `test/mnt` are recursively chown with `<you_user>` and `<your_group>`

25
docker-compose.yml Normal file
View File

@ -0,0 +1,25 @@
version: "3.6"
services:
# FTP, FTPS
# https://hub.docker.com/r/mikatux/ftps-server
ftps_server:
image: mikatux/ftps-server
volumes:
- ./mnt/ftps_server:/home/username
environment:
USER: username
PASSWORD: password
ports:
- "4567:21"
- "3000-3010:3000-3010"
# SFTP (SSH)
# https://hub.docker.com/r/atmoz/sftp
sftp_server:
image: atmoz/sftp:debian
volumes:
- ./mnt/sftp_server:/home/foo/upload
ports:
- "4522:22"
command: foo:pass:1000

View File

@ -179,6 +179,15 @@ class WebExporter:
action)
self.iface.removeToolBarIcon(action)
def export(self):
print("TODO : send file from the folder to the ftp")
"""
from ftplib import FTP
ftp = FTP()
ftp.connect('0.0.0.0', 4567)
ftp.login('username', 'password')
"""
def run(self):
"""Run method that performs all the real work"""
@ -188,6 +197,7 @@ class WebExporter:
if self.first_start == True:
self.first_start = False
self.dlg = WebExporterDialog()
self.dlg.button_box.accepted.connect(self.export)
# show the dialog
self.dlg.show()

View File

@ -1,7 +1,8 @@
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WebExporterDialogBase</class>
<widget class="QDialog" name="WebExporterDialogBase" >
<property name="geometry" >
<widget class="QDialog" name="WebExporterDialogBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@ -9,26 +10,78 @@
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Web Exporter</string>
</property>
<widget class="QDialogButtonBox" name="button_box" >
<property name="geometry" >
<rect>
<x>30</x>
<y>240</y>
<width>341</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>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="5" column="1">
<widget class="QgsFileWidget" name="mQgsFileWidget"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Source folder</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>User</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Host</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Destination</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="button_box">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsFileWidget</class>
<extends>QWidget</extends>
<header>qgsfilewidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
@ -37,13 +90,13 @@
<receiver>WebExporterDialogBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="source_label" >
<x>248</x>
<y>254</y>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destination_label" >
<x>157</x>
<y>274</y>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
@ -53,13 +106,13 @@
<receiver>WebExporterDialogBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="source_label" >
<x>316</x>
<y>260</y>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destination_label" >
<x>286</x>
<y>274</y>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>