Skip to content

Commit 7f63459

Browse files
committed
Add openssl version to version command
1 parent 68d2311 commit 7f63459

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

scrapy/commands/version.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import platform
44

55
import twisted
6+
import OpenSSL
67

78
import scrapy
89
from scrapy.commands import ScrapyCommand
@@ -26,11 +27,22 @@ def run(self, args, opts):
2627
import lxml.etree
2728
lxml_version = ".".join(map(str, lxml.etree.LXML_VERSION))
2829
libxml2_version = ".".join(map(str, lxml.etree.LIBXML_VERSION))
29-
print("Scrapy : %s" % scrapy.__version__)
30-
print("lxml : %s" % lxml_version)
31-
print("libxml2 : %s" % libxml2_version)
32-
print("Twisted : %s" % twisted.version.short())
33-
print("Python : %s" % sys.version.replace("\n", "- "))
34-
print("Platform: %s" % platform.platform())
30+
print("Scrapy : %s" % scrapy.__version__)
31+
print("lxml : %s" % lxml_version)
32+
print("libxml2 : %s" % libxml2_version)
33+
print("Twisted : %s" % twisted.version.short())
34+
print("Python : %s" % sys.version.replace("\n", "- "))
35+
print("pyOpenSSL : %s" % self._get_openssl_version())
36+
print("Platform : %s" % platform.platform())
3537
else:
3638
print("Scrapy %s" % scrapy.__version__)
39+
40+
def _get_openssl_version(self):
41+
try:
42+
openssl = OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION)\
43+
.decode('ascii', errors='replace')
44+
# pyOpenSSL 0.12 does not expose openssl version
45+
except AttributeError:
46+
openssl = 'Unknown OpenSSL version'
47+
48+
return '{} ({})'.format(OpenSSL.version.__version__, openssl)

0 commit comments

Comments
 (0)