Commit 0d95673c authored by Yori Fournier's avatar Yori Fournier
Browse files

Now I can import mfdv2 and create the mfdServer

The readData signal is well understood and read the data properly

not yet clean neither tested.
parent 0f87706a
......@@ -113,6 +113,13 @@ elif(D_HIERARCHY in ('SERVER', 'server')):
# from .test import FigTestServer
from .test import FigTest
# for testing purpose
from .test import readStupidData
SERVER_IOFUNCTIONS = {'readStupidData': readStupidData}
from .server import Server
elif D_HIERARCHY in ('LOCAL', 'local'):
......@@ -165,5 +172,4 @@ if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
# from .test import testList
from .test import FigTest
# for testing purpose
from .test import readStupidData
......@@ -148,8 +148,8 @@ elif run4Plot:
elif run4server:
from .server import Server
from .test import readStupidData
from . import Server
from . import readStupidData
server = Server()
server.init()
......
......@@ -3,8 +3,7 @@ from . import D_HOST
from . import D_PORT
from . import INFO, DBUG, WARN, SEVR, SPCE
from . import readStupidData
from . import FigTest
from . import SERVER_IOFUNCTIONS
G_RAWDATA = {}
G_FIGURES = {}
......@@ -18,8 +17,13 @@ class Server():
self.host = D_HOST
self.port = D_PORT
def defineKnownFunctions(self):
self.knownFunctions = SERVER_IOFUNCTIONS
def init(self):
self.defineKnownFunctions()
self.soc.bind((self.host, self.port))
self.soc.listen(1)
......@@ -69,28 +73,56 @@ class Server():
answer = ('readData', None, 'could not extract content')
return(answer)
try:
print(str(functionName)+'('+str(args)+', '+str(kwargs)+')')
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:
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)+'()')
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'):
......
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