Commit d3cb2a9c authored by Yori Fournier's avatar Yori Fournier
Browse files

Merge branch '88-cleanning-pep8-compilance' of...

Merge branch '88-cleanning-pep8-compilance' of gitlab.aip.de:yfournier/myplotlib into 88-cleanning-pep8-compilance
parents 1c8b8680 548a2b5e
Pipeline #502 failed with stage
in 6 minutes and 6 seconds
......@@ -55,12 +55,14 @@ class MplClient():
def send(self, sig):
""" Sending a Type derived from Signal through the socket
after 'pickling' it"""
print('prepare sending')
wf = self.sock.makefile(mode='wb')
if debug:
print('sending ',
type(sig),
' with content \"',
sig.content, '\"')
print('makefile done')
#~ if debug:
print('Client sending ',
type(sig),
' with content \"',
sig.content, '\"')
try:
pickle.dump(sig, wf)
except Exception:
......@@ -210,8 +212,8 @@ class MplClient():
# try to create a figure of the same class on the client side
if isinstance(answer, Answer):
print('''trying to create a figure of the same
class on the client side''')
print('trying to create a figure of the same '
'class on the client side')
fig = figname(dataname, *args, **kwargs)
# Link the temporary Sync Figure
fig.sync_id = answer.content
......@@ -298,7 +300,7 @@ class MplClient():
if formated_data.value:
print('This should not happen')
else:
print('instead if answer a error was received')
print('instead of answer a error was received')
datas = (None,)
else:
# set the figure data to answerSig.value
......
......@@ -123,12 +123,16 @@ class MplFigClient(Figure):
print('The figure could not be deleted on the server Side')
else:
print(
'The client is not connected to a server yet. Please use the client to set up a sync conection.')
'The client is not connected to a server yet.'
'Please use the client to set up a sync conection.')
def get_state(self):
""" this function collects the current state of in the figure by creating a dict that holds all keyword,value pairs (taking the aliases into account)
""" this function collects the current state of in the figure
by creating a dict that holds all keyword,value pairs
(taking the aliases into account)
Warning: myplotlib allows in a transparent manner to modify the axes directly. Those changes can not be covert.
Warning: myplotlib allows in a transparent manner to modify
the axes directly. Those changes can not be covert.
"""
state = dict()
# test for double keywords and print a waring
......@@ -155,7 +159,8 @@ class MplFigClient(Figure):
print(
'Warning: The keyword \"',
key,
'\" appears in multiple axes. The Defaults will be overwritten. Prevent this by using aliases')
'\" appears in multiple axes. The Defaults will'
' be overwritten. Prevent this by using aliases')
# update the global keyword index
state.update(ax_keywords)
......@@ -178,7 +183,8 @@ class MplFigClient(Figure):
self.sync_id = new_fig.sync_id
else:
print(
'The client is not connected to a server yet. Please use the client to set up a sync conection.')
'The client is not connected to a server yet. '
'Please use the client to set up a sync conection.')
# INITIALIZE -------------------------------------------------------
def _initialize(self, *args, **kwargs):
......@@ -292,10 +298,19 @@ class MplFigClient(Figure):
print(SEVR + "The axes name ", name, " was not found")
return None
def get_axes_name(self,unknownax) :
""" compares all axes against the function parameter and
returns the name of that axes if found in figure"""
for ax in self.get_axes() :
if unknownax == ax :
return ax.name
# SET RAW DATA -----------------------------------------------------
def set_rawdata(self, rawdata):
''' This function sets loacally the names of the remote data in a similar way as a local figure would do.
Warning : No consitancy checking is done. The server side will report the errors.
''' This function sets loacally the names of the remote data
in a similar way as a local figure would do.
Warning : No consitancy checking is done. The server
side will report the errors.
'''
self.remote_rawdata = rawdata
......@@ -306,16 +321,10 @@ class MplFigClient(Figure):
synchronized figure (server-side) """
if (self.client is not None) and (self.sync_id != -1):
# try:
if (True):
datas = self.client.sync_fig_format_rawdata(self.sync_id)
# except:
# print(SEVR+'The server-side figure could not format the data...')
# return(False)
for ax, data in zip(self.get_axes(), datas):
# each data is a string that can be unpacked by axes itself
# ax.data = ax.unpackFormattedData(data)
ax.data = data
else:
......
......@@ -176,7 +176,7 @@ class MplHandler(SocketServer.StreamRequestHandler):
def handle(self):
print('HANDLING...')
print('Server handling request...')
reply = None
......@@ -187,6 +187,7 @@ class MplHandler(SocketServer.StreamRequestHandler):
try:
unpickler = MplUnpickler(self.rfile)
request = unpickler.load()
print('Server message loaded...')
if isinstance(request, Query):
if request.query_type == request.READDATA:
......@@ -217,14 +218,13 @@ class MplHandler(SocketServer.StreamRequestHandler):
elif isinstance(request, Answer):
# needed for server???
pass
elif isinstance(request, request):
self.serv_print('received unknown requestnal')
reply = Status(False, "received unknown requestnal")
elif isinstance(request, Signal):
self.serv_print('received unknown Signal')
reply = Status(False, "received unknown Signal")
else:
self.serv_print('what is happening here???'
' received Object of type:')
self.serv_print(str(request))
reply = Status(False, "received something totally diffenent")
self.serv_print('Server received unknown object:'
' of type:'+str(type(request)))
reply = Status(False, "Server received unknown object")
if isinstance(reply, Signal):
if debug:
......@@ -232,10 +232,14 @@ class MplHandler(SocketServer.StreamRequestHandler):
except EOFError:
print("could not unpickle, noting in the file")
except Exeption as e:
raise e
finally:
if reply:
pickle.dump(reply, self.wfile)
#~ else:
#~ pickle.dump(Status(False,None), self.wfile)
# these two lines are not needed
self.wfile.close()
......
......@@ -12,7 +12,8 @@ from clientside.figures_tests import FigTest as FigTestc
from serverside.figures_tests import FigTest2 as FigTests2
from clientside.figures_tests import FigTest2 as FigTestc2
SERVER_IOFUNCTIONS = {'read_stupid_data': read_stupid_data,'read_stupid_data_2': read_stupid_data_2}
SERVER_IOFUNCTIONS = {'read_stupid_data': read_stupid_data,
'read_stupid_data_2': read_stupid_data_2}
SERVER_FIGURES = {'FigTest': FigTests,'FigTest2': FigTests2}
import serverside.myplotlib as mpl_server
......@@ -33,16 +34,24 @@ class ComSetupTestCase(unittest.TestCase):
print('REQUEST CONNECTION...')
self.client.connect(('localhost', 12345))
print('CONNECTED')
self.assertEqual(self.client.connected,True)
self.assertTrue(self.client.connected)
# Send a signal without meaning to the server.
# A negative status message is expected as a repy
#~ client.send(Signal(True,'Hello World')) # Not working ATM
#~ resp = client.wait_for_signal()
#~ self.assertIsInstance(resp, Status)
#~ self.assertFalse(resp.value)
#~ self.assertEqual(type(resp.content),str)
print('REQUEST DISCONNECTION...')
self.client.disconnect()
self.assertFalse(self.client.connected)
print('DISCONNECTED')
def tearDown(self) :
self.server.server_close()
self.server.shutdown()
# Warning: If server and client are local the client can not shut down the port because the server has still a handle on it'''
# maybe this can be circumvented by setting up an external tunneling with ssh???
del self.server
del self.client
......@@ -52,9 +61,6 @@ class RemoteFigTestCase(unittest.TestCase):
self.server = mpl_server.MplServer(port=12347, known_functions=SERVER_IOFUNCTIONS, known_figures=SERVER_FIGURES)
self.client = mpl_client.MplClient()
self.client.host = 'localhost'
self.client.port = 12345
self.server.run(as_daemon=True)
self.client.connect(('localhost',12347))
......@@ -109,6 +115,7 @@ class RemoteFigTestCase(unittest.TestCase):
def test_re_sync(self):
fig1 = self.client.new_sync_figure(FigTestc, ('data1',))
fig1.de_sync_fig()
self.assertEqual(len(self.server._figures),0)
fig1.re_sync_fig()
def tearDown(self) :
......
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