-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
84 lines (72 loc) · 2.36 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
from PySide import QtCore, QtGui
from MainWindow import Ui_MainWindow
import os, sys, time
app = QtGui.QApplication(sys.argv)
mainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(mainWindow)
associatedLabels = {
'200': {'title': ui.room200title, 'speaker': ui.room200speaker},
'201': {'title': ui.room201title, 'speaker': ui.room201speaker},
'208': {'title': ui.room208title, 'speaker': ui.room208speaker},
}
sessions = []
images = []
def loadImages():
path = 'images/'
fileList = [ f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f)) ]
for imageFile in fileList:
images.append(QtGui.QPixmap(path + imageFile))
def loadSessions():
sessionDict = {}
with open('schedule.tab', 'r') as scheduleFile:
for line in scheduleFile:
if line[0] != '#':
parts = line.strip().split('\t')
parts[0] = int(parts[0])
if parts[0] not in sessionDict:
sessionDict[parts[0]] = {}
sessionDict[parts[0]][parts[1]] = parts[2:]
sessionTimes = list(sessionDict.keys())
sessionTimes.sort()
for timestamp in sessionTimes:
session = {
'time': timestamp,
'rooms': sessionDict[timestamp]
}
sessions.append(session)
import datetime
t = datetime.datetime.fromtimestamp(session['time']).strftime('%Y-%m-%d %H:%M:%S')
print("Session check: " + t)
for r in session['rooms']:
print('\t%s\t%s' % (r, session['rooms'][r]))
def update():
currentTime = int(time.time())# + 27*60*60 + 715*60
ui.clock.setText(time.strftime('%H:%M:%S'))
while len(sessions) > 0 and (currentTime - 11*60) > int(sessions[0]['time']):
sessions.pop(0)
if len(sessions) > 0:
session = sessions[0]
minutesLeft = int((session['time'] - currentTime)/60)
ui.nextSession.setText('Next session in %dm' % minutesLeft)
for room in associatedLabels.keys():
if room in session['rooms']:
associatedLabels[room]['title'].setText(session['rooms'][room][0])
associatedLabels[room]['speaker'].setText(session['rooms'][room][1])
else:
associatedLabels[room]['title'].setText('<html> <br/> </html>')
associatedLabels[room]['speaker'].setText('<html> </html>')
else:
pass
if currentTime % 4 == 0:
images.append(images.pop(0))
ui.logo.setPixmap(images[0])
def startTimer():
timer = QtCore.QTimer(mainWindow)
timer.timeout.connect(update)
timer.start(1000)
loadImages()
loadSessions()
startTimer()
mainWindow.show()
sys.exit(app.exec_())