From 570f49d4071983c901e0d7f2ee8c350fb15d1637 Mon Sep 17 00:00:00 2001 From: Daniel Grana Date: Tue, 16 Dec 2008 18:49:12 +0000 Subject: [PATCH] stats: limit the default number of stats history to 10 --HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40522 --- scrapy/trunk/scrapy/command/commands/stats.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scrapy/trunk/scrapy/command/commands/stats.py b/scrapy/trunk/scrapy/command/commands/stats.py index e062ce6a8..1b0febb75 100644 --- a/scrapy/trunk/scrapy/command/commands/stats.py +++ b/scrapy/trunk/scrapy/command/commands/stats.py @@ -12,11 +12,13 @@ class Command(ScrapyCommand): def add_options(self, parser): ScrapyCommand.add_options(self, parser) parser.add_option("-p", "--path", dest="path", help="restrict stats to PATH", metavar="PATH") + parser.add_option("--limit", dest="limit", default='10', help="limit the number of stats") def run(self, args, opts): if not args: print "A domain is required" return + if not settings['SCRAPING_DB']: print "SCRAPING_DB setting is required for this command" return @@ -26,5 +28,5 @@ class Command(ScrapyCommand): for domain in args: print "# %s" % domain - pprint.pprint(list(ddh.getall(domain, opts.path))) + pprint.pprint(list(ddh.get(domain, path=opts.path, count=int(opts.limit))))