Robpol86 / terminaltables

Project no longer maintained.
https://github.com/matthewdeanmartin/terminaltables
MIT License
689 stars 70 forks source link

Table show error #57

Open XuCcc opened 6 years ago

XuCcc commented 6 years ago

My Codes:

from terminaltables import SingleTable
...
    def show(self, nametuple):
        datas = []
        datas.append(("id",) + nametuple._fields[:-1])
        for i, data in enumerate(self.data):
            datas.append((i,) + data[:-1])
        print SingleTable(datas).table
.                                                                                                                                                              [ 19%]
test/test_dataBase.py .s..┌────┬────────────┬─────────┬─────────┐
│ id │ ip         │ web     │ pwn     │
├────┼────────────┼─────────┼─────────┤
│ 0  │ 10.10.10.1 │ 8080 80 │ 9090 90 │
│ 1  │ 10.10.10.2 │ 8080 80 │ 9090 90 │
│ 2  │ 10.10.10.3 │ 8080 80 │ 9090 90 │
│ 3  │ 10.10.10.4 │ 8080 80 │ 9090 90 │
│ 4  │ 10.10.10.5 │ 8080 80 │ 9090 90 │
└────┴────────────┴─────────┴─────────┘

it workds ok,but after i import pwntools

from terminaltables import SingleTable
...
from pwn import *
...
    def show(self, nametuple):
        datas = []
        datas.append(("id",) + nametuple._fields[:-1])
        for i, data in enumerate(self.data):
            datas.append((i,) + data[:-1])
        print SingleTable(datas).table
test/test_dataBase.py .s..lqqqqwqqqqqqqqqqqqwqqqqqqqqqwqqqqqqqqqk
x id x ip         x web     x pwn     x
tqqqqnqqqqqqqqqqqqnqqqqqqqqqnqqqqqqqqqu
x 0  x 10.10.10.1 x 8080 80 x 9090 90 x
x 1  x 10.10.10.2 x 8080 80 x 9090 90 x
x 2  x 10.10.10.3 x 8080 80 x 9090 90 x
x 3  x 10.10.10.4 x 8080 80 x 9090 90 x
x 4  x 10.10.10.5 x 8080 80 x 9090 90 x
mqqqqvqqqqqqqqqqqqvqqqqqqqqqvqqqqqqqqqj
.lqqqqwqqqqqqqqqqqqqwqqqqqqwqqqqqqqqqqwqqqqqqqqqqk
roganartu commented 5 years ago

I came across this too, but it happened even without any other packages.

#!/usr/bin/env python3.6

from terminaltables import SingleTable, DoubleTable

data = [
    ["Testing", "Header"],
    ["foo", "bar"],
]

print(SingleTable(data).table)
print(DoubleTable(data).table)

outputs:

lqqqqqqqqqwqqqqqqqqk
x Testing x Header x
tqqqqqqqqqnqqqqqqqqu
x foo     x bar    x
mqqqqqqqqqvqqqqqqqqj
╔═════════╦════════╗
║ Testing ║ Header ║
╠═════════╬════════╣
║ foo     ║ bar    ║
╚═════════╩════════╝

Interestingly, if I run it inside tmux it works fine:

┌─────────┬────────┐
│ Testing │ Header │
├─────────┼────────┤
│ foo     │ bar    │
└─────────┴────────┘
╔═════════╦════════╗
║ Testing ║ Header ║
╠═════════╬════════╣
║ foo     ║ bar    ║
╚═════════╩════════╝

I don't like the DoubleTable, but the WindowsTable appears to work fine as an alternative to UnixTable on non-windows machines that I've tested if anyone else stumbles across this via Google like I did.

rotaugenlaubfrosch commented 4 years ago

Hi All, Any news regarding this issue? SingleTable seems to print a lot of "q"'s - but using DoubleTable it works fine. This is really strange. Best regards