Ticket #98 (closed defect: invalid)

Opened 7 months ago

Last modified 2 months ago

Scap-win's ANSI-color support breaks when user issues print commands on his own

Reported by: Dirk Loss Assigned to: pbi
Priority: minor Milestone:
Component: Scapy Version:
Keywords: Windows ANSI color Cc:

Description

Scapy-win's ANSI-color support breaks when you issue print or repr() commands on your own:

Welcome to Scapy (1.2.0.2-win)
>>> IP()         # This works
<IP  |>          # 'IP' is printed in yellow
>>> repr(IP())   # This doesn't and shows ugly ANSI escape sequences:
'\x1b[0m<\x1b[0m\x1b[33m\x1b[1mIP\x1b[0m  \x1b[0m|\x1b[0m\x1b[0m>\x1b[0m'

As a workaround, change the color theme to BasicTheme (which only prints plain ASCII without any ANSI color codes):

>>> conf.color_theme=BasicTheme()
>>> repr(IP())
'<IP  |>'           # 'IP' is printed as normal text/without color

Or print to the special console object which we currently use for ANSI color support:

>>> conf.color_theme=ColorOnBlackTheme()
>>> print >> console, repr(IP())
<IP  |>             # 'IP' is printed in yellow

All this is quite ugly and should be fixed.

Attachments

Change History

03/08/08 11:22:17 changed by Dirk Loss

I've noticed that my problem description is misleading, because the Linux version behaves in the same way: just evaluating repr(IP()) returns the ANSI escape sequences. But if you use print to output the results, there's a difference:

Windows console:

Welcome to Scapy (1.2.0.2-win)
>>> print repr(IP())
←[0m<←[0m←[33m←[1mIP←[0m  ←[0m|←[0m←[0m>←[0m

Linux console:

Welcome to Scapy (1.2.0.2)
>>> print repr(IP())
<IP |>               # <- colored output

That could be important, if you want to output some packet representations in your own scripts:

# ansicolortest.py
from scapy import *
print repr(IP())

The above workarounds seem correct, though.

08/15/08 16:29:57 changed by pbi

  • status changed from new to closed.
  • resolution set to invalid.

This is the way it is supposed to work.


Add/Change #98 (Scap-win's ANSI-color support breaks when user issues print commands on his own)




Change Properties
Action