-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrestore.py
44 lines (36 loc) · 1.46 KB
/
restore.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
from PyQt4 import QtCore,QtGui
import os,sys,ui_restore
from subprocess import Popen, PIPE
class backup(QtGui.QMainWindow):
returnedDate = ""
def __init__(self):
QtGui.QMainWindow.__init__(self)
uifile = ui_restore.Ui_MainWindow()
uifile.setupUi(self)
self.connect(uifile.calenderRestore,QtCore.SIGNAL("clicked(QDate)"),self.userDate)
self.connect(uifile.restoreButton,QtCore.SIGNAL("clicked()"),self.userDate)
def userDate(self,date):
selectedDate = QtCore.QDate.toString(date,"yyyy, MM, dd")
self.returnedDate = selectedDate
print self.returnedDate, type(str(selectedDate))
self.parsegitLog()
def gitCheckout(self,logDate):
print logDate
def parsegitLog(self):
parseLog = Popen('git log --pretty=oneline',shell=True, stdout=PIPE).stdout.readlines()
for logLines in parseLog:
catchLine = logLines.split(' ',3)
logDate = catchLine[3]
if logDate.strip() == str(self.returnedDate):
catchlogMsg = catchLine[0]
checkout = 'git checkout ' + catchlogMsg
os.system(checkout)
else:
pass
##############################################################################################################
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
window = backup()
window.show()
window.parsegitLog()
sys.exit(app.exec_())