From 333a33e48ac9dcd8c741fd3e661af579696cf686 Mon Sep 17 00:00:00 2001 From: Ralf Hallmen Date: Wed, 20 Feb 2019 23:17:06 +0100 Subject: [PATCH 1/3] removed dependency on blessings and instead use colors from colorama --- ronin/utils/messages.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ronin/utils/messages.py b/ronin/utils/messages.py index 7ecdece..069c704 100644 --- a/ronin/utils/messages.py +++ b/ronin/utils/messages.py @@ -16,7 +16,6 @@ from __future__ import unicode_literals from .unicode import to_str -from blessings import Terminal import colorama, atexit @@ -27,7 +26,12 @@ def _restore_terminal(): atexit.register(_restore_terminal) -terminal = Terminal() +colors = { + 'green': colorama.Fore.GREEN, + 'red': colorama.Fore.RED, + 'yellow': colorama.Fore.YELLOW, +} +reset_color = colorama.Style.RESET_ALL def announce(message, prefix='rōnin', color='green'): @@ -39,9 +43,9 @@ def announce(message, prefix='rōnin', color='green'): :param color: color name :type color: str """ - - if color: - prefix = getattr(terminal, color)(prefix) + + if color and color in colors: + prefix = colors[color] + prefix + reset_color print('{}: {}'.format(prefix, message)) From 306c959cc1808d49810f2dcce5db5057c63611e9 Mon Sep 17 00:00:00 2001 From: Ralf Hallmen Date: Wed, 20 Feb 2019 23:20:37 +0100 Subject: [PATCH 2/3] setup.py did not work with Windows - requirement on blessings removed - io.open uses cp1252 as default encoding on Windows, so explicitly requesting utf8 is necessary --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 32e2b38..a47354d 100755 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ import pypandoc # @UnresolvedImport long_description = pypandoc.convert(os.path.join(HERE, 'README.md'), 'rst') except(IOError, ImportError): - with io.open(os.path.join(HERE, 'README.md')) as f: + with io.open(os.path.join(HERE, 'README.md'), encoding='utf8') as f: long_description = f.read() with io.open(os.path.join(HERE, 'ronin', 'version.py')) as f: @@ -74,6 +74,5 @@ 'ronin.vala'), install_requires=( - 'blessings>=1.6, <2.0', 'colorama>=0.3.9, <2.0.0', 'glob2>=0.5, <=2.0')) From f8aca3880d710dab7201595e854fa3ec78f2882c Mon Sep 17 00:00:00 2001 From: Ralf Hallmen Date: Thu, 28 Feb 2019 01:45:42 +0100 Subject: [PATCH 3/3] added shutil_which. uses the method which from shutil. untested --- ronin/utils/platform.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ronin/utils/platform.py b/ronin/utils/platform.py index 20b21fc..ca7705c 100644 --- a/ronin/utils/platform.py +++ b/ronin/utils/platform.py @@ -212,6 +212,16 @@ def which(command, exception=True): raise WhichException("could not find '{}'".format(command)) return None +def shutil_which(command, exception=True): + import shutil + command = stringify(command) + found_command = shutil.which(command) + if found_command is None: + if exception: + raise WhichException("could not find '{}'".format(command)) + return None + return found_command + class WhichException(Exception): """