Commit 682f49d8 authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

Correct the client now tested with server

working as expected.
parent f5c432ea
from socket import socket, AF_INET, SOCK_STREAM
from . import socket, AF_INET, SOCK_STREAM
from . import INFO, DBUG, WARN, SEVR, SPCE
SIZE_STATUS_MAX = 1024
from . import D_DEBUG
DEBUG = D_DEBUG
# CLASS CLIENT ---------------------------------------------------------
class MplClient(object):
......@@ -42,7 +47,7 @@ class MplClient(object):
def packReadDataContent(self, ioFunction, dataName, *args, **kwargs):
'''Pack the content of the instructions for readData.'''
packedContent = "[\""+str(dataName)+"\", \""+ioFunction.__name__+"\", \""+str(args)+"\", \""+str(kwargs)+"\"]"
packedContent = "['"+str(dataName)+"', '"+ioFunction.__name__+"', '"+str(args)+"', '"+str(kwargs)+"']"
return(packedContent)
......@@ -63,22 +68,26 @@ class MplClient(object):
# Send the signal with size
signal = self.packSignal(('readData', instructionSize))
self.sendSignal(signal)
sock = self.sendSignal(signal)
if(DEBUG):
print(INFO+'Sent Signal, waiting for receipt...')
status = self.waitForReceipt()
status = self.waitForReceipt(sock)
# Check status
if not status:
return(False)
if(DEBUG):
print(INFO+'Received the receipt')
print(INFO+'Sent the instructions, waiting for status: ')
# Send Instructions
self.sendInstructions(packedInstructions)
self.sendInstructions(sock, packedInstructions)
# Check status
status = self.waitForStatus()
status = self.waitForStatus(sock)
if not status:
return(False)
......@@ -116,10 +125,15 @@ class MplClient(object):
'''Wait for the receipt. return a tuple.'''
answer = sock.recv(SIZE_STATUS_MAX)
status = False
errmsg = ''
header = ''
try:
header, status, errmsg = eval(answer)
except:
print(SEVR+'could not Exctract the receipt.')
print(SEVR+'Received: '+str(answer))
if not status:
print(SEVR+str(errmsg))
......@@ -147,6 +161,10 @@ class MplClient(object):
'''Wait for the status. return a tuple.'''
answer = sock.recv(SIZE_STATUS_MAX)
status = False
errmsg = ''
header = ''
try:
header, status, errmsg = eval(answer)
except:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment