mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Rename store_download to ebook_download.
This commit is contained in:
parent
bec82bb02b
commit
4f40bdfdf8
@ -21,7 +21,7 @@ from calibre.gui2 import Dispatcher
|
|||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from calibre.utils.ipc.job import BaseJob
|
from calibre.utils.ipc.job import BaseJob
|
||||||
|
|
||||||
class StoreDownloadJob(BaseJob):
|
class EbookDownloadJob(BaseJob):
|
||||||
|
|
||||||
def __init__(self, callback, description, job_manager, db, cookie_file=None, url='', filename='', save_as_loc='', add_to_lib=True, tags=[]):
|
def __init__(self, callback, description, job_manager, db, cookie_file=None, url='', filename='', save_as_loc='', add_to_lib=True, tags=[]):
|
||||||
BaseJob.__init__(self, description)
|
BaseJob.__init__(self, description)
|
||||||
@ -57,7 +57,7 @@ class StoreDownloadJob(BaseJob):
|
|||||||
self.log_write(traceback.format_exc())
|
self.log_write(traceback.format_exc())
|
||||||
|
|
||||||
# Dump log onto disk
|
# Dump log onto disk
|
||||||
lf = PersistentTemporaryFile('store_log')
|
lf = PersistentTemporaryFile('ebook_download_log')
|
||||||
lf.write(self._log_file.getvalue())
|
lf.write(self._log_file.getvalue())
|
||||||
lf.close()
|
lf.close()
|
||||||
self.log_path = lf.name
|
self.log_path = lf.name
|
||||||
@ -69,7 +69,7 @@ class StoreDownloadJob(BaseJob):
|
|||||||
def log_write(self, what):
|
def log_write(self, what):
|
||||||
self._log_file.write(what)
|
self._log_file.write(what)
|
||||||
|
|
||||||
class StoreDownloader(Thread):
|
class EbookDownloader(Thread):
|
||||||
|
|
||||||
def __init__(self, job_manager):
|
def __init__(self, job_manager):
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
@ -120,7 +120,7 @@ class StoreDownloader(Thread):
|
|||||||
import traceback
|
import traceback
|
||||||
failed = True
|
failed = True
|
||||||
exc = e
|
exc = e
|
||||||
job.log_write('\nSending failed...\n')
|
job.log_write('\nDownloading failed...\n')
|
||||||
job.log_write(traceback.format_exc())
|
job.log_write(traceback.format_exc())
|
||||||
|
|
||||||
if not self._run:
|
if not self._run:
|
||||||
@ -185,32 +185,31 @@ class StoreDownloader(Thread):
|
|||||||
|
|
||||||
shutil.copy(job.tmp_file_name, save_loc)
|
shutil.copy(job.tmp_file_name, save_loc)
|
||||||
|
|
||||||
def download_from_store(self, callback, db, cookie_file=None, url='', filename='', save_as_loc='', add_to_lib=True, tags=[]):
|
def download_ebook(self, callback, db, cookie_file=None, url='', filename='', save_as_loc='', add_to_lib=True, tags=[]):
|
||||||
description = _('Downloading %s') % filename if filename else url
|
description = _('Downloading %s') % filename if filename else url
|
||||||
job = StoreDownloadJob(callback, description, self.job_manager, db, cookie_file, url, filename, save_as_loc, add_to_lib, tags)
|
job = EbookDownloadJob(callback, description, self.job_manager, db, cookie_file, url, filename, save_as_loc, add_to_lib, tags)
|
||||||
self.job_manager.add_job(job)
|
self.job_manager.add_job(job)
|
||||||
self.jobs.put(job)
|
self.jobs.put(job)
|
||||||
|
|
||||||
|
|
||||||
class StoreDownloadMixin(object):
|
class EbookDownloadMixin(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.store_downloader = StoreDownloader(self.job_manager)
|
self.ebook_downloader = EbookDownloader(self.job_manager)
|
||||||
|
|
||||||
def download_from_store(self, url='', cookie_file=None, filename='', save_as_loc='', add_to_lib=True, tags=[]):
|
def download_ebook(self, url='', cookie_file=None, filename='', save_as_loc='', add_to_lib=True, tags=[]):
|
||||||
if not self.store_downloader.is_alive():
|
if not self.ebook_downloader.is_alive():
|
||||||
self.store_downloader.start()
|
self.ebook_downloader.start()
|
||||||
if tags:
|
if tags:
|
||||||
if isinstance(tags, basestring):
|
if isinstance(tags, basestring):
|
||||||
tags = tags.split(',')
|
tags = tags.split(',')
|
||||||
self.store_downloader.download_from_store(Dispatcher(self.downloaded_from_store), self.library_view.model().db, cookie_file, url, filename, save_as_loc, add_to_lib, tags)
|
self.ebook_downloader.download_ebook(Dispatcher(self.downloaded_ebook), self.library_view.model().db, cookie_file, url, filename, save_as_loc, add_to_lib, tags)
|
||||||
self.status_bar.show_message(_('Downloading') + ' ' + filename if filename else url, 3000)
|
self.status_bar.show_message(_('Downloading') + ' ' + filename if filename else url, 3000)
|
||||||
|
|
||||||
def downloaded_from_store(self, job):
|
def downloaded_ebook(self, job):
|
||||||
if job.failed:
|
if job.failed:
|
||||||
self.job_exception(job, dialog_title=_('Failed to download book'))
|
self.job_exception(job, dialog_title=_('Failed to download ebook'))
|
||||||
return
|
return
|
||||||
|
|
||||||
self.status_bar.show_message(job.description + ' ' + _('finished'), 5000)
|
self.status_bar.show_message(job.description + ' ' + _('finished'), 5000)
|
||||||
|
|
||||||
|
|
@ -70,9 +70,9 @@ class NPWebView(QWebView):
|
|||||||
os.path.join(home, filename),
|
os.path.join(home, filename),
|
||||||
'*.*')
|
'*.*')
|
||||||
if name:
|
if name:
|
||||||
self.gui.download_from_store(url, cf, name, name, False)
|
self.gui.download_ebook(url, cf, name, name, False)
|
||||||
else:
|
else:
|
||||||
self.gui.download_from_store(url, cf, filename, tags=self.tags)
|
self.gui.download_ebook(url, cf, filename, tags=self.tags)
|
||||||
|
|
||||||
def ignore_ssl_errors(self, reply, errors):
|
def ignore_ssl_errors(self, reply, errors):
|
||||||
reply.ignoreSslErrors(errors)
|
reply.ignoreSslErrors(errors)
|
||||||
|
@ -33,7 +33,7 @@ from calibre.gui2.main_window import MainWindow
|
|||||||
from calibre.gui2.layout import MainWindowMixin
|
from calibre.gui2.layout import MainWindowMixin
|
||||||
from calibre.gui2.device import DeviceMixin
|
from calibre.gui2.device import DeviceMixin
|
||||||
from calibre.gui2.email import EmailMixin
|
from calibre.gui2.email import EmailMixin
|
||||||
from calibre.gui2.store_download import StoreDownloadMixin
|
from calibre.gui2.ebook_download import EbookDownloadMixin
|
||||||
from calibre.gui2.jobs import JobManager, JobsDialog, JobsButton
|
from calibre.gui2.jobs import JobManager, JobsDialog, JobsButton
|
||||||
from calibre.gui2.init import LibraryViewMixin, LayoutMixin
|
from calibre.gui2.init import LibraryViewMixin, LayoutMixin
|
||||||
from calibre.gui2.search_box import SearchBoxMixin, SavedSearchBoxMixin
|
from calibre.gui2.search_box import SearchBoxMixin, SavedSearchBoxMixin
|
||||||
@ -91,7 +91,7 @@ class SystemTrayIcon(QSystemTrayIcon): # {{{
|
|||||||
class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||||
TagBrowserMixin, CoverFlowMixin, LibraryViewMixin, SearchBoxMixin,
|
TagBrowserMixin, CoverFlowMixin, LibraryViewMixin, SearchBoxMixin,
|
||||||
SavedSearchBoxMixin, SearchRestrictionMixin, LayoutMixin, UpdateMixin,
|
SavedSearchBoxMixin, SearchRestrictionMixin, LayoutMixin, UpdateMixin,
|
||||||
StoreDownloadMixin
|
EbookDownloadMixin
|
||||||
):
|
):
|
||||||
'The main GUI'
|
'The main GUI'
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
|
|
||||||
LayoutMixin.__init__(self)
|
LayoutMixin.__init__(self)
|
||||||
EmailMixin.__init__(self)
|
EmailMixin.__init__(self)
|
||||||
StoreDownloadMixin.__init__(self)
|
EbookDownloadMixin.__init__(self)
|
||||||
DeviceMixin.__init__(self)
|
DeviceMixin.__init__(self)
|
||||||
|
|
||||||
self.progress_indicator = ProgressIndicator(self)
|
self.progress_indicator = ProgressIndicator(self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user