Commit 3249460e authored by Yori Fournier's avatar Yori Fournier
Browse files

TRy to make it compatible with newSyncFigures

parent 0d95673c
......@@ -118,6 +118,7 @@ elif(D_HIERARCHY in ('SERVER', 'server')):
from .test import readStupidData
SERVER_IOFUNCTIONS = {'readStupidData': readStupidData}
SERVER_FIGURES = {'FigTest', FigTest}
from .server import Server
......
......@@ -4,6 +4,7 @@ from . import D_PORT
from . import INFO, DBUG, WARN, SEVR, SPCE
from . import SERVER_IOFUNCTIONS
from . import SERVER_FIGURES
G_RAWDATA = {}
G_FIGURES = {}
......@@ -20,9 +21,13 @@ class Server():
def defineKnownFunctions(self):
self.knownFunctions = SERVER_IOFUNCTIONS
def defineKnownFigures(self):
self.knownFigures = SERVER_FIGURES
def init(self):
self.defineKnownFunctions()
self.defineKnownFigures()
self.soc.bind((self.host, self.port))
self.soc.listen(1)
......@@ -73,61 +78,25 @@ class Server():
answer = ('readData', None, 'could not extract content')
return(answer)
# try:
if (True):
# arguments = ''
# print(str(args))
# if args != '':
# for arg in eval(args):
# arguments = arguments + str(arg) + ', '
# arguments = arguments[:-2]
# print('with args: ' + str(arguments))
# if kwargs != ():
# for kwarg in eval(kwargs).items():
# arguments = arguments + str(kwarg[0]) + '=' + str(kwargs[1]) + ', '
# arguments = arguments[:-2]
# print('with kwargs: ' + str(arguments))
# print(str(functionName)+'('+str(arguments)+')')
# if args is not None:
# if kwargs is not None:
# G_RAWDATA[dataName] = eval(str(functionName)+'('+str(args)+', '+str(kwargs)+')')
# else:
# G_RAWDATA[dataName] = eval(str(functionName)+'('+str(args)+')')
# else:
# if kwargs is not None:
# G_RAWDATA[dataName] = eval(str(functionName)+'('+str(kwargs)+')')
# else:
# G_RAWDATA[dataName] = eval(str(functionName)+'()')
try:
args = eval(str(args))
kwargs = eval(str(kwargs))
# fct = eval(str(functionName))
fct = self.knownFunctions[str(functionName)]
print(fct.__name__)
print(args)
print(kwargs)
# G_RAWDATA[dataName] = readRun('./mfdv2/data/serie_v3_005_A/run000')
G_RAWDATA[dataName] = fct(*args, **kwargs)
# G_RAWDATA[dataName] = eval(str(functionName)+'('+str(arguments)+')')
print(G_RAWDATA[dataName].data)
answer = ('readData', dataName, 'no error')
#except:
# print(WARN+"The read function could not be executed")
# answer = ('readData', None, 'function could not be executed')
# return(answer)
except:
print(WARN+"The read function could not be executed")
answer = ('readData', None, 'function could not be executed')
return(answer)
elif header in ('newSyncFigure'):
try:
(figClass, rawdata, kwargs) = eval(str(content))
(figClassName, rawdata, kwargs) = eval(str(content))
except:
print(WARN+"The content of readData could not be extracted")
print(SPCE+'Received: '+str(content))
......@@ -139,13 +108,17 @@ class Server():
# try:
# print(figClass.__name__, rawdata, kwargs)
FigID = 'Test'
datas = "("
# datas = "("
kwargs = eval(kwargs)
datas = ()
for raw in eval(rawdata):
datas = datas + "G_RAWDATA['"+raw+"'],"
datas = datas + ")"
datas = datas + (G_RAWDATA[raw],)
print(datas)
print(figClass+'('+str(datas)+', '+kwargs+')')
G_FIGURES[FigID] = eval(figClass+'('+str(datas)+', '+kwargs+')')
figClass = self.knownFigures[figClassName]
# print(figClass+'('+str(datas)+', '+kwargs+')')
# G_FIGURES[FigID] = eval(figClass+'('+str(datas)+', '+kwargs+')')
G_FIGURES[FigID] = figClass(datas, **kwargs)
answer = ('newSyncFigure', FigID, '')
# except:
# print(WARN+"The required fig could not be created")
......
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