Fix nasty bug that was preventing the use of a mail server to send email

This commit is contained in:
Kovid Goyal 2009-03-26 19:16:37 -07:00
parent 962a0b873d
commit e704037a34
4 changed files with 22 additions and 15 deletions

View File

@ -5,6 +5,7 @@ import os, traceback, Queue, time, socket
from threading import Thread, RLock
from itertools import repeat
from functools import partial
from binascii import unhexlify
from PyQt4.Qt import QMenu, QAction, QActionGroup, QIcon, SIGNAL, QPixmap, \
Qt
@ -385,7 +386,7 @@ class Emailer(Thread):
verbose=opts.verbose,
timeout=self.timeout, relay=opts.relay_host,
username=opts.relay_username,
password=opts.relay_password, port=opts.relay_port,
password=unhexlify(opts.relay_password), port=opts.relay_port,
encryption=opts.encryption)
results.append([jobname, None, None])
except Exception, e:

View File

@ -387,7 +387,9 @@ class ConfigDialog(QDialog, Ui_Dialog):
self.connect(self.relay_use_gmail, SIGNAL('clicked(bool)'),
self.create_gmail_relay)
self.connect(self.relay_show_password, SIGNAL('stateChanged(int)'),
lambda state:self.relay_password.setEchoMode(self.relay_password.Password))
lambda
state:self.relay_password.setEchoMode(self.relay_password.Password if
state == 0 else self.relay_password.Normal))
self.connect(self.email_add, SIGNAL('clicked(bool)'),
self.add_email_account)
self.connect(self.email_make_default, SIGNAL('clicked(bool)'),

View File

@ -118,12 +118,12 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.system_tray_icon.setContextMenu(self.system_tray_menu)
self.connect(self.quit_action, SIGNAL('triggered(bool)'), self.quit)
self.connect(self.donate_action, SIGNAL('triggered(bool)'), self.donate)
self.connect(self.restore_action, SIGNAL('triggered(bool)'),
lambda c : self.show())
self.connect(self.restore_action, SIGNAL('triggered()'),
self.show)
self.connect(self.action_show_book_details,
SIGNAL('triggered(bool)'), self.show_book_info)
self.connect(self.action_restart, SIGNAL('triggered(bool)'),
lambda c : self.quit(None, restart=True))
self.connect(self.action_restart, SIGNAL('triggered()'),
self.restart)
self.connect(self.system_tray_icon,
SIGNAL('activated(QSystemTrayIcon::ActivationReason)'),
self.system_tray_icon_activated)
@ -490,6 +490,9 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
def uncheck_cover_button(self, *args):
self.status_bar.cover_flow_button.setChecked(False)
def toggle_cover_flow(self, show):
if config['separate_cover_flow']:
if show:
@ -505,8 +508,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.library_view.scrollTo(self.library_view.currentIndex())
d.show()
self.connect(d, SIGNAL('finished(int)'),
lambda x: self.status_bar.\
cover_flow_button.setChecked(False))
self.uncheck_cover_button)
self.cf_dialog = d
else:
cfd = getattr(self, 'cf_dialog', None)
@ -1395,7 +1397,10 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
if self.device_connected:
self.memory_view.write_settings()
def quit(self, checked, restart=False):
def restart(self):
self.quit(restart=True)
def quit(self, checked=True, restart=False):
if not self.confirm_quit():
return
try:
@ -1596,5 +1601,5 @@ if __name__ == '__main__':
if os.path.exists(logfile):
log = open(logfile).read().decode('utf-8', 'ignore')
d = QErrorMessage(('<b>Error:</b>%s<br><b>Traceback:</b><br>'
'%s<b>Log:</b><br>')%(unicode(err), unicode(tb), log))
'%s<b>Log:</b><br>%s')%(unicode(err), unicode(tb), log))
d.exec_()

View File

@ -54,8 +54,7 @@ def get_mx(host):
def sendmail_direct(from_, to, msg, timeout, localhost, verbose):
import smtplib
hosts = get_mx(to.split('@')[-1].strip())
if 'darwin' in sys.platform:
timeout=None # Non blocking sockets dont work on OS X
timeout=None # Non blocking sockets sometimes don't work
s = smtplib.SMTP(timeout=timeout, local_hostname=localhost)
s.set_debuglevel(verbose)
if not hosts:
@ -81,8 +80,8 @@ def sendmail(msg, from_, to, localhost=None, verbose=0, timeout=30,
return sendmail_direct(from_, x, msg, timeout, localhost, verbose)
import smtplib
cls = smtplib.SMTP if encryption == 'TLS' else smtplib.SMTP_SSL
if 'darwin' in sys.platform:
timeout = None # Non-blocking sockets in OS X don't work
timeout = None # Non-blocking sockets sometimes don't work
port = int(port)
s = cls(timeout=timeout, local_hostname=localhost)
s.set_debuglevel(verbose)
if port < 0: