provide setup for MLZ_Amagnet to be used @PSI soon
Also implement lots of fixes and improvements. fixes: #3381 Change-Id: Ibe6664da00756ae5813b90f190295045808b2ff0
This commit is contained in:
@ -39,12 +39,12 @@ class MessageEncoder(object):
|
||||
raise NotImplemented
|
||||
|
||||
|
||||
from demo_v2 import DemoEncoder as DemoEncoderV2
|
||||
from demo_v3 import DemoEncoder as DemoEncoderV3
|
||||
from demo_v4 import DemoEncoder as DemoEncoderV4
|
||||
from text import TextEncoder
|
||||
from pickle import PickleEncoder
|
||||
from simplecomm import SCPEncoder
|
||||
from .demo_v2 import DemoEncoder as DemoEncoderV2
|
||||
from .demo_v3 import DemoEncoder as DemoEncoderV3
|
||||
from .demo_v4 import DemoEncoder as DemoEncoderV4
|
||||
from .text import TextEncoder
|
||||
from .pickle import PickleEncoder
|
||||
from .simplecomm import SCPEncoder
|
||||
|
||||
ENCODERS = {
|
||||
'pickle': PickleEncoder,
|
||||
|
@ -24,6 +24,8 @@
|
||||
# implement as class as they may need some internal 'state' later on
|
||||
# (think compressors)
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from secop.protocol.encoding import MessageEncoder
|
||||
from secop.protocol import messages
|
||||
from secop.lib.parsing import *
|
||||
@ -43,9 +45,9 @@ class DemoEncoder(MessageEncoder):
|
||||
if match:
|
||||
novalue, devname, pname, propname, assign = match.groups()
|
||||
if assign:
|
||||
print "parsing", assign,
|
||||
print("parsing", assign,)
|
||||
assign = parse_args(assign)
|
||||
print "->", assign
|
||||
print("->", assign)
|
||||
return messages.DemoRequest(novalue, devname, pname, propname,
|
||||
assign)
|
||||
return messages.HelpRequest()
|
||||
@ -56,13 +58,13 @@ class DemoEncoder(MessageEncoder):
|
||||
handler_name = '_encode_' + msg.__class__.__name__
|
||||
handler = getattr(self, handler_name, None)
|
||||
if handler is None:
|
||||
print "Handler %s not yet implemented!" % handler_name
|
||||
print("Handler %s not yet implemented!" % handler_name)
|
||||
try:
|
||||
args = dict((k, msg.__dict__[k]) for k in msg.ARGS)
|
||||
result = handler(**args)
|
||||
except Exception as e:
|
||||
print "Error encoding %r with %r!" % (msg, handler)
|
||||
print e
|
||||
print("Error encoding %r with %r!" % (msg, handler))
|
||||
print(e)
|
||||
return '~InternalError~'
|
||||
return result
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
# implement as class as they may need some internal 'state' later on
|
||||
# (think compressors)
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from secop.protocol.encoding import MessageEncoder
|
||||
from secop.protocol.messages import *
|
||||
from secop.protocol.errors import ProtocolError
|
||||
@ -257,7 +259,7 @@ class DemoEncoder(MessageEncoder):
|
||||
mgroups['args'] = args
|
||||
|
||||
# reformat qualifiers
|
||||
print mgroups
|
||||
print(mgroups)
|
||||
quals = dict(
|
||||
qual.split('=', 1)
|
||||
for qual in helper(mgroups.pop('qualifiers', ';')))
|
||||
@ -306,9 +308,9 @@ class DemoEncoder(MessageEncoder):
|
||||
'read blub:c=14;t=3.3',
|
||||
]
|
||||
for m in testmsg:
|
||||
print repr(m)
|
||||
print self.decode(m)
|
||||
print
|
||||
print(repr(m))
|
||||
print(self.decode(m))
|
||||
print()
|
||||
|
||||
|
||||
DEMO_RE_MZ = re.compile(
|
||||
@ -326,7 +328,7 @@ class DemoEncoder_MZ(MessageEncoder):
|
||||
def decode(sef, encoded):
|
||||
m = DEMO_RE_MZ.match(encoded)
|
||||
if m:
|
||||
print "implement me !"
|
||||
print("implement me !")
|
||||
return HelpRequest()
|
||||
|
||||
def encode(self, msg):
|
||||
|
@ -24,6 +24,8 @@
|
||||
# implement as class as they may need some internal 'state' later on
|
||||
# (think compressors)
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from secop.lib.parsing import format_time
|
||||
from secop.protocol.encoding import MessageEncoder
|
||||
from secop.protocol.messages import *
|
||||
@ -235,7 +237,7 @@ class DemoEncoder(MessageEncoder):
|
||||
# first check beginning
|
||||
match = DEMO_RE.match(encoded)
|
||||
if not match:
|
||||
print repr(encoded), repr(IDENTREPLY)
|
||||
print(repr(encoded), repr(IDENTREPLY))
|
||||
if encoded == IDENTREPLY: # XXX:better just check the first 2 parts...
|
||||
return IdentifyReply(version_string=encoded)
|
||||
|
||||
@ -274,9 +276,9 @@ class DemoEncoder(MessageEncoder):
|
||||
origin=encoded)
|
||||
|
||||
def tests(self):
|
||||
print "---- Testing encoding -----"
|
||||
print("---- Testing encoding -----")
|
||||
for msgclass, parts in sorted(self.ENCODEMAP.items()):
|
||||
print msgclass
|
||||
print(msgclass)
|
||||
e = self.encode(
|
||||
msgclass(
|
||||
module='<module>',
|
||||
@ -289,17 +291,17 @@ class DemoEncoder(MessageEncoder):
|
||||
nonce='<nonce>',
|
||||
errorclass='InternalError',
|
||||
errorinfo='nix'))
|
||||
print e
|
||||
print self.decode(e)
|
||||
print
|
||||
print "---- Testing decoding -----"
|
||||
print(e)
|
||||
print(self.decode(e))
|
||||
print()
|
||||
print("---- Testing decoding -----")
|
||||
for msgtype, _ in sorted(self.DECODEMAP.items()):
|
||||
msg = '%s a:b 3' % msgtype
|
||||
if msgtype == EVENT:
|
||||
msg = '%s a:b [3,{"t":193868}]' % msgtype
|
||||
print msg
|
||||
print(msg)
|
||||
d = self.decode(msg)
|
||||
print d
|
||||
print self.encode(d)
|
||||
print
|
||||
print "---- Testing done -----"
|
||||
print(d)
|
||||
print(self.encode(d))
|
||||
print()
|
||||
print("---- Testing done -----")
|
||||
|
Reference in New Issue
Block a user