Preferences/ConfigurationPages/EmailPage.py

Wed, 16 Oct 2013 15:16:54 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 16 Oct 2013 15:16:54 +0200
changeset 3025
67064c71df21
parent 3020
542e97d4ecb3
child 3034
7ce719013078
child 3058
0a02c433f52d
permissions
-rw-r--r--

Fixed a bunch of visible indentation issues.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2065
diff changeset
3 # Copyright (c) 2006 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the Email configuration page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
10 import smtplib
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
11 import socket
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
12
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
13 from PyQt4.QtCore import pyqtSlot, Qt
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
14 from PyQt4.QtGui import QApplication, QCursor
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
15
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
16 from E5Gui import E5MessageBox
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
17
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
18 from .ConfigurationPageBase import ConfigurationPageBase
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
19 from .Ui_EmailPage import Ui_EmailPage
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
23
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 class EmailPage(ConfigurationPageBase, Ui_EmailPage):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Class implementing the Email configuration page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def __init__(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1122
diff changeset
32 super().__init__()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.setObjectName("EmailPage")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 # set initial values
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.mailServerEdit.setText(Preferences.getUser("MailServer"))
388
174d7a46f58d Fixed an issue with the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
38 self.portSpin.setValue(Preferences.getUser("MailServerPort"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.emailEdit.setText(Preferences.getUser("Email"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.signatureEdit.setPlainText(Preferences.getUser("Signature"))
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 388
diff changeset
41 self.mailAuthenticationCheckBox.setChecked(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 Preferences.getUser("MailServerAuthentication"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.mailUserEdit.setText(Preferences.getUser("MailServerUser"))
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 388
diff changeset
44 self.mailPasswordEdit.setText(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 Preferences.getUser("MailServerPassword"))
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 388
diff changeset
46 self.useTlsCheckBox.setChecked(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 Preferences.getUser("MailServerUseTLS"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 def save(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 Public slot to save the Email configuration.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
53 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
54 "MailServer",
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.mailServerEdit.text())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
56 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
57 "MailServerPort",
388
174d7a46f58d Fixed an issue with the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
58 self.portSpin.value())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
59 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
60 "Email",
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.emailEdit.text())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
62 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
63 "Signature",
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.signatureEdit.toPlainText())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
65 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
66 "MailServerAuthentication",
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
67 self.mailAuthenticationCheckBox.isChecked())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
68 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
69 "MailServerUser",
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.mailUserEdit.text())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
71 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
72 "MailServerPassword",
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.mailPasswordEdit.text())
3025
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
74 Preferences.setUser(
67064c71df21 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
75 "MailServerUseTLS",
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
76 self.useTlsCheckBox.isChecked())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
78 def __updateTestButton(self):
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
79 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
80 Private slot to update the enabled state of the test button.
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
81 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
82 self.testButton.setEnabled(
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
83 self.mailAuthenticationCheckBox.isChecked() and \
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
84 self.mailUserEdit.text() != "" and \
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
85 self.mailPasswordEdit.text() != "" and \
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
86 self.mailServerEdit.text() != ""
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
87 )
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
88
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
89 @pyqtSlot(bool)
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
90 def on_mailAuthenticationCheckBox_toggled(self, checked):
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
91 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
92 Private slot to handle a change of the state of the authentication
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
93 selector.
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
94
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
95 @param checked state of the checkbox (boolean)
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
96 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
97 self.__updateTestButton()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
98
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
99 @pyqtSlot(str)
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
100 def on_mailUserEdit_textChanged(self, txt):
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
101 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
102 Private slot to handle a change of the text of the user edit.
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
103
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
104 @param txt current text of the edit (string)
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
105 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
106 self.__updateTestButton()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
107
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
108 @pyqtSlot(str)
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
109 def on_mailPasswordEdit_textChanged(self, txt):
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
110 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
111 Private slot to handle a change of the text of the user edit.
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
112
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
113 @param txt current text of the edit (string)
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
114 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
115 self.__updateTestButton()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
116
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
117 @pyqtSlot()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
118 def on_testButton_clicked(self):
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
119 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
120 Private slot to test the mail server login data.
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
121 """
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
122 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
123 QApplication.processEvents()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
124 try:
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
125 server = smtplib.SMTP(self.mailServerEdit.text(),
1061
3e21869872e3 Fixed PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1032
diff changeset
126 self.portSpin.value(),
1122
9871c792eaca Fixed a bug in EmailPage.py causing the login test to fail.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1061
diff changeset
127 timeout=10)
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
128 if self.useTlsCheckBox.isChecked():
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
129 server.starttls()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
130 try:
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
131 server.login(self.mailUserEdit.text(),
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
132 self.mailPasswordEdit.text())
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
133 QApplication.restoreOverrideCursor()
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
134 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
135 self,
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
136 self.trUtf8("Login Test"),
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
137 self.trUtf8("""The login test succeeded."""))
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
138 except (smtplib.SMTPException, socket.error) as e:
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
139 QApplication.restoreOverrideCursor()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
140 if isinstance(e, smtplib.SMTPResponseException):
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
141 errorStr = e.smtp_error.decode()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
142 elif isinstance(e, socket.timeout):
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
143 errorStr = str(e)
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
144 elif isinstance(e, socket.error):
2065
aea3ddf97aca Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
145 try:
aea3ddf97aca Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
146 errorStr = e[1]
aea3ddf97aca Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
147 except TypeError:
aea3ddf97aca Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
148 errorStr = str(e)
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
149 else:
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
150 errorStr = str(e)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
151 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
152 self,
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
153 self.trUtf8("Login Test"),
3010
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
154 self.trUtf8(
befeff46ec0f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2964
diff changeset
155 """<p>The login test failed.<br>Reason: {0}</p>""")
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
156 .format(errorStr))
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
157 server.quit()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
158 except (smtplib.SMTPException, socket.error) as e:
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
159 QApplication.restoreOverrideCursor()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
160 if isinstance(e, smtplib.SMTPResponseException):
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
161 errorStr = e.smtp_error.decode()
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
162 elif isinstance(e, socket.timeout):
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
163 errorStr = str(e)
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
164 elif isinstance(e, socket.error):
2065
aea3ddf97aca Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
165 try:
aea3ddf97aca Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
166 errorStr = e[1]
aea3ddf97aca Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
167 except TypeError:
aea3ddf97aca Fixed an issue in the Email config page testing the settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
168 errorStr = str(e)
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
169 else:
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
170 errorStr = str(e)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
171 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3010
diff changeset
172 self,
1032
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
173 self.trUtf8("Login Test"),
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
174 self.trUtf8("""<p>The login test failed.<br>Reason: {0}</p>""")
f7c2e348f6f3 Added function to test the login data to the Email config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
175 .format(errorStr))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
176
1061
3e21869872e3 Fixed PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1032
diff changeset
177
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 def create(dlg):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 Module function to create the configuration page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 @param dlg reference to the configuration dialog
2964
84b65fb9e780 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2632
diff changeset
183 @return reference to the instantiated page (ConfigurationPageBase)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 page = EmailPage()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
186 return page

eric ide

mercurial