Merge pull request #2915 from redapple/versions-with-cryptography

Print cryptography package version
This commit is contained in:
Mikhail Korobov 2017-09-28 13:04:56 +02:00 committed by GitHub
commit 346310cd10
3 changed files with 12 additions and 3 deletions

View File

@ -23,8 +23,11 @@ class Command(ScrapyCommand):
def run(self, args, opts):
if opts.verbose:
for name, version in scrapy_components_versions():
print("%-9s : %s" % (name, version))
versions = scrapy_components_versions()
width = max(len(n) for (n, _) in versions)
patt = "%-{}s : %s".format(width)
for name, version in versions:
print(patt % (name, version))
else:
print("Scrapy %s" % scrapy.__version__)

View File

@ -17,6 +17,11 @@ def scrapy_components_versions():
w3lib_version = w3lib.__version__
except AttributeError:
w3lib_version = "<1.14.3"
try:
import cryptography
cryptography_version = cryptography.__version__
except ImportError:
cryptography_version = "unknown"
return [
("Scrapy", scrapy.__version__),
@ -28,6 +33,7 @@ def scrapy_components_versions():
("Twisted", twisted.version.short()),
("Python", sys.version.replace("\n", "- ")),
("pyOpenSSL", _get_openssl_version()),
("cryptography", cryptography_version),
("Platform", platform.platform()),
]

View File

@ -28,4 +28,4 @@ class VersionTest(ProcessTest, unittest.TestCase):
self.assertEqual(headers, ['Scrapy', 'lxml', 'libxml2',
'cssselect', 'parsel', 'w3lib',
'Twisted', 'Python', 'pyOpenSSL',
'Platform'])
'cryptography', 'Platform'])