skorokithakis / tbvaccine

A small utility to pretty-print Python tracebacks. ⛺

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running tbvaccine on non python file - colors don't work

szabolcsdombi opened this issue · comments

By mistake I just called python -m tbvaccine tox.ini.

The trace has no colors and it is longer then 100 lines, however calling python directly on a non python file causes only 4 lines for a single exception.

image

It would be great if tbvaccine could detect when a non python file is passed.

Hmm, I can't reproduce this:

16:53:35 $ python -m tbvaccine tox.ini 
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/tmp/tbvaccine/tbvaccine/__main__.py", line 23, in <module>
>   code = compile(script_file.read(), script_path, 'exec')
|     __builtins__ = <module '__builtin__' (built-in)>
|     __doc__      = None
|     __file__     = /tmp/tbvaccine/tbvaccine/__main__.py
|     __loader__   = <pkgutil.ImpLoader instance at 0x7f57adb82e60>
|     __name__     = __main__
|     __package__  = tbvaccine
|     os           = <module 'os' from '/usr/lib/python2.7/os.pyc'>
|     script_file  = <closed file 'tox.ini', mode 'r' at 0x7f57adb1e030>
|     script_path  = tox.ini
|     sys          = <module 'sys' (built-in)>
|     tbvaccine    = <module 'tbvaccine' from 'tbvaccine/__init__.pyc'>
SyntaxError: invalid syntax (tox.ini, line 5)

I am using windows it seems colors don't work on windows :(

Colorama works on windows. It changes the cmd.exe settings runtime by calling some winpai functions, here is a link.

Ah, I see. Unfortunately I don't have a Windows set up, but I'd be grateful if you wanted to submit a PR for this.

I give it a try.