Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions ronin/utils/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from __future__ import unicode_literals
from .unicode import to_str
from blessings import Terminal
import colorama, atexit


Expand All @@ -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'):
Expand All @@ -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))


Expand Down
10 changes: 10 additions & 0 deletions ronin/utils/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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'))