def showplanes(win, lock): plane = Plane('abcdef',datetime.utcnow()) while True: time.sleep(.500) row=2 win.erase() plane.showheader(win) lock.acquire() for id in sorted(planes, key=planes.__getitem__): planes[id].showincurses(win, row) row=row+1 now=str(datetime.utcnow()) win.addstr(rows-1,cols-5-len(now),now) win.refresh() removeplanes() lock.release()
def main(screen): curses.start_color() curses.init_pair(1,curses.COLOR_GREEN, curses.COLOR_BLUE) screen.refresh() c_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM); c_socket.connect(('localhost',30003)); win = curses.newwin(rows,cols,1,1) win.bkgd(curses.color_pair(1)) win.box() for line in c_socket.makefile('r'): #print line parts=[x.strip() for x in line.split(',')] if parts[0] == 'MSG': id = parts[4] if id in planes: plane =planes[id] else: plane = Plane(parts[4], datetime.utcnow()) planes[id]=plane plane.update(parts) removeplanes() row=2 win.erase() plane.showheader(win) for id in sorted(planes, key=planes.__getitem__): planes[id].showincurses(win, row) row=row+1 now=str(datetime.utcnow()) win.addstr(rows-1,cols-5-len(now),now) win.refresh()