Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to print ANSI color text in gitbash because of colorama.init() #3525

Closed
seehuily opened this issue Aug 10, 2016 · 5 comments
Closed

Comments

@seehuily
Copy link
Contributor

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

@fabke
Copy link

fabke commented Aug 10, 2016

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']

@seehuily
Copy link
Contributor Author

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.

@seehuily
Copy link
Contributor Author

Still not working in Windows when I use gitbash with today's version.

@k4n30
Copy link
Contributor

k4n30 commented Aug 16, 2016

@seehuily still an issue?

@k4n30
Copy link
Contributor

k4n30 commented Aug 19, 2016

@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 :)

@k4n30 k4n30 closed this as completed Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants