Skip to content

Commit 7e6e499

Browse files
committed
Merge pop3 and linktesting branches.
2 parents 57a312d + cd28744 commit 7e6e499

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

informer.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def initUI(self):
3333
self.setWindowTitle("Informer's main window")
3434
self.setWindowIcon(QtGui.QIcon(os.path.dirname(os.path.realpath(__file__)) +
3535
'/call.png'))
36-
self.btn = QtGui.QPushButton('Button', self)
36+
self.btn = QtGui.QPushButton('Check mail', self)
3737
self.connect(self.btn, QtCore.SIGNAL("clicked()"), self.clicked)
38-
self.btn.setToolTip('This is a <b>QPushButton</b> widget')
38+
self.btn.setToolTip('Click for check you mail.')
3939
self.show()
4040

4141
def closeEvent(self, event):
@@ -53,7 +53,12 @@ def closeEvent(self, event):
5353
event.ignore()
5454

5555
def clicked(self):
56-
QtGui.QMessageBox.about(self, 'Socket availability', str(self.THREAD_PARSER.tn.sock_avail()), )
56+
mails = self.POP_PARSER.pop3_parser()
57+
for i,j in enumerate(mails):
58+
self.label = QtGui.QLabel(j[:-1], self)
59+
self.label.setMinimumWidth(200)
60+
self.label.move(20, 30+i*25)
61+
self.label.show()
5762

5863

5964
def qtWindow(THREAD_PARSER, POP_PARSER):

parsers/pop3_parser.py

+21-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import configparser
55
import threading
66

7-
from viewer.notify import view_tk
7+
from viewer.notify import view_notify
88

99
config = configparser.ConfigParser()
1010
config.read(os.path.dirname(os.path.realpath(__file__)) + '/../conf.ini')
@@ -18,19 +18,26 @@ def __init__(self):
1818
self.pop3_timeout = config.get('options', 'timeout')
1919

2020
def pop3_parser(self):
21+
pop = poplib.POP3(self.pop3_ip)
22+
pop.user(self.pop3_user)
23+
pop.pass_(self.pop3_pass)
24+
mails = []
25+
26+
if pop.stat()[0] > 0:
27+
numMessages = len(pop.list()[1])
28+
result = ''
29+
for i in range(numMessages):
30+
tmp = str(i+1) + ') From: ' + pop.retr(i+1)[1][0].decode('UTF-8').split(':')[1].lstrip()[1:-1] + '\n'
31+
result += tmp
32+
mails.append(tmp)
33+
view_notify(result)
34+
35+
pop.quit()
36+
return mails
37+
38+
def main(self):
2139
while True:
22-
pop = poplib.POP3(self.pop3_ip)
23-
pop.user(self.pop3_user)
24-
pop.pass_(self.pop3_pass)
25-
26-
if pop.stat()[0] > 0:
27-
numMessages = len(pop.list()[1])
28-
result = ''
29-
for i in range(numMessages):
30-
result += str(i+1) + ') From: ' + pop.retr(i+1)[1][0].decode('UTF-8').split(':')[1].lstrip()[1:-1] + '\n'
31-
view_tk(result)
32-
33-
pop.quit()
40+
self.pop3_parser()
3441
time.sleep(int(self.pop3_timeout))
3542

36-
run = pop3_parser
43+
run = main

0 commit comments

Comments
 (0)