Commit 38e4d065 authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

Merge branch '54-clean-server' of gitlab.aip.de:yfournier/myplotlib into 54-clean-server

parents 040ed59a ab9c1045
......@@ -37,8 +37,8 @@ class MplClient(object):
def packInstructions(self, instructions):
'''Pack the instructions, a tuple of strings: (header, content).'''
header, content = instructions
packedInstructions = "(\""+header+"\", \""+content+"\")"
header, packedContent = instructions
packedInstructions = "(\""+header+"\", "+str(packedContent)+")"
return(packedInstructions)
......@@ -47,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)
......@@ -92,23 +92,6 @@ class MplClient(object):
if not status:
return(False)
# content = "['"+str(dataName)+"', '"+ioFunction.__name__+"', \""+str(args)+"\", \""+str(kwargs)+"\"]"
#
# signal = "("+"'readData'"+', '+str(content)+')'
#
# # create signal
# sock = self.sendSignal(signal)
# answer = self.waitForAnswer(sock)
# header, content, errmsg = eval(answer)
# dataName = content
# # add data in the currentSyncData interface
# if dataName is None:
# print(SEVR+errmsg)
# status=False
# else:
# self.currentRemoteData.append(dataName)
# status=True
#
return(True)
# SEND SIGNAL ------------------------------------------------------
......@@ -181,32 +164,89 @@ class MplClient(object):
# NEW SYNC FIGURE --------------------------------------------------
def newSyncFigure(self, figClass, symbolicRawdata, **kwargs):
'''Start the readData procedure.
1. Send newSyncFigure Signal with length of packedInstructions
2. Wait for receipt
3. Send Instructions
4. Wait for status
'''
# create temporary syncFigure
syncFigure = figClass(symbolicRawdata, **kwargs)
content = "['"+str(figClass.__name__)+"', \""+str(symbolicRawdata)+"\", '"+str(kwargs)+"']"
signal = "("+"'newSyncFigure'"+", "+str(content)+")"
# Pack instructions and get size
content = self.packNewSyncFigureContent(figClass, symbolicRawdata, **kwargs)
packedInstructions = self.packInstructions(('newSyncFigure', content))
instructionSize = len(packedInstructions)
# Send the signal with size
signal = self.packSignal(('newSyncFigure', instructionSize))
sock = self.sendSignal(signal)
answer = self.waitForAnswer(sock)
header, content, errmsg = eval(answer)
ID = content
if(DEBUG):
print(INFO+'Sent Signal, waiting for receipt...')
# Wait for the receipt
status = self.waitForReceipt(sock)
# Check status
if not status:
del(syncFigure)
return(None)
if(DEBUG):
print(INFO+'Received the receipt')
print(INFO+'Sent the instructions, waiting for status: ')
# Figure was created then link sync version locally
if ID is not None:
# Send Instructions
self.sendInstructions(sock, packedInstructions)
# Check status
ID = self.waitForStatus(sock)
# If failed
if ID == 'ERROR':
del(syncFigure)
return(None)
# If created
else:
# Link the temporary Sync Figure
syncFigure.syncID = ID
syncFigure.client = self
# else delete the sync Figure
else:
print(WARN + 'The server could not create the figure')
print(errmsg)
del(syncFigure)
syncFigure = None
# content = "['"+str(figClass.__name__)+"', \""+str(symbolicRawdata)+"\", '"+str(kwargs)+"']"
# signal = "("+"'newSyncFigure'"+", "+str(content)+")"
#
# sock = self.sendSignal(signal)
#
# answer = self.waitForAnswer(sock)
# header, content, errmsg = eval(answer)
#
# ID = content
#
# # Figure was created then link sync version locally
# if ID is not None:
# syncFigure.syncID = ID
# syncFigure.client = self
# # else delete the sync Figure
# else:
# print(WARN + 'The server could not create the figure')
# print(errmsg)
# del(syncFigure)
# syncFigure = None
#
return(syncFigure)
# PACK NEW SYNC FIGURE CONTENT -------------------------------------
def packNewSyncFigureContent(self, FigClass, rawdata, **kwargs):
'''Pack the content of the instructions for new Sync Figure.'''
packedContent = "['"+FigClass.__name__+"', "+str(rawdata)+", "+str(kwargs)+"]"
return(packedContent)
# SYNC FIGURE FORMAT RAWDATA ---------------------------------------
def syncFigFormatRawData(self, syncID):
'''the returned datas should be a tuple of strings'''
......
Supports Markdown
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