Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Yori Fournier
myplotlib
Commits
ab9c1045
Commit
ab9c1045
authored
Sep 15, 2017
by
Yori 'AGy' Fournier
Browse files
Now newSynCFigures works on client side
tested
parent
e5cf3138
Changes
1
Hide whitespace changes
Inline
Side-by-side
mplClient.py
View file @
ab9c1045
...
...
@@ -37,8 +37,8 @@ class MplClient(object):
def
packInstructions
(
self
,
instructions
):
'''Pack the instructions, a tuple of strings: (header, content).'''
header
,
c
ontent
=
instructions
packedInstructions
=
"(
\"
"
+
header
+
"
\"
,
\"
"
+
c
ontent
+
"
\
"
)"
header
,
packedC
ontent
=
instructions
packedInstructions
=
"(
\"
"
+
header
+
"
\"
,
"
+
str
(
packedC
ontent
)
+
")"
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'''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment