mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2025-12-06 08:52:55 +01:00
Report BG job failed entirely as individual books failed instead of just exception. For #1225
This commit is contained in:
parent
af5c78e2e9
commit
f8937c1af3
1 changed files with 26 additions and 12 deletions
|
|
@ -1827,6 +1827,7 @@ class FanFicFarePlugin(InterfaceAction):
|
||||||
self.download_job_manager.get_batch(options['tdir']).add_job(site,job)
|
self.download_job_manager.get_batch(options['tdir']).add_job(site,job)
|
||||||
job.tdir=options['tdir']
|
job.tdir=options['tdir']
|
||||||
job.site=site
|
job.site=site
|
||||||
|
job.orig_book_list = book_list
|
||||||
# set as part of job, otherwise *changing* reconsolidate_jobs
|
# set as part of job, otherwise *changing* reconsolidate_jobs
|
||||||
# after launch could cause job results to be ignored.
|
# after launch could cause job results to be ignored.
|
||||||
job.reconsolidate=prefs['reconsolidate_jobs'] # YYY batch update
|
job.reconsolidate=prefs['reconsolidate_jobs'] # YYY batch update
|
||||||
|
|
@ -2021,12 +2022,27 @@ class FanFicFarePlugin(InterfaceAction):
|
||||||
site = job.site
|
site = job.site
|
||||||
logger.debug("Batch Job:%s %s"%(tdir,site))
|
logger.debug("Batch Job:%s %s"%(tdir,site))
|
||||||
batch = self.download_job_manager.get_batch(tdir)
|
batch = self.download_job_manager.get_batch(tdir)
|
||||||
if job.reconsolidate or job.failed: # YYY batch update
|
|
||||||
|
if job.failed:
|
||||||
|
# logger.debug(job.orig_book_list)
|
||||||
|
## I don't *think* there would be any harm to modifying
|
||||||
|
## the original book list, but I elect not to chance it.
|
||||||
|
failedjobresult = copy.deepcopy(job.orig_book_list)
|
||||||
|
for x in failedjobresult:
|
||||||
|
if x['good']:
|
||||||
|
## may have failed before reaching BG job.
|
||||||
|
x['good'] = False
|
||||||
|
x['status'] = _('Error')
|
||||||
|
x['added'] = False
|
||||||
|
x['reportorder'] = x['listorder']+10000000 # force to end.
|
||||||
|
x['comment'] = _('Background Job Failed, see Calibre Jobs log.')
|
||||||
|
x['showerror'] = True
|
||||||
|
self.gui.job_exception(job, dialog_title=_('Background Job Failed to Download Stories for (%s)')%job.site)
|
||||||
|
job.result = failedjobresult
|
||||||
|
|
||||||
|
if job.reconsolidate: # YYY batch update
|
||||||
logger.debug("batch.finish_job(%s)"%site)
|
logger.debug("batch.finish_job(%s)"%site)
|
||||||
batch.finish_job(site)
|
batch.finish_job(site)
|
||||||
if job.failed:
|
|
||||||
self.gui.job_exception(job, dialog_title='Failed to Download Stories')
|
|
||||||
return
|
|
||||||
|
|
||||||
showsite = None
|
showsite = None
|
||||||
# set as part of job, otherwise *changing* reconsolidate_jobs
|
# set as part of job, otherwise *changing* reconsolidate_jobs
|
||||||
|
|
@ -2036,7 +2052,7 @@ class FanFicFarePlugin(InterfaceAction):
|
||||||
book_list = batch.get_results()
|
book_list = batch.get_results()
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
elif not job.failed:
|
else:
|
||||||
showsite = site
|
showsite = site
|
||||||
book_list = job.result
|
book_list = job.result
|
||||||
|
|
||||||
|
|
@ -2049,13 +2065,11 @@ class FanFicFarePlugin(InterfaceAction):
|
||||||
good_list = [ x for x in book_list if x['good'] ]
|
good_list = [ x for x in book_list if x['good'] ]
|
||||||
bad_list = [ x for x in book_list if not x['good'] ]
|
bad_list = [ x for x in book_list if not x['good'] ]
|
||||||
chapter_error_list = [ x for x in book_list if 'chapter_error_count' in x ]
|
chapter_error_list = [ x for x in book_list if 'chapter_error_count' in x ]
|
||||||
try:
|
|
||||||
good_list = sorted(good_list,key=lambda x : x['reportorder'])
|
sort_func = lambda x : x.get('reportorder',x['listorder'])
|
||||||
bad_list = sorted(bad_list,key=lambda x : x['reportorder'])
|
good_list = sorted(good_list,key=sort_func)
|
||||||
except KeyError:
|
bad_list = sorted(bad_list,key=sort_func)
|
||||||
good_list = sorted(good_list,key=lambda x : x['listorder'])
|
|
||||||
bad_list = sorted(bad_list,key=lambda x : x['listorder'])
|
|
||||||
#print("book_list:%s"%book_list)
|
|
||||||
payload = (good_list, bad_list, options)
|
payload = (good_list, bad_list, options)
|
||||||
|
|
||||||
msgl = [ _('FanFicFare found <b>%s</b> good and <b>%s</b> bad updates.')%(len(good_list),len(bad_list)) ]
|
msgl = [ _('FanFicFare found <b>%s</b> good and <b>%s</b> bad updates.')%(len(good_list),len(bad_list)) ]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue