Commit 36d26f20 authored by OzzieIsaacs's avatar OzzieIsaacs

Merge remote-tracking branch '625/625'

Update russian translation
parents 21582f09 03dc179b
This diff is collapsed.
...@@ -232,10 +232,25 @@ class WorkerThread(threading.Thread): ...@@ -232,10 +232,25 @@ class WorkerThread(threading.Thread):
bookid = self.queue[self.current]['bookid'] bookid = self.queue[self.current]['bookid']
format_old_ext = u'.' + self.queue[self.current]['settings']['old_book_format'].lower() format_old_ext = u'.' + self.queue[self.current]['settings']['old_book_format'].lower()
format_new_ext = u'.' + self.queue[self.current]['settings']['new_book_format'].lower() format_new_ext = u'.' + self.queue[self.current]['settings']['new_book_format'].lower()
# check to see if destination format already exists -
# if it does - mark the conversion task as complete and return a success
# this will allow send to kindle workflow to continue to work
if os.path.isfile(file_path + format_new_ext):
web.app.logger.info("Book id %d already converted to %s", bookid, format_new_ext)
cur_book = web.db.session.query(web.db.Books).filter(web.db.Books.id == bookid).first()
self.queue[self.current]['path'] = file_path
self.queue[self.current]['title'] = cur_book.title
self._handleSuccess()
return file_path + format_new_ext
else:
web.app.logger.info("Book id %d - target format of %s does not existing. Moving forward with convert.", bookid, format_new_ext)
# check if converter-executable is existing # check if converter-executable is existing
if not os.path.exists(web.ub.config.config_converterpath): if not os.path.exists(web.ub.config.config_converterpath):
self._handleError(_(u"Convertertool %(converter)s not found", converter=web.ub.config.config_converterpath)) self._handleError(_(u"Convertertool %(converter)s not found", converter=web.ub.config.config_converterpath))
return return
try: try:
# check which converter to use kindlegen is "1" # check which converter to use kindlegen is "1"
if format_old_ext == '.epub' and format_new_ext == '.mobi': if format_old_ext == '.epub' and format_new_ext == '.mobi':
...@@ -313,11 +328,7 @@ class WorkerThread(threading.Thread): ...@@ -313,11 +328,7 @@ class WorkerThread(threading.Thread):
self.queue[self.current]['title'] = cur_book.title self.queue[self.current]['title'] = cur_book.title
if web.ub.config.config_use_google_drive: if web.ub.config.config_use_google_drive:
os.remove(file_path + format_old_ext) os.remove(file_path + format_old_ext)
self.queue[self.current]['status'] = STAT_FINISH_SUCCESS self._handleSuccess()
self.UIqueue[self.current]['status'] = _('Finished')
self.UIqueue[self.current]['progress'] = "100 %"
self.UIqueue[self.current]['runtime'] = self._formatRuntime(
datetime.now() - self.queue[self.current]['starttime'])
return file_path + format_new_ext return file_path + format_new_ext
else: else:
error_message = format_new_ext.upper() + ' format not found on disk' error_message = format_new_ext.upper() + ' format not found on disk'
...@@ -434,12 +445,7 @@ class WorkerThread(threading.Thread): ...@@ -434,12 +445,7 @@ class WorkerThread(threading.Thread):
self.asyncSMTP.login(str(obj['settings']["mail_login"]), str(obj['settings']["mail_password"])) self.asyncSMTP.login(str(obj['settings']["mail_login"]), str(obj['settings']["mail_password"]))
self.asyncSMTP.sendmail(obj['settings']["mail_from"], obj['recipent'], msg) self.asyncSMTP.sendmail(obj['settings']["mail_from"], obj['recipent'], msg)
self.asyncSMTP.quit() self.asyncSMTP.quit()
self.queue[self.current]['status'] = STAT_FINISH_SUCCESS self._handleSuccess()
self.UIqueue[self.current]['status'] = _('Finished')
self.UIqueue[self.current]['progress'] = "100 %"
self.UIqueue[self.current]['runtime'] = self._formatRuntime(
datetime.now() - self.queue[self.current]['starttime'])
sys.stderr = org_stderr sys.stderr = org_stderr
except (MemoryError) as e: except (MemoryError) as e:
...@@ -452,8 +458,6 @@ class WorkerThread(threading.Thread): ...@@ -452,8 +458,6 @@ class WorkerThread(threading.Thread):
self._handleError(u'Error sending email: ' + e.strerror) self._handleError(u'Error sending email: ' + e.strerror)
return None return None
def _formatRuntime(self, runtime): def _formatRuntime(self, runtime):
self.UIqueue[self.current]['rt'] = runtime.total_seconds() self.UIqueue[self.current]['rt'] = runtime.total_seconds()
val = re.split('\:|\.', str(runtime))[0:3] val = re.split('\:|\.', str(runtime))[0:3]
...@@ -475,6 +479,12 @@ class WorkerThread(threading.Thread): ...@@ -475,6 +479,12 @@ class WorkerThread(threading.Thread):
datetime.now() - self.queue[self.current]['starttime']) datetime.now() - self.queue[self.current]['starttime'])
self.UIqueue[self.current]['message'] = error_message self.UIqueue[self.current]['message'] = error_message
def _handleSuccess(self):
self.queue[self.current]['status'] = STAT_FINISH_SUCCESS
self.UIqueue[self.current]['status'] = _('Finished')
self.UIqueue[self.current]['progress'] = "100 %"
self.UIqueue[self.current]['runtime'] = self._formatRuntime(
datetime.now() - self.queue[self.current]['starttime'])
class StderrLogger(object): class StderrLogger(object):
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment