From fd279ff3168c91be2ed8a012af6395034475ccf5 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 22 Dec 2017 17:43:52 +0100 Subject: Add simple stats-keeping SiteLoader --- crocoite/cli.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'crocoite/cli.py') diff --git a/crocoite/cli.py b/crocoite/cli.py index 0880a53..32e0959 100644 --- a/crocoite/cli.py +++ b/crocoite/cli.py @@ -160,6 +160,8 @@ def archive (self, url, output, onload, onsnapshot, browser, finished_dir = '/tmp/finished' """ + ret = {'stats': None} + self.update_state (state='PROGRESS', meta={'step': 'start'}) stopVarname = '__' + __package__ + '_stop__' @@ -229,11 +231,12 @@ def archive (self, url, output, onload, onsnapshot, browser, if screenshot: self.update_state (state='PROGRESS', meta={'step': 'screenshot'}) writeScreenshot (l.tab, writer) + ret['stats'] = l.stats writer.flush () if not output: outPath = os.path.join (app.conf.finished_dir, outFile) os.rename (fd.name, outPath) - return True + return ret def stateCallback (data): result = data['result'] @@ -271,11 +274,12 @@ def main (): if distributed: result = archive.delay (**passArgs) - result.get (on_message=stateCallback) + r = result.get (on_message=stateCallback) else: # XXX: local evaluation does not init celery logging? logging.basicConfig (level=logging.INFO) - archive (**passArgs) + r = archive (**passArgs) + print (r['stats']) return True -- cgit v1.2.3