I have a few projectors that i control with a python script using telnetlib, which works fine. I can also read the telnet output to get the current settings from them.
The issue i am having is that the telnet output gives me some unwanted characters and i would like to filter those out and show just the actual data.
#CURRENT SCRIPT
import time
import telnetlib
import os
port = 555
ipaddr = ('10.0.0.171',
'10.0.0.172',
'10.0.0.173',)
for ip in ipaddr:
tn = telnetlib.Telnet(ip, port,)
time.sleep(0.1)
tn.write(b"*gamma ?\r")
time.sleep(0.1)
tn.write(b"*power ?\r")
time.sleep(0.1)
print(tn.read_eager(), end = ' ')
print("on " + ip)
print("----------------------------------------------------")
tn.close
os.system("pause")
The output looks like this:
b'ack gamma = 3\r\nack power = 1\r\n' on 10.0.0.171
----------------------------------------------------
b'ack gamma = 3\r\nack power = 1\r\n' on 10.0.0.172
----------------------------------------------------
b'ack gamma = 3\r\nack power = 1\r\n' on 10.0.0.173
----------------------------------------------------
Press any key to continue . . .
which basically returns the ACK command and the data with \r\n at the end
is it possible to filter those out and put a delimiter between? something like:
| gamma = 3 | power = 1 | on 10.0.0.171
----------------------------------------------------
| gamma = 3 | power = 1 | on 10.0.0.172
----------------------------------------------------
| gamma = 3 | power = 1 | on 10.0.0.173
----------------------------------------------------
Press any key to continue . . .
Or if it is simpler to output these replies in a popup message box? or highlight them (different color)?
Working on Windows with Python 3.7.3
Any help would be much appreciated, Thanks
David