Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Added verbose option to 'version' command. Closes #298

Pablo Hoffman119fd20e91d2
diff --git a/docs/contributing.rst b/docs/contributing.rst
index 1653ff352..d227b223e 100644
--- a/docs/contributing.rst
+++ b/docs/contributing.rst
@@ -41,6 +41,10 @@ guidelines when reporting a new bug.
reproduce the bug, so please include all relevant files required to reproduce
it.
+* include the output of ``scrapy version -v`` so developers working on your bug
+ know exactly which version and platform it occurred on, which is often very
+ helpful for reproducing it, or knowing if it was already fixed.
+
Writing patches
===============
diff --git a/docs/topics/commands.rst b/docs/topics/commands.rst
index 418648c8e..6b30a4e59 100644
--- a/docs/topics/commands.rst
+++ b/docs/topics/commands.rst
@@ -413,10 +413,11 @@ Example usage::
version
-------
-* Syntax: ``scrapy version``
+* Syntax: ``scrapy version [-v]``
* Requires project: *no*
-Prints the Scrapy version.
+Prints the Scrapy version. If used with ``-v`` it also prints Python, Twisted
+and Platform info, which is useful for bug reports.
.. command:: deploy
diff --git a/scrapy/commands/version.py b/scrapy/commands/version.py
index 4d4557357..ef39f69fa 100644
--- a/scrapy/commands/version.py
+++ b/scrapy/commands/version.py
@@ -1,10 +1,29 @@
+import sys
+import platform
+
+import twisted
+
import scrapy
from scrapy.command import ScrapyCommand
class Command(ScrapyCommand):
+ def syntax(self):
+ return "[-v]"
+
def short_desc(self):
return "Print Scrapy version"
+ def add_options(self, parser):
+ ScrapyCommand.add_options(self, parser)
+ parser.add_option("--verbose", "-v", dest="verbose", action="store_true",
+ help="also display twisted/python/platform info (useful for bug reports)")
+
def run(self, args, opts):
- print "Scrapy %s" % scrapy.__version__
+ if opts.verbose:
+ print "Scrapy : %s" % scrapy.__version__
+ print "Twisted : %s" % twisted.version.short()
+ print "Python : %s" % sys.version.replace("\n", "- ")
+ print "Platform: %s" % platform.platform()
+ else:
+ print "Scrapy %s" % scrapy.__version__