lpcmanager

LPCCommand : switch to wx.Timer instead of regular python timer for the rapidfire protection. With regular python timers, some refresh order could pile eventloop when interacting with the GUI while doing initial loading of signals.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
class StdoutPseudoFile:
def __init__(self, port, debug):
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.connect(('localhost', port))
self.Buffer = ""
self.debug = debug
def __del__(self):
self.socket.close()
def readline(self):
idx = self.Buffer.find("\n")
while idx == -1:
text = self.socket.recv(2048)
if text == "":
return ""
self.Buffer += text
idx = self.Buffer.find("\n")
if idx != -1:
line = self.Buffer[:idx + 1]
self.Buffer = self.Buffer[idx + 1:]
if self.debug:
print "command >" + line
return line
return ""
""" Base class for file like objects to facilitate StdOut for the Shell."""
def write(self, s, style=None):
if s != '':
self.socket.send(s.encode('utf8'))
def writeyield(self, s):
self.write(s)
def write_warning(self, s):
self.write(s)
def write_error(self, s):
self.write(s)
def flush(self):
pass
def isatty(self):
return False