This commit is contained in:
Kovid Goyal 2013-06-27 13:29:09 +05:30
parent 86691f22a2
commit 32fccdb901

View File

@ -32,7 +32,7 @@ class Worker(Thread):
self.func, self.args = func, args self.func, self.args = func, args
def run(self): def run(self):
#time.sleep(1000) # time.sleep(1000)
try: try:
self.func(*self.args) self.func(*self.args)
except Exception as e: except Exception as e:
@ -46,7 +46,7 @@ class Worker(Thread):
class Sendmail(object): class Sendmail(object):
MAX_RETRIES = 1 MAX_RETRIES = 1
TIMEOUT = 15 * 60 # seconds TIMEOUT = 15 * 60 # seconds
def __init__(self): def __init__(self):
self.calculate_rate_limit() self.calculate_rate_limit()
@ -166,7 +166,7 @@ def email_news(mi, remove, get_fmts, done, job_manager):
plugboard_email_value = 'email' plugboard_email_value = 'email'
plugboard_email_formats = ['epub', 'mobi', 'azw3'] plugboard_email_formats = ['epub', 'mobi', 'azw3']
class EmailMixin(object): # {{{ class EmailMixin(object): # {{{
def send_by_mail(self, to, fmts, delete_from_library, subject='', send_ids=None, def send_by_mail(self, to, fmts, delete_from_library, subject='', send_ids=None,
do_auto_convert=True, specific_format=None): do_auto_convert=True, specific_format=None):
@ -208,10 +208,10 @@ class EmailMixin(object): # {{{
if not components: if not components:
components = [mi.title] components = [mi.title]
subjects.append(os.path.join(*components)) subjects.append(os.path.join(*components))
a = authors_to_string(mi.authors if mi.authors else \ a = authors_to_string(mi.authors if mi.authors else
[_('Unknown')]) [_('Unknown')])
texts.append(_('Attached, you will find the e-book') + \ texts.append(_('Attached, you will find the e-book') +
'\n\n' + t + '\n\t' + _('by') + ' ' + a + '\n\n' + \ '\n\n' + t + '\n\t' + _('by') + ' ' + a + '\n\n' +
_('in the %s format.') % _('in the %s format.') %
os.path.splitext(f)[1][1:].upper()) os.path.splitext(f)[1][1:].upper())
prefix = ascii_filename(t+' - '+a) prefix = ascii_filename(t+' - '+a)
@ -231,7 +231,7 @@ class EmailMixin(object): # {{{
auto = [] auto = []
if _auto_ids != []: if _auto_ids != []:
for id in _auto_ids: for id in _auto_ids:
if specific_format == None: if specific_format is None:
dbfmts = self.library_view.model().db.formats(id, index_is_id=True) dbfmts = self.library_view.model().db.formats(id, index_is_id=True)
formats = [f.lower() for f in (dbfmts.split(',') if dbfmts else formats = [f.lower() for f in (dbfmts.split(',') if dbfmts else
[])] [])]
@ -302,8 +302,9 @@ class EmailMixin(object): # {{{
sent_mails = email_news(mi, remove, sent_mails = email_news(mi, remove,
get_fmts, self.email_sent, self.job_manager) get_fmts, self.email_sent, self.job_manager)
if sent_mails: if sent_mails:
self.status_bar.show_message(_('Sent news to')+' '+\ self.status_bar.show_message(_('Sent news to')+' '+
', '.join(sent_mails), 3000) ', '.join(sent_mails), 3000)
# }}} # }}}