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
|
import logging
from PyQt4 import QtGui
from PyQt4 import QtCore
vpnlogger = logging.getLogger('leap.openvpn')
class LogPaneMixin(object):
"""
a simple log pane
that writes new lines as they come
"""
def createLogBrowser(self):
"""
creates Browser widget for displaying logs
(in debug mode only).
"""
self.loggerBox = QtGui.QGroupBox()
logging_layout = QtGui.QVBoxLayout()
self.logbrowser = QtGui.QTextBrowser()
startStopButton = QtGui.QPushButton("&Connect")
self.startStopButton = startStopButton
logging_layout.addWidget(self.logbrowser)
logging_layout.addWidget(self.startStopButton)
self.loggerBox.setLayout(logging_layout)
# status box
self.statusBox = QtGui.QGroupBox()
grid = QtGui.QGridLayout()
self.updateTS = QtGui.QLabel('')
self.status_label = QtGui.QLabel('Disconnected')
self.ip_label = QtGui.QLabel('')
self.remote_label = QtGui.QLabel('')
tun_read_label = QtGui.QLabel("tun read")
self.tun_read_bytes = QtGui.QLabel("0")
tun_write_label = QtGui.QLabel("tun write")
self.tun_write_bytes = QtGui.QLabel("0")
grid.addWidget(self.updateTS, 0, 0)
grid.addWidget(self.status_label, 0, 1)
grid.addWidget(self.ip_label, 1, 0)
grid.addWidget(self.remote_label, 1, 1)
grid.addWidget(tun_read_label, 2, 0)
grid.addWidget(self.tun_read_bytes, 2, 1)
grid.addWidget(tun_write_label, 3, 0)
grid.addWidget(self.tun_write_bytes, 3, 1)
self.statusBox.setLayout(grid)
@QtCore.pyqtSlot(str)
def onLoggerNewLine(self, line):
"""
simple slot: writes new line to logger Pane.
"""
msg = line[:-1]
if self.debugmode:
self.logbrowser.append(msg)
vpnlogger.info(msg)
|