catalog generation: Output timing info to log

This commit is contained in:
Kovid Goyal 2013-03-20 19:44:49 +05:30
commit e93c855a67
2 changed files with 23 additions and 7 deletions

View File

@ -7,7 +7,7 @@ __license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os
import datetime, os, time
from collections import namedtuple
from calibre import strftime
@ -388,18 +388,24 @@ class EPUB_MOBI(CatalogPlugin):
build_log.append(" %s: %s" % (key, repr(opts_dict[key])))
if opts.verbose:
log('\n'.join(line for line in build_log))
# Capture start_time
opts.start_time = time.time()
self.opts = opts
if opts.verbose:
log.info(" Begin catalog source generation (%s)" %
str(datetime.timedelta(seconds = int(time.time() - opts.start_time))))
# Launch the Catalog builder
catalog = CatalogBuilder(db, opts, self, report_progress=notification)
if opts.verbose:
log.info(" Begin catalog source generation")
try:
catalog.build_sources()
if opts.verbose:
log.info(" Completed catalog source generation\n")
log.info(" Completed catalog source generation (%s)\n" %
str(datetime.timedelta(seconds = int(time.time() - opts.start_time))))
except (AuthorSortMismatchException, EmptyCatalogException), e:
log.error(" *** Terminated catalog generation: %s ***" % e)
except:
@ -489,5 +495,9 @@ class EPUB_MOBI(CatalogPlugin):
os.remove(epub_shell)
zip_rebuilder(input_path, os.path.join(catalog_debug_path, 'input.epub'))
if opts.verbose:
log.info(" Catalog creation complete (%s)\n" %
str(datetime.timedelta(seconds = int(time.time() - opts.start_time))))
# returns to gui2.actions.catalog:catalog_generated()
return catalog.error

View File

@ -3,7 +3,7 @@
__license__ = 'GPL v3'
__copyright__ = '2010, Greg Riker'
import datetime, htmlentitydefs, os, platform, re, shutil, unicodedata, zlib
import datetime, htmlentitydefs, os, platform, re, shutil, time, unicodedata, zlib
from copy import deepcopy
from xml.sax.saxutils import escape
@ -4855,7 +4855,13 @@ class CatalogBuilder(object):
self.progress_int = 0.01
self.reporter(self.progress_int, self.progress_string)
if self.opts.cli_environment:
self.opts.log(u"%3.0f%% %s" % (self.progress_int * 100, self.progress_string))
log_msg = u"%3.0f%% %s" % (self.progress_int * 100, self.progress_string)
if self.opts.verbose:
log_msg += " (%s)" % str(datetime.timedelta(seconds=int(time.time() - self.opts.start_time)))
else:
log_msg = ("%s (%s)" % (self.progress_string,
str(datetime.timedelta(seconds=int(time.time() - self.opts.start_time)))))
self.opts.log(log_msg)
def update_progress_micro_step(self, description, micro_step_pct):
""" Update calibre's job status UI.