Not able to print ANSI color text in gitbash because of colorama.init()
DEV:
Not able to print ANSI color text in gitbash because:
pokemongo_bot\cell_workers\utils.py:
from colorama import init
init()
if I commented out 'init()' I am able to print color
example
2016-08-10 23:40:36,472 [ cli] [INFO] Ran for 0:02:13 2016-08-10 23:40:36,472 [ cli] [INFO] Total XP Earned: 410 Average: 11122.87/h 2016-08-10 23:40:36,473 [ cli] [INFO] Travelled 0.03km 2016-08-10 23:40:36,473 [ cli] [INFO] Visited 4 stops 2016-08-10 23:40:36,473 [ cli] [INFO] Encountered 1 pokemon, 1 caught, 1 released, 0 evolved, 0 never seen before 2016-08-10 23:40:36,473 [ cli] [INFO] Threw 1 pokeball 2016-08-10 23:40:36,473 [ cli] [INFO] Earned 100 Stardust 2016-08-10 23:40:36,473 [ cli] [INFO] 2016-08-10 23:40:36,473 [ cli] [INFO] Highest CP Pokemon: Drowzee [CP: 41] [IV: 10/6/0] Potential: 0.36 2016-08-10 23:40:36,473 [ cli] [INFO] Most Perfect Pokemon: Drowzee [CP: 41] [IV: 10/6/0] Potential: 0.36 Traceback (most recent call last): File "./pokecli.py", line 530, in
main() File "./pokecli.py", line 96, in main bot.tick() File "/var/www/USERDIR/PokemonGo-Bot/pokemongo_bot/init.py", line 472, in tick if worker.work() == WorkerResult.RUNNING: File "/var/www/USERDIR/PokemonGo-Bot/pokemongo_bot/cell_workers/catch_visible_pokemon.py", line 45, in work 'expiration_timestamp_ms': pokemon['expiration_timestamp_ms'], File "/var/www/USERDIR/PokemonGo-Bot/pokemongo_bot/base_task.py", line 27, in emit_event data=data File "/var/www/USERDIR/PokemonGo-Bot/pokemongo_bot/event_manager.py", line 65, in emit handler.handle_event(event, sender, level, formatted_msg, data) File "/var/www/USERDIR/PokemonGo-Bot/pokemongo_bot/event_handlers/colored_logging_handler.py", line 130, in handle_event terminal_width = self._terminal_width() File "/var/www/USERDIR/PokemonGo-Bot/pokemongo_bot/event_handlers/colored_logging_handler.py", line 171, in _terminal_width struct.pack('HHHH', 0, 0, 0, 0))) IOError: [Errno 25] Inappropriate ioctl for device 2016-08-10 23:40:36,479 [sentry.errors] [ERROR] Sentry responded with an error: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) (url: https://app.getsentry.com/api/90254/store/) Traceback (most recent call last): File "/var/www/USERDIR/PokemonGo-Bot/lib/python2.7/site-packages/raven/transport/threaded.py", line 174, in send_sync super(ThreadedHTTPTransport, self).send(data, headers) File "/var/www/USERDIR/PokemonGo-Bot/lib/python2.7/site-packages/raven/transport/http.py", line 47, in send ca_certs=self.ca_certs, File "/var/www/USERDIR/PokemonGo-Bot/lib/python2.7/site-packages/raven/utils/http.py", line 66, in urlopen return opener.open(url, data, timeout) File "/var/www/USERDIR/PokemonGo-Bot/lib/python2.7/site-packages/future/backports/urllib/request.py", line 494, in open response = self._open(req, data) File "/var/www/USERDIR/PokemonGo-Bot/lib/python2.7/site-packages/future/backports/urllib/request.py", line 512, in _open '_open', req) File "/var/www/USERDIR/PokemonGo-Bot/lib/python2.7/site-packages/future/backports/urllib/request.py", line 466, in _call_chain result = func(*args) File "/var/www/USERDIR/PokemonGo-Bot/lib/python2.7/site-packages/raven/utils/http.py", line 46, in https_open return self.do_open(ValidHTTPSConnection, req) File "/var/www/USERDIR/PokemonGo-Bot/lib/python2.7/site-packages/future/backports/urllib/request.py", line 1284, in do_open h.request(req.get_method(), req.selector, req.data, headers) File "/usr/lib64/python2.7/httplib.py", line 1057, in request self._send_request(method, url, body, headers) File "/usr/lib64/python2.7/httplib.py", line 1097, in _send_request self.endheaders(body) File "/usr/lib64/python2.7/httplib.py", line 1053, in endheaders self._send_output(message_body) File "/usr/lib64/python2.7/httplib.py", line 895, in _send_output msg += message_body UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) 2016-08-10 23:40:36,480 [sentry.errors.uncaught] [ERROR] [u'IOError: [Errno 25] Inappropriate ioctl for device', u' File "pokecli.py", line 530, in ', u' File "pokecli.py", line 96, in main', u' File "pokemongo_bot/init.py", line 472, in tick', u' File "pokemongo_bot/cell_workers/catch_visible_pokemon.py", line 45, in work', u' File "pokemongo_bot/base_task.py", line 27, in emit_event', u' File "pokemongo_bot/event_manager.py", line 65, in emit', u' File "pokemongo_bot/event_handlers/colored_logging_handler.py", line 130, in handle_event', u' File "pokemongo_bot/event_handlers/colored_logging_handler.py", line 171, in _terminal_width']
Applications should initialise Colorama using:
from colorama import init init() On Windows, calling init() will filter ANSI escape sequences out of any text sent to stdout or stderr, and replace them with equivalent Win32 calls.
Still not working in Windows when I use gitbash with today's version.
@seehuily still an issue?
@seehuily I'd suggest making a PR if you get this sorted, as no one else is experiencing this issue i'm going to close it as I don't see anyone fixing it for you, unless you do yourself :)