From baea522e6b5c3acceb08d743ce75f4c6f734f034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Di=C3=B3genes=20Augusto=20Fernandes=20Herm=C3=ADnio?= Date: Tue, 2 Apr 2019 23:21:59 -0300 Subject: [PATCH 1/2] This fixes the following scenario: When user is installing owtf and doesn't have tornado installed in its own system, when importing __version__ on setup.py, it will try to load OWTFLogger, that uses tornado, then breaking the application. My fix just bypass that by handling the LoadModule error and installation goes fine. --- owtf/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/owtf/__init__.py b/owtf/__init__.py index 84e3731d9..5df810c51 100644 --- a/owtf/__init__.py +++ b/owtf/__init__.py @@ -3,7 +3,11 @@ import re from typing import Any, NamedTuple -from owtf.utils.logger import OWTFLogger +try: + from owtf.utils.logger import OWTFLogger + OWTFLogger().enable_logging() +except ModuleNotFoundError as e: + print(e) __version__ = "2.6.0" __homepage__ = "https://github.com/owtf/owtf" @@ -24,6 +28,3 @@ VERSION = version_info = version_info_t(int(_temp[0]), int(_temp[1]), int(_temp[2])) del _temp __all__ = [] - - -OWTFLogger().enable_logging() From 3f241bb7e35e7ff1a6d2bb777b40f6b49f04ec61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Di=C3=B3genes=20Augusto=20Fernandes=20Herm=C3=ADnio?= Date: Wed, 3 Apr 2019 00:22:40 -0300 Subject: [PATCH 2/2] adapting code for python2 --- owtf/__init__.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/owtf/__init__.py b/owtf/__init__.py index 5df810c51..8df1f1d01 100644 --- a/owtf/__init__.py +++ b/owtf/__init__.py @@ -5,8 +5,9 @@ try: from owtf.utils.logger import OWTFLogger + OWTFLogger().enable_logging() -except ModuleNotFoundError as e: +except ImportError as e: print(e) __version__ = "2.6.0" @@ -14,13 +15,7 @@ __docformat__ = "markdown" -version_info_t = NamedTuple( - "version_info_t", [ - ("major", int), - ("minor", int), - ("patch", int), - ] -) +version_info_t = NamedTuple("version_info_t", [("major", int), ("minor", int), ("patch", int)]) # bumpversion can only search for {current_version} # so we have to parse the version here.