MCPcopy Create free account
hub / github.com/LabPy/lantz / handle

Method handle

lantz/drivers/legacy/rpc.py:633–682  ·  view source on GitHub ↗
(self, call)

Source from the content-addressed store, hash-verified

631 raise RPCError('unregister failed')
632
633 def handle(self, call):
634 # Don't use unpack_header but parse the header piecewise
635 # XXX I have no idea if I am using the right error responses!
636 self.unpacker.reset(call)
637 self.packer.reset()
638 xid = self.unpacker.unpack_uint()
639 self.packer.pack_uint(xid)
640 temp = self.unpacker.unpack_enum()
641 if temp != msg_type.CALL:
642 return None # Not worthy of a reply
643 self.packer.pack_uint(msg_type.REPLY)
644 temp = self.unpacker.unpack_uint()
645 if temp != RPCVERSION:
646 self.packer.pack_uint(reply_stat.MSG_DENIED)
647 self.packer.pack_uint(reject_stat.RPC_MISMATCH)
648 self.packer.pack_uint(RPCVERSION)
649 self.packer.pack_uint(RPCVERSION)
650 return self.packer.get_buf()
651 self.packer.pack_uint(reply_stat.MSG_ACCEPTED)
652 self.packer.pack_auth((auth_flavor.AUTH_NULL, make_auth_null()))
653 prog = self.unpacker.unpack_uint()
654 if prog != self.prog:
655 self.packer.pack_uint(accept_stat.PROG_UNAVAIL)
656 return self.packer.get_buf()
657 vers = self.unpacker.unpack_uint()
658 if vers != self.vers:
659 self.packer.pack_uint(accept_stat.PROG_MISMATCH)
660 self.packer.pack_uint(self.vers)
661 self.packer.pack_uint(self.vers)
662 return self.packer.get_buf()
663 proc = self.unpacker.unpack_uint()
664 methname = 'handle_' + repr(proc)
665 try:
666 meth = getattr(self, methname)
667 except AttributeError:
668 self.packer.pack_uint(accept_stat.PROC_UNAVAIL)
669 return self.packer.get_buf()
670 cred = self.unpacker.unpack_auth()
671 verf = self.unpacker.unpack_auth()
672 try:
673 meth() # Unpack args, call turn_around(), pack reply
674 except (EOFError, RPCGarbageArgs):
675 # Too few or too many arguments
676 self.packer.reset()
677 self.packer.pack_uint(xid)
678 self.packer.pack_uint(msg_type.REPLY)
679 self.packer.pack_uint(reply_stat.MSG_ACCEPTED)
680 self.packer.pack_auth((auth_flavor.AUTH_NULL, make_auth_null()))
681 self.packer.pack_uint(accept_stat.GARBAGE_ARGS)
682 return self.packer.get_buf()
683
684 def turn_around(self):
685 try:

Callers 2

sessionMethod · 0.45
sessionMethod · 0.45

Calls 4

make_auth_nullFunction · 0.85
pack_authMethod · 0.80
unpack_authMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected