tweaking the fakeserver

This commit is contained in:
Maximilien Rigaut 2021-11-01 06:26:22 +01:00
parent c847c7fd88
commit 3ae407afc9
2 changed files with 8 additions and 3 deletions

View File

@ -656,6 +656,7 @@ class analogController(object):
except OSError as e:
eprint(e)
eprint('The socket connection is experiencing issues')
sys.exit()
def socketLoop(self):
@ -688,7 +689,7 @@ class analogController(object):
try:
iprint(">>> Sending direct: {}".format(direct))
self.sck.sendall(direct)
except:
except socket.error:
eprint("Error sending data: ",direct)
def sendData(self,data):

View File

@ -24,8 +24,8 @@ class Answer(object):
def __radd__(self,other):
if type(other)==str:
def new_funct(match):
return other+self.function
return new_funct
return other+self.function(match)
return Answer(new_funct)
else:
raise TypeError
@ -46,6 +46,7 @@ _goodanswers={
"#":_MSG+_0,
"PRinp":_MSG+_ARG,
"PUscu":_MSG+_ARG,
",GCtav":"GCtav"+_ARG+Answer(",1"),
"_":_MSG+_ARG,
}
def goodServer(s,addr,delay=_DELAY):
@ -85,6 +86,9 @@ def Main(delay=_DELAY):
# print(c.recv(4000))
# c.sendall(b"*\r\n")
start_new_thread(goodServer, (c,addr,delay,))
cont=input("Keep accepting connections ?")
if cont.lower()=="n":
break
s.close()