-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
651 lines (557 loc) · 31.5 KB
/
main.py
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
"""
Copyright (C) 2014 Alket Rexhepi
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
from PyQt4 import QtCore, QtGui
from os.path import expanduser
import sqlite3, hashlib, os , datetime, time, ftplib, shutil
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(800, 600)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8("icon.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.gridLayout_2 = QtGui.QGridLayout(self.centralwidget)
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
self.gridLayout = QtGui.QGridLayout()
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.comboBox_projects = QtGui.QComboBox(self.centralwidget)
self.comboBox_projects.setObjectName(_fromUtf8("comboBox_projects"))
self.comboBox_projects.addItem(_fromUtf8(""))
self.gridLayout.addWidget(self.comboBox_projects, 0, 0, 1, 1)
self.pushButton_compare = QtGui.QPushButton(self.centralwidget)
self.pushButton_compare.setObjectName(_fromUtf8("pushButton_compare"))
self.gridLayout.addWidget(self.pushButton_compare, 0, 1, 1, 1)
self.pushButton_update = QtGui.QPushButton(self.centralwidget)
self.pushButton_update.setObjectName(_fromUtf8("pushButton_update"))
self.gridLayout.addWidget(self.pushButton_update, 0, 2, 1, 1)
self.pushButton_edit = QtGui.QPushButton(self.centralwidget)
self.pushButton_edit.setObjectName(_fromUtf8("pushButton_edit"))
self.gridLayout.addWidget(self.pushButton_edit, 0, 3, 1, 1)
self.pushButton_new = QtGui.QPushButton(self.centralwidget)
self.pushButton_new.setObjectName(_fromUtf8("pushButton_new"))
self.gridLayout.addWidget(self.pushButton_new, 0, 4, 1, 1)
self.treeWidget = QtGui.QTreeWidget(self.centralwidget)
self.treeWidget.setObjectName(_fromUtf8("treeWidget"))
self.gridLayout.addWidget(self.treeWidget, 1, 0, 1, 5)
self.listWidget_log = QtGui.QListWidget(self.centralwidget)
self.listWidget_log.setMinimumSize(QtCore.QSize(0, 100))
self.listWidget_log.setMaximumSize(QtCore.QSize(16777215, 100))
self.listWidget_log.setObjectName(_fromUtf8("listWidget_log"))
self.gridLayout.addWidget(self.listWidget_log, 2, 0, 1, 5)
self.progressBar = QtGui.QProgressBar(self.centralwidget)
self.progressBar.setProperty("value", 0)
self.progressBar.setObjectName(_fromUtf8("progressBar"))
self.gridLayout.addWidget(self.progressBar, 3, 0, 1, 5)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
self.progressBar.hide()
MainWindow.setCentralWidget(self.centralwidget)
self.actionNew_Project = QtGui.QAction(MainWindow)
self.actionNew_Project.setObjectName(_fromUtf8("actionNew_Project"))
self.actionEdit_Projects = QtGui.QAction(MainWindow)
self.actionEdit_Projects.setObjectName(_fromUtf8("actionEdit_Projects"))
self.pushButton_update.setEnabled(False)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
#functions
self.pushButton_new.clicked.connect(self.newProjectForm)
self.pushButton_compare.clicked.connect(self.compareFiles)
self.pushButton_update.clicked.connect(self.updateAndUpload)
self.pushButton_edit.clicked.connect(self.editProjectForm)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "AUCHO", None))
self.pushButton_compare.setText(_translate("MainWindow", "Compare", None))
self.pushButton_update.setText(_translate("MainWindow", "Upload", None))
self.pushButton_edit.setText(_translate("MainWindow", "Edit", None))
self.pushButton_new.setText(_translate("MainWindow", "New", None))
self.treeWidget.headerItem().setText(0, _translate("MainWindow", "Upload", None))
self.treeWidget.headerItem().setText(1, _translate("MainWindow", "State", None))
self.treeWidget.headerItem().setText(2, _translate("MainWindow", "File", None))
self.actionNew_Project.setText(_translate("MainWindow", "New Project", None))
self.actionEdit_Projects.setText(_translate("MainWindow", "Edit Projects", None))
self.treeWidget.header().resizeSection(0,70)
self.treeWidget.header().resizeSection(1,100)
def logNew(self,msg):
self.listWidget_log.insertItem(0,str(datetime.datetime.now().strftime("%H:%M:%S"))+" - "+msg)
def newProjectForm(self):
NewProject.show()
def removeProject(self):
EditProject.hide()
areYouSure = QtGui.QMessageBox.question(None, 'Message',"Are you sure to quit?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if areYouSure == QtGui.QMessageBox.Yes:
index = self.comboBox_projects.currentIndex()
project = self.getProject(index)
con = sqlite3.connect('data/main.sql')
con.text_factory = str
cur = con.cursor()
con.execute("DELETE FROM main WHERE id=?",[project[0]])
con.commit()
os.remove('data/'+project[0]+'.sql')
os.remove('data/last/'+project[0]+'.sql')
self.showProjects()
def editProjectForm(self):
index = self.comboBox_projects.currentIndex()
project = self.getProject(index)
projectId = project[0]
projectTitle = project[1]
projectDir = project[2]
projectFTP_host = project[3]
projectFTP_user = project[4]
projectFTP_password = project[5]
projectFTP_dir = project[7]
ui_editProject.lineEdit_projectTitle.setText(projectTitle)
ui_editProject.lineEdit_localDirectory.setText(projectDir)
ui_editProject.lineEdit_ftpHost.setText(projectFTP_host)
ui_editProject.lineEdit_ftpUser.setText(projectFTP_user)
ui_editProject.lineEdit_ftpPassword.setText(projectFTP_password)
ui_editProject.lineEdit_ftpDirectory.setText(projectFTP_dir)
EditProject.show()
def editProjectEdit(self):
index = self.comboBox_projects.currentIndex()
project = self.getProject(index)
projectId = project[0]
con = sqlite3.connect('data/main.sql')
con.text_factory = str
cur = con.cursor()
cur.execute("UPDATE main SET title=? , directory=? , ftp_host=? , ftp_user=? , ftp_password=? , ftp_directory=? WHERE id=? ", [str(ui_editProject.lineEdit_projectTitle.text()), str(ui_editProject.lineEdit_localDirectory.text()), str(ui_editProject.lineEdit_ftpHost.text()), str(ui_editProject.lineEdit_ftpUser.text()), str(ui_editProject.lineEdit_ftpPassword.text()), str(ui_editProject.lineEdit_ftpDirectory.text()),projectId])
con.commit()
self.showProjects()
EditProject.hide()
def showProjects(self):
self.comboBox_projects.clear()
con = sqlite3.connect('data/main.sql')
con.text_factory = str
cur = con.cursor()
cur.execute("SELECT * FROM main")
rows = cur.fetchall()
for row in rows:
self.comboBox_projects.addItem(row[1])
if len(rows) == 0:
self.pushButton_compare.setEnabled(False)
self.pushButton_edit.setEnabled(False)
else:
self.pushButton_compare.setEnabled(True)
self.pushButton_edit.setEnabled(True)
def getProject(self,index):
con = sqlite3.connect('data/main.sql')
con.text_factory = str
cur = con.cursor()
cur.execute("SELECT * FROM main")
rows = cur.fetchall()
return rows[index]
def updateAndUpload(self):
itemCount = self.treeWidget.topLevelItemCount()
if itemCount > 0:
index = self.comboBox_projects.currentIndex()
project = self.getProject(index)
projectId = project[0]
projectDir = project[2]
projectFTP_host = project[3]
projectFTP_user = project[4]
projectFTP_password = project[5]
projectFTP_dir = project[7]
self.pushButton_compare.setEnabled(False)
self.pushButton_update.setEnabled(False)
self.pushButton_new.setEnabled(False)
self.treeWidget.setEnabled(False)
self.comboBox_projects.setEnabled(False)
everythingOk = False
if projectFTP_password == "":
password, button_ok = QtGui.QInputDialog.getText(None,"FTP Password","Please provide password for\n"+projectFTP_user+"@"+projectFTP_host,QtGui.QLineEdit.Password)
if button_ok:
projectFTP_password = str(password)
everythingOk = True
else:
everythingOk = False
else:
everythingOk = True
if everythingOk:
self.logNew("Trying to connect to FTP")
ftp = ftplib.FTP(projectFTP_host)
self.logNew(ftp.login(projectFTP_user,projectFTP_password))
self.logNew(ftp.getwelcome())
conLs = sqlite3.connect('data/last/'+projectId+'.sql')
conLs.text_factory = str
curLs = conLs.cursor()
#create dirs
for root, dirs, filenames in os.walk(projectDir):
remoteDir = projectFTP_dir+root[len(projectDir):]
if remoteDir != "":
try:
ftp.mkd(remoteDir)
except:
pass
#upload files
self.progressBar.setValue(0)
self.progressBar.setMaximum(itemCount)
self.progressBar.show()
currentItem = 0
while currentItem < itemCount:
item = self.treeWidget.topLevelItem(currentItem)
currentItem += 1
if item.checkState(0) == 2:
currentFile = projectDir+"/"+item.text(2)
remoteFile = projectFTP_dir+"/"+item.text(2)
cleanFile = str(item.text(2))
self.logNew(remoteFile+" : Uploading")
try:
self.logNew(remoteFile+" : "+ftp.storbinary('STOR '+str(remoteFile), open(str(currentFile), 'rb')))
except Exception,e:
self.logNew(remoteFile +" : "+str(e))
curLs.execute("SELECT * FROM project WHERE file=?",[cleanFile])
row = curLs.fetchone()
currentFileHash = hashlib.md5(open(currentFile).read()).hexdigest()
if row:
curLs.execute("UPDATE project SET hash=? WHERE file=?",[currentFileHash,cleanFile])
else:
curLs.execute("INSERT INTO project VALUES(?,?)",[cleanFile,currentFileHash])
self.progressBar.setValue(currentItem)
self.logNew(ftp.quit())
conLs.commit()
self.treeWidget.clear()
self.pushButton_update.setEnabled(False)
self.progressBar.hide()
self.logNew("Uploaded "+str(itemCount)+" Files.")
else:
self.logNew("No password provided")
else:
self.logNew("Nothing to upload.")
def compareFiles(self):
self.logNew("Comparing...")
self.pushButton_compare.setEnabled(False)
self.pushButton_update.setEnabled(False)
self.pushButton_new.setEnabled(False)
self.treeWidget.setEnabled(False)
self.comboBox_projects.setEnabled(False)
self.treeWidget.clear()
index = self.comboBox_projects.currentIndex()
project = self.getProject(index)
projectId = project[0]
projectDir = project[2]
if not os.path.isfile('data/'+projectId+'.sql'): #check if project is new
shutil.copy('data/template.sql','data/'+str(projectId)+'.sql')
shutil.copy('data/template.sql','data/last/'+str(projectId)+'.sql')
con = sqlite3.connect('data/'+projectId+'.sql')
con.text_factory = str
cur = con.cursor()
conLs = sqlite3.connect('data/last/'+projectId+'.sql')
conLs.text_factory = str
curLs = conLs.cursor()
totalFiles = 0
for root, dirs, filenames in os.walk(projectDir):
for f in filenames:
totalFiles += 1
self.progressBar.show()
self.progressBar.setValue(0)
self.progressBar.setMaximum(totalFiles)
currentProgress = 0
for root, dirs, filenames in os.walk(projectDir):
currentDir = root[len(projectDir)+1:]
if currentDir != "":
currentDir = currentDir+'/'
for f in filenames:
currentFile = currentDir+f
variables = [currentFile]
currentFileHash = hashlib.md5(open(root+'/'+f).read()).hexdigest()
curLs.execute("SELECT * FROM project WHERE file=?",variables)
row = curLs.fetchone()
if row: #is it in Last sql ?
if currentFileHash != row[1]: #did it change ?
newVariables = [currentFileHash,currentFile]
cur.execute("UPDATE project SET hash=? WHERE file=?",newVariables)
self.addItemToTree("Modified",currentFile)
else: #fil may be new ? if not update hash anyway
cur.execute("SELECT * FROM project WHERE file=?",variables)
row = cur.fetchone()
if row: # File exists , update hash
newVariables = [currentFileHash,currentFile]
cur.execute("UPDATE project SET hash=? WHERE file=?",newVariables)
else: # File is new
newVariables = [currentFile,currentFileHash]
cur.execute("INSERT INTO project VALUES(?,?)",newVariables)
self.addItemToTree("New",currentFile)
currentProgress += 1
self.progressBar.setValue(currentProgress)
con.commit()
self.pushButton_compare.setEnabled(True)
if self.treeWidget.topLevelItemCount() > 0:
self.logNew(str(self.treeWidget.topLevelItemCount())+" files to be uploaded.")
self.pushButton_update.setEnabled(True)
else:
self.logNew("Nothing to upload.")
self.pushButton_new.setEnabled(True)
self.treeWidget.setEnabled(True)
self.comboBox_projects.setEnabled(True)
self.progressBar.hide()
def addItemToTree(self,fileState,currentFile):
item = QtGui.QTreeWidgetItem(["",fileState,currentFile])
item.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
item.setCheckState(0,QtCore.Qt.Checked)
currentExt = currentFile.split('.')
currentExt = currentExt[len(currentExt)-1]
icon = QtGui.QIcon()
if currentExt == "html":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/text-html.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "css":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/text-css.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "bmp":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/image-bmp.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "jpg" or currentExt == "jpeg":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/image-jpeg.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "png":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/image-png.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "gif":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/image-gif.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "tga":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/image-tiff.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "ico":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/image-x-ico.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "xml":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/text-xml.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "wav":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/audio-x-generic.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "py" or currentExt == "pyc":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/text-x-python.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "psd":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/image-x-psd.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "avi" or currentExt == "mp4" or currentExt == "ogg" or currentExt == "ogv":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/video-x-generic.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "php":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/application-x-php.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "exe":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/application-x-ms-dos-executable.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "swf" or currentExt == "flv":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/application-x-flash-video.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "exe":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/application-x-ms-dos-executable.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "pdf":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/application-pdf.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "js":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/text-x-javascript.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "zip" or currentExt == "7z" or currentExt == "rar" or currentExt == ".gz":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/application-x-archive.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "tpl" or currentExt == "lng":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/text-x-generic-template")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "so" or currentExt == "bin" or currentExt == "sh":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/application-x-executable.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "xcf":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/gimp.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
elif currentExt == "svg" or currentExt == "ai":
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/inkscape.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
else:
icon.addPixmap(QtGui.QPixmap(_fromUtf8("data/icons/unknown.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
item.setIcon(2, icon)
self.treeWidget.insertTopLevelItem(0,item)
def newProjectAdd(self):
title = ui_newProject.lineEdit_projectTitle.text()
directory = ui_newProject.lineEdit_localDirectory.text()
ftp_host = ui_newProject.lineEdit_ftpHost.text()
ftp_user = ui_newProject.lineEdit_ftpUser.text()
ftp_password = ui_newProject.lineEdit_ftpPassword.text()
ftp_directory = ui_newProject.lineEdit_ftpDirectory.text()
if title != "" and directory != "" and ftp_host != "" and ftp_user != "" and ftp_directory != "":
con = sqlite3.connect('data/main.sql')
con.text_factory = str
cur = con.cursor()
projectId = time.time()
variables = [str(projectId),str(title),str(directory),str(ftp_host),str(ftp_user),str(ftp_password),"",str(ftp_directory),""]
cur.execute("INSERT INTO main VALUES(?,?,?,?,?,?,?,?,?)",variables)
con.commit()
self.comboBox_projects.addItem(str(title)) #replace with the new one
self.logNew("Created new project: "+str(title))
self.showProjects()
NewProject.hide()
else:
self.logNew("Please fill required fields.")
class Ui_formProjects(object):
def setupUi(self, formProjects):
formProjects.setObjectName(_fromUtf8("formProjects"))
formProjects.resize(406, 220)
formProjects.setMinimumSize(QtCore.QSize(406, 220))
formProjects.setMaximumSize(QtCore.QSize(406, 220))
self.widget = QtGui.QWidget(formProjects)
self.widget.setGeometry(QtCore.QRect(10, 10, 385, 214))
self.widget.setObjectName(_fromUtf8("widget"))
self.gridLayout = QtGui.QGridLayout(self.widget)
self.gridLayout.setMargin(0)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.pushButton_addProject = QtGui.QPushButton(formProjects)
self.pushButton_addProject.setGeometry(QtCore.QRect(157, 180, 94, 24))
self.pushButton_addProject.setObjectName(_fromUtf8("pushButton_addProject"))
self.label = QtGui.QLabel(self.widget)
self.label.setObjectName(_fromUtf8("label"))
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.lineEdit_projectTitle = QtGui.QLineEdit(self.widget)
self.lineEdit_projectTitle.setObjectName(_fromUtf8("lineEdit_projectTitle"))
self.gridLayout.addWidget(self.lineEdit_projectTitle, 0, 1, 1, 1)
self.label_2 = QtGui.QLabel(self.widget)
self.label_2.setObjectName(_fromUtf8("label_2"))
self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
self.lineEdit_localDirectory = QtGui.QLineEdit(self.widget)
self.lineEdit_localDirectory.setObjectName(_fromUtf8("lineEdit_localDirectory"))
self.gridLayout.addWidget(self.lineEdit_localDirectory, 1, 1, 1, 1)
self.pushButton_browse = QtGui.QPushButton(self.widget)
self.pushButton_browse.setObjectName(_fromUtf8("pushButton_browse"))
self.gridLayout.addWidget(self.pushButton_browse, 1, 2, 1, 1)
self.label_3 = QtGui.QLabel(self.widget)
self.label_3.setObjectName(_fromUtf8("label_3"))
self.gridLayout.addWidget(self.label_3, 2, 0, 1, 1)
self.lineEdit_ftpHost = QtGui.QLineEdit(self.widget)
self.lineEdit_ftpHost.setObjectName(_fromUtf8("lineEdit_ftpHost"))
self.gridLayout.addWidget(self.lineEdit_ftpHost, 2, 1, 1, 1)
self.label_4 = QtGui.QLabel(self.widget)
self.label_4.setObjectName(_fromUtf8("label_4"))
self.gridLayout.addWidget(self.label_4, 3, 0, 1, 1)
self.lineEdit_ftpUser = QtGui.QLineEdit(self.widget)
self.lineEdit_ftpUser.setObjectName(_fromUtf8("lineEdit_ftpUser"))
self.gridLayout.addWidget(self.lineEdit_ftpUser, 3, 1, 1, 1)
self.label_5 = QtGui.QLabel(self.widget)
self.label_5.setObjectName(_fromUtf8("label_5"))
self.gridLayout.addWidget(self.label_5, 4, 0, 1, 1)
self.lineEdit_ftpPassword = QtGui.QLineEdit(self.widget)
self.lineEdit_ftpPassword.setObjectName(_fromUtf8("lineEdit_ftpPassword"))
self.gridLayout.addWidget(self.lineEdit_ftpPassword, 4, 1, 1, 1)
self.label_7 = QtGui.QLabel(self.widget)
self.label_7.setObjectName(_fromUtf8("label_7"))
self.gridLayout.addWidget(self.label_7, 6, 0, 1, 1)
self.lineEdit_ftpDirectory = QtGui.QLineEdit(self.widget)
self.lineEdit_ftpDirectory.setObjectName(_fromUtf8("lineEdit_ftpDirectory"))
self.gridLayout.addWidget(self.lineEdit_ftpDirectory, 6, 1, 1, 1)
self.label_8 = QtGui.QLabel(self.widget)
self.label_8.setObjectName(_fromUtf8("label_8"))
self.gridLayout.addWidget(self.label_8, 7, 0, 1, 1)
self.retranslateUi(formProjects)
QtCore.QMetaObject.connectSlotsByName(formProjects)
#functions
self.pushButton_addProject.clicked.connect(ui.newProjectAdd)
self.pushButton_browse.clicked.connect(self.selectDir)
def retranslateUi(self, formProjects):
formProjects.setWindowTitle(_translate("formProjects", "Create New Project", None))
self.pushButton_addProject.setText(_translate("formProjects", "Add Project", None))
self.pushButton_browse.setText(_translate("formProjects", "Browse", None))
self.label.setText(_translate("formProjects", "Project Title", None))
self.label_2.setText(_translate("formProjects", "Local Directory", None))
self.label_3.setText(_translate("formProjects", "FTP Host", None))
self.label_4.setText(_translate("formProjects", "FTP User", None))
self.label_5.setText(_translate("formProjects", "FTP Password", None))
self.label_7.setText(_translate("formProjects", "FTP Directory", None))
def selectDir(self):
dirname = QtGui.QFileDialog.getExistingDirectory(None,'Select directory of project',expanduser('~'))
self.lineEdit_localDirectory.setText(dirname)
class Ui_formEditProject(object):
def setupUi(self, formProjects):
formProjects.setObjectName(_fromUtf8("formProjects"))
formProjects.resize(406, 220)
formProjects.setMinimumSize(QtCore.QSize(406, 220))
formProjects.setMaximumSize(QtCore.QSize(406, 220))
self.widget = QtGui.QWidget(formProjects)
self.widget.setGeometry(QtCore.QRect(10, 10, 385, 214))
self.widget.setObjectName(_fromUtf8("widget"))
self.gridLayout = QtGui.QGridLayout(self.widget)
self.gridLayout.setMargin(0)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.pushButton_editProject = QtGui.QPushButton(formProjects)
self.pushButton_editProject.setGeometry(QtCore.QRect(225, 180, 94, 24))
self.pushButton_editProject.setObjectName(_fromUtf8("pushButton_editProject"))
self.pushButton_removeProject = QtGui.QPushButton(formProjects)
self.pushButton_removeProject.setGeometry(QtCore.QRect(100, 180, 94, 24))
self.pushButton_removeProject.setObjectName(_fromUtf8("pushButton_removeProject"))
self.label = QtGui.QLabel(self.widget)
self.label.setObjectName(_fromUtf8("label"))
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.lineEdit_projectTitle = QtGui.QLineEdit(self.widget)
self.lineEdit_projectTitle.setObjectName(_fromUtf8("lineEdit_projectTitle"))
self.gridLayout.addWidget(self.lineEdit_projectTitle, 0, 1, 1, 1)
self.label_2 = QtGui.QLabel(self.widget)
self.label_2.setObjectName(_fromUtf8("label_2"))
self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
self.lineEdit_localDirectory = QtGui.QLineEdit(self.widget)
self.lineEdit_localDirectory.setObjectName(_fromUtf8("lineEdit_localDirectory"))
self.gridLayout.addWidget(self.lineEdit_localDirectory, 1, 1, 1, 1)
self.pushButton_browse = QtGui.QPushButton(self.widget)
self.pushButton_browse.setObjectName(_fromUtf8("pushButton_browse"))
self.gridLayout.addWidget(self.pushButton_browse, 1, 2, 1, 1)
self.label_3 = QtGui.QLabel(self.widget)
self.label_3.setObjectName(_fromUtf8("label_3"))
self.gridLayout.addWidget(self.label_3, 2, 0, 1, 1)
self.lineEdit_ftpHost = QtGui.QLineEdit(self.widget)
self.lineEdit_ftpHost.setObjectName(_fromUtf8("lineEdit_ftpHost"))
self.gridLayout.addWidget(self.lineEdit_ftpHost, 2, 1, 1, 1)
self.label_4 = QtGui.QLabel(self.widget)
self.label_4.setObjectName(_fromUtf8("label_4"))
self.gridLayout.addWidget(self.label_4, 3, 0, 1, 1)
self.lineEdit_ftpUser = QtGui.QLineEdit(self.widget)
self.lineEdit_ftpUser.setObjectName(_fromUtf8("lineEdit_ftpUser"))
self.gridLayout.addWidget(self.lineEdit_ftpUser, 3, 1, 1, 1)
self.label_5 = QtGui.QLabel(self.widget)
self.label_5.setObjectName(_fromUtf8("label_5"))
self.gridLayout.addWidget(self.label_5, 4, 0, 1, 1)
self.lineEdit_ftpPassword = QtGui.QLineEdit(self.widget)
self.lineEdit_ftpPassword.setObjectName(_fromUtf8("lineEdit_ftpPassword"))
self.gridLayout.addWidget(self.lineEdit_ftpPassword, 4, 1, 1, 1)
self.label_7 = QtGui.QLabel(self.widget)
self.label_7.setObjectName(_fromUtf8("label_7"))
self.gridLayout.addWidget(self.label_7, 6, 0, 1, 1)
self.lineEdit_ftpDirectory = QtGui.QLineEdit(self.widget)
self.lineEdit_ftpDirectory.setObjectName(_fromUtf8("lineEdit_ftpDirectory"))
self.gridLayout.addWidget(self.lineEdit_ftpDirectory, 6, 1, 1, 1)
self.label_8 = QtGui.QLabel(self.widget)
self.label_8.setObjectName(_fromUtf8("label_8"))
self.gridLayout.addWidget(self.label_8, 7, 0, 1, 1)
self.retranslateUi(formProjects)
QtCore.QMetaObject.connectSlotsByName(formProjects)
self.pushButton_editProject.clicked.connect(ui.editProjectEdit)
self.pushButton_removeProject.clicked.connect(ui.removeProject)
def retranslateUi(self, formProjects):
formProjects.setWindowTitle(_translate("formProjects", "Edit Project", None))
self.pushButton_editProject.setText(_translate("formProjects", "Edit", None))
self.pushButton_removeProject.setText(_translate("formProjects", "Delete", None))
self.pushButton_browse.setText(_translate("formProjects", "Browse", None))
self.label.setText(_translate("formProjects", "Project Title", None))
self.label_2.setText(_translate("formProjects", "Local Directory", None))
self.label_3.setText(_translate("formProjects", "FTP Host", None))
self.label_4.setText(_translate("formProjects", "FTP User", None))
self.label_5.setText(_translate("formProjects", "FTP Password", None))
self.label_7.setText(_translate("formProjects", "FTP Directory", None))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
ui.showProjects()
MainWindow.show()
NewProject = QtGui.QDialog(MainWindow)
NewProject.setModal(True)
ui_newProject = Ui_formProjects()
ui_newProject.setupUi(NewProject)
EditProject = QtGui.QDialog(MainWindow)
EditProject.setModal(True)
ui_editProject = Ui_formEditProject()
ui_editProject.setupUi(EditProject)
sys.exit(app.exec_())