mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix nasty bug that was preventing the use of a mail server to send email
This commit is contained in:
parent
962a0b873d
commit
e704037a34
@ -5,6 +5,7 @@ import os, traceback, Queue, time, socket
|
|||||||
from threading import Thread, RLock
|
from threading import Thread, RLock
|
||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from binascii import unhexlify
|
||||||
|
|
||||||
from PyQt4.Qt import QMenu, QAction, QActionGroup, QIcon, SIGNAL, QPixmap, \
|
from PyQt4.Qt import QMenu, QAction, QActionGroup, QIcon, SIGNAL, QPixmap, \
|
||||||
Qt
|
Qt
|
||||||
@ -385,7 +386,7 @@ class Emailer(Thread):
|
|||||||
verbose=opts.verbose,
|
verbose=opts.verbose,
|
||||||
timeout=self.timeout, relay=opts.relay_host,
|
timeout=self.timeout, relay=opts.relay_host,
|
||||||
username=opts.relay_username,
|
username=opts.relay_username,
|
||||||
password=opts.relay_password, port=opts.relay_port,
|
password=unhexlify(opts.relay_password), port=opts.relay_port,
|
||||||
encryption=opts.encryption)
|
encryption=opts.encryption)
|
||||||
results.append([jobname, None, None])
|
results.append([jobname, None, None])
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
@ -387,7 +387,9 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
|||||||
self.connect(self.relay_use_gmail, SIGNAL('clicked(bool)'),
|
self.connect(self.relay_use_gmail, SIGNAL('clicked(bool)'),
|
||||||
self.create_gmail_relay)
|
self.create_gmail_relay)
|
||||||
self.connect(self.relay_show_password, SIGNAL('stateChanged(int)'),
|
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.connect(self.email_add, SIGNAL('clicked(bool)'),
|
||||||
self.add_email_account)
|
self.add_email_account)
|
||||||
self.connect(self.email_make_default, SIGNAL('clicked(bool)'),
|
self.connect(self.email_make_default, SIGNAL('clicked(bool)'),
|
||||||
|
@ -118,12 +118,12 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.system_tray_icon.setContextMenu(self.system_tray_menu)
|
self.system_tray_icon.setContextMenu(self.system_tray_menu)
|
||||||
self.connect(self.quit_action, SIGNAL('triggered(bool)'), self.quit)
|
self.connect(self.quit_action, SIGNAL('triggered(bool)'), self.quit)
|
||||||
self.connect(self.donate_action, SIGNAL('triggered(bool)'), self.donate)
|
self.connect(self.donate_action, SIGNAL('triggered(bool)'), self.donate)
|
||||||
self.connect(self.restore_action, SIGNAL('triggered(bool)'),
|
self.connect(self.restore_action, SIGNAL('triggered()'),
|
||||||
lambda c : self.show())
|
self.show)
|
||||||
self.connect(self.action_show_book_details,
|
self.connect(self.action_show_book_details,
|
||||||
SIGNAL('triggered(bool)'), self.show_book_info)
|
SIGNAL('triggered(bool)'), self.show_book_info)
|
||||||
self.connect(self.action_restart, SIGNAL('triggered(bool)'),
|
self.connect(self.action_restart, SIGNAL('triggered()'),
|
||||||
lambda c : self.quit(None, restart=True))
|
self.restart)
|
||||||
self.connect(self.system_tray_icon,
|
self.connect(self.system_tray_icon,
|
||||||
SIGNAL('activated(QSystemTrayIcon::ActivationReason)'),
|
SIGNAL('activated(QSystemTrayIcon::ActivationReason)'),
|
||||||
self.system_tray_icon_activated)
|
self.system_tray_icon_activated)
|
||||||
@ -290,7 +290,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.connect(self.action_books_in_this_series, SIGNAL('triggered()'),
|
self.connect(self.action_books_in_this_series, SIGNAL('triggered()'),
|
||||||
lambda : self.show_similar_books('series'))
|
lambda : self.show_similar_books('series'))
|
||||||
self.connect(self.action_books_with_the_same_tags,
|
self.connect(self.action_books_with_the_same_tags,
|
||||||
SIGNAL('triggered()'),
|
SIGNAL('triggered()'),
|
||||||
lambda : self.show_similar_books('tag'))
|
lambda : self.show_similar_books('tag'))
|
||||||
self.connect(self.action_books_by_this_publisher, SIGNAL('triggered()'),
|
self.connect(self.action_books_by_this_publisher, SIGNAL('triggered()'),
|
||||||
lambda : self.show_similar_books('publisher'))
|
lambda : self.show_similar_books('publisher'))
|
||||||
@ -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):
|
def toggle_cover_flow(self, show):
|
||||||
if config['separate_cover_flow']:
|
if config['separate_cover_flow']:
|
||||||
if show:
|
if show:
|
||||||
@ -505,8 +508,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.library_view.scrollTo(self.library_view.currentIndex())
|
self.library_view.scrollTo(self.library_view.currentIndex())
|
||||||
d.show()
|
d.show()
|
||||||
self.connect(d, SIGNAL('finished(int)'),
|
self.connect(d, SIGNAL('finished(int)'),
|
||||||
lambda x: self.status_bar.\
|
self.uncheck_cover_button)
|
||||||
cover_flow_button.setChecked(False))
|
|
||||||
self.cf_dialog = d
|
self.cf_dialog = d
|
||||||
else:
|
else:
|
||||||
cfd = getattr(self, 'cf_dialog', None)
|
cfd = getattr(self, 'cf_dialog', None)
|
||||||
@ -1395,7 +1397,10 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
if self.device_connected:
|
if self.device_connected:
|
||||||
self.memory_view.write_settings()
|
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():
|
if not self.confirm_quit():
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
@ -1596,5 +1601,5 @@ if __name__ == '__main__':
|
|||||||
if os.path.exists(logfile):
|
if os.path.exists(logfile):
|
||||||
log = open(logfile).read().decode('utf-8', 'ignore')
|
log = open(logfile).read().decode('utf-8', 'ignore')
|
||||||
d = QErrorMessage(('<b>Error:</b>%s<br><b>Traceback:</b><br>'
|
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_()
|
d.exec_()
|
||||||
|
@ -54,8 +54,7 @@ def get_mx(host):
|
|||||||
def sendmail_direct(from_, to, msg, timeout, localhost, verbose):
|
def sendmail_direct(from_, to, msg, timeout, localhost, verbose):
|
||||||
import smtplib
|
import smtplib
|
||||||
hosts = get_mx(to.split('@')[-1].strip())
|
hosts = get_mx(to.split('@')[-1].strip())
|
||||||
if 'darwin' in sys.platform:
|
timeout=None # Non blocking sockets sometimes don't work
|
||||||
timeout=None # Non blocking sockets dont work on OS X
|
|
||||||
s = smtplib.SMTP(timeout=timeout, local_hostname=localhost)
|
s = smtplib.SMTP(timeout=timeout, local_hostname=localhost)
|
||||||
s.set_debuglevel(verbose)
|
s.set_debuglevel(verbose)
|
||||||
if not hosts:
|
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)
|
return sendmail_direct(from_, x, msg, timeout, localhost, verbose)
|
||||||
import smtplib
|
import smtplib
|
||||||
cls = smtplib.SMTP if encryption == 'TLS' else smtplib.SMTP_SSL
|
cls = smtplib.SMTP if encryption == 'TLS' else smtplib.SMTP_SSL
|
||||||
if 'darwin' in sys.platform:
|
timeout = None # Non-blocking sockets sometimes don't work
|
||||||
timeout = None # Non-blocking sockets in OS X don't work
|
port = int(port)
|
||||||
s = cls(timeout=timeout, local_hostname=localhost)
|
s = cls(timeout=timeout, local_hostname=localhost)
|
||||||
s.set_debuglevel(verbose)
|
s.set_debuglevel(verbose)
|
||||||
if port < 0:
|
if port < 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user