Bonjour à tous.
Pour commencer soyez indulgent je débute
Je suis entrain de scripter un petit soft pour envoyer et recevoir des fichiers par FTP. Pour cela j'utilise NCFTP.

L'interface je l'ai crée avec Designer.
Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
from PyQt4 import QtCore, QtGui
 
try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s
 
class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName(_fromUtf8("Dialog"))
        Dialog.resize(432, 389)
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "FTP Gui", None, QtGui.QApplication.UnicodeUTF8))
        Dialog.setToolTip(_fromUtf8(""))
        self.buttonBox = QtGui.QDialogButtonBox(Dialog)
        self.buttonBox.setGeometry(QtCore.QRect(70, 350, 341, 32))
        self.buttonBox.setMouseTracking(True)
        self.buttonBox.setAcceptDrops(True)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
        self.shell = QtGui.QTextEdit(Dialog)
        self.shell.setGeometry(QtCore.QRect(20, 210, 391, 131))
        self.shell.setMouseTracking(True)
        self.shell.setAutoFillBackground(False)
        self.shell.setFrameShape(QtGui.QFrame.WinPanel)
        self.shell.setFrameShadow(QtGui.QFrame.Sunken)
        self.shell.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.shell.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.shell.setAutoFormatting(QtGui.QTextEdit.AutoAll)
        self.shell.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextEditable|QtCore.Qt.TextEditorInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
        self.shell.setObjectName(_fromUtf8("shell"))
        self.FTP = QtGui.QLineEdit(Dialog)
        self.FTP.setGeometry(QtCore.QRect(140, 10, 271, 20))
        self.FTP.setAutoFillBackground(False)
        self.FTP.setText(QtGui.QApplication.translate("Dialog", "192.168.1.1", None, QtGui.QApplication.UnicodeUTF8))
        self.FTP.setDragEnabled(True)
        self.FTP.setObjectName(_fromUtf8("FTP"))
        self.Login = QtGui.QLineEdit(Dialog)
        self.Login.setGeometry(QtCore.QRect(140, 40, 271, 20))
        self.Login.setText(QtGui.QApplication.translate("Dialog", "user", None, QtGui.QApplication.UnicodeUTF8))
        self.Login.setDragEnabled(True)
        self.Login.setObjectName(_fromUtf8("Login"))
        self.MdP = QtGui.QLineEdit(Dialog)
        self.MdP.setGeometry(QtCore.QRect(140, 70, 271, 20))
        self.MdP.setText(QtGui.QApplication.translate("Dialog", "password", None, QtGui.QApplication.UnicodeUTF8))
        self.MdP.setDragEnabled(True)
        self.MdP.setObjectName(_fromUtf8("MdP"))
        self.LocalFolder = QtGui.QLineEdit(Dialog)
        self.LocalFolder.setGeometry(QtCore.QRect(140, 100, 271, 20))
        self.LocalFolder.setText(QtGui.QApplication.translate("Dialog", "/test", None, QtGui.QApplication.UnicodeUTF8))
        self.LocalFolder.setDragEnabled(True)
        self.LocalFolder.setObjectName(_fromUtf8("LocalFolder"))
        self.RemoteFolder = QtGui.QLineEdit(Dialog)
        self.RemoteFolder.setGeometry(QtCore.QRect(140, 130, 271, 20))
        self.RemoteFolder.setText(QtGui.QApplication.translate("Dialog", "/", None, QtGui.QApplication.UnicodeUTF8))
        self.RemoteFolder.setDragEnabled(True)
        self.RemoteFolder.setObjectName(_fromUtf8("RemoteFolder"))
        self.LabelFTP = QtGui.QLabel(Dialog)
        self.LabelFTP.setGeometry(QtCore.QRect(20, 10, 81, 16))
        self.LabelFTP.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Adresse FTP</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.LabelFTP.setObjectName(_fromUtf8("LabelFTP"))
        self.LabelLogin = QtGui.QLabel(Dialog)
        self.LabelLogin.setGeometry(QtCore.QRect(20, 40, 111, 16))
        self.LabelLogin.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Nom d\'utilisateur</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.LabelLogin.setObjectName(_fromUtf8("LabelLogin"))
        self.LabelMdP = QtGui.QLabel(Dialog)
        self.LabelMdP.setGeometry(QtCore.QRect(20, 70, 101, 16))
        self.LabelMdP.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Mot de Passe</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.LabelMdP.setObjectName(_fromUtf8("LabelMdP"))
        self.LabelLocalFolder = QtGui.QLabel(Dialog)
        self.LabelLocalFolder.setGeometry(QtCore.QRect(20, 100, 111, 16))
        self.LabelLocalFolder.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Répertoire Local</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.LabelLocalFolder.setObjectName(_fromUtf8("LabelLocalFolder"))
        self.LabelRemoteFolder = QtGui.QLabel(Dialog)
        self.LabelRemoteFolder.setGeometry(QtCore.QRect(20, 130, 121, 16))
        self.LabelRemoteFolder.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:9pt; font-weight:600;\">Répertoire Distant</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.LabelRemoteFolder.setObjectName(_fromUtf8("LabelRemoteFolder"))
        self.radioButtonUP = QtGui.QRadioButton(Dialog)
        self.radioButtonUP.setGeometry(QtCore.QRect(20, 170, 82, 17))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.radioButtonUP.setFont(font)
        self.radioButtonUP.setText(QtGui.QApplication.translate("Dialog", "Upload", None, QtGui.QApplication.UnicodeUTF8))
        self.radioButtonUP.setChecked(True)
        self.radioButtonUP.setObjectName(_fromUtf8("radioButtonUP"))
        self.radioButtonDown = QtGui.QRadioButton(Dialog)
        self.radioButtonDown.setGeometry(QtCore.QRect(90, 170, 82, 17))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.radioButtonDown.setFont(font)
        self.radioButtonDown.setText(QtGui.QApplication.translate("Dialog", "Download", None, QtGui.QApplication.UnicodeUTF8))
        self.radioButtonDown.setObjectName(_fromUtf8("radioButtonDown"))
        self.progressBar = QtGui.QProgressBar(Dialog)
        self.progressBar.setGeometry(QtCore.QRect(180, 170, 241, 23))
        font = QtGui.QFont()
        font.setBold(False)
        font.setWeight(50)
        self.progressBar.setFont(font)
        self.progressBar.setProperty("value", 0)
        self.progressBar.setObjectName(_fromUtf8("progressBar"))
        self.line = QtGui.QFrame(Dialog)
        self.line.setGeometry(QtCore.QRect(0, 150, 431, 20))
        self.line.setFrameShape(QtGui.QFrame.HLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.line.setObjectName(_fromUtf8("line"))
 
        self.retranslateUi(Dialog)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.choice)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.close)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
 
    def retranslateUi(self, Dialog):
        pass
 
    def choice(self):
        print("choix de l envoi")
        print(Login)
        if self.radioButtonUP == True:
            self.ncftpup
        if self.radioButtonDown == True:
            self.ncftpdown
 
    def ncftpup(self):
        Login="user"      # avec ca ca marche
        MdP="password"
        FTP="192.168.1.1"
        RemoteFolder="/"
        LocalFolder="/test"
        args = ["C:\\windows\\ncftpput.exe","-u", Login,"-p", MdP,"-R","-z", FTP, RemoteFolder, LocalFolder]
        cmd = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)    
        status=cmd.wait()
        pyerr = cmd.stderr.readlines()
        pyout = cmd.stdout.readlines()
        print(pyerr)
        print(pyout)
 
    def ncftpdown(self):
        args = ["C:\\windows\\ncftpget.exe","-u", Login,"-p", MdP,"-R","-z", FTP, LocalFolder, RemoteFolder]
        cmd = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)   
        status=cmd.wait()
        pyerr = cmd.stderr.readlines()
        pyout = cmd.stdout.readlines()
        print(pyerr)
        print(pyout)
 
 
if __name__ == "__main__":
    import os, sys, subprocess
    app = QtGui.QApplication(sys.argv)
    Dialog = QtGui.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())
Plusieurs problèmes : Comment dire à subprocess d'utiliser les valeurs de connexion que je tape dans la fenêtre (ex: Nom d'utilisateur : user) car quand je le mets à la main ça fonctionne.

Comment faire marcher les radiobuttons ainsi que la progressbar.

Pouvez-vous me donner des pistes? C'est la première fois que j'utilise Qt. Ca à l'air compliquer mais que c'est pratique avec Designer pour faire de belles fenêtres.
Mon objectif est de faire de simples scripts pour mon travail.

Merci pour votre aide.