All pastes #408685 Raw Edit

Stuff

public python v1 · immutable
#408685 ·published 2007-03-25 01:00 UTC
rendered paste body
#!/usr/bin/python -uimport osimport cursesimport telnetlibfrom curses.wrapper import wrapperHOST = 'whatever'PORT = 6546keys = {	9: 'tab',	10: 'enter',	27: 'escape',	32: 'space',	258: 'down',	259: 'up',	260: 'left',	261: 'right',	262: 'home',	263: 'backspace',	330: 'delete',	331: 'insert',	338: 'pagedown',	339: 'pageup',	353: 'backtab',	360: 'end',}def main(screen):	tn = telnetlib.Telnet(HOST, PORT)	prompt = '\r\n# '	tn.read_until(prompt, 2)	while True:		screen.addstr(0, 5, '-= MythTV console remote =-\n')		c = screen.getch()		if c in keys:			s = 'key %s\n' % keys[c]		else:			s = 'key %s\n' % chr(c)		screen.addstr(s)		tn.write(s)		r = tn.read_until(prompt, 2)	curses.endwin()wrapper(main)