Skip to content
Snippets Groups Projects
Commit e30cef09 authored by jkerdreu's avatar jkerdreu
Browse files

Fixed old naming issues

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2733 b32b6428-25c9-4566-ad07-03861ab6144f
parent 3ec3699f
No related branches found
No related tags found
No related merge requests found
......@@ -82,7 +82,7 @@ class Engine(object):
#####################################################
# Fifo for msg to send
def queue_msg(self, msg):
"""queue a message"""
"""queue an encoded / cyphered message"""
self.__txFifo.append(msg)
def process_tx_msg(self):
......@@ -98,7 +98,7 @@ class Engine(object):
break
def send_msg(self, msg):
"""Send an message to the bus, use queue_msg instead"""
"""Send an encoded message to the bus, use queue_msg instead"""
self.network.send(msg)
def send_request(self,dev,targets,action,body = None):
......@@ -117,14 +117,15 @@ class Engine(object):
self.queue_msg(msg)
def send_get_description(self,dev,targets):
"""queue a getDescription request"""
"""queue a get_description request"""
self.send_request(dev,targets,'get_description')
def send_get_attributes(self,dev,targets):
"""queue a getAttributes request"""
"""queue a get_attributes request"""
self.send_request(dev,targets,'get_attributes')
def send_notification(self,dev,action,body=None):
"""queue a notificaton"""
msg = self.msg_factory.build_msg(dev,[],MessageType.NOTIFY,action,body)
self.queue_msg(msg)
......@@ -137,7 +138,7 @@ class Engine(object):
msg = self.msg_factory.build_alive_for(dev, timeout)
self.queue_msg(msg)
def send_isAlive(self, dev, dev_types="any.any"):
def send_is_alive(self, dev, dev_types="any.any"):
"""Send a is_alive message, w/ dev_types filtering"""
body = {}
body['dev_types'] = dev_types
......@@ -210,7 +211,6 @@ class Engine(object):
"""Filter msg for devices according default xAAL API then process the
request for each targets identied in the engine
"""
if not msg.is_request():
return
......@@ -219,9 +219,9 @@ class Engine(object):
if msg.action == 'is_alive':
self.send_alive(target)
else:
self.handle_method_request(msg, target)
self.handle_action_request(msg, target)
def handle_method_request(self, msg, target):
def handle_action_request(self, msg, target):
"""Run method (xAAL exposed method) on device:
- None is returned if device method do not return anything
- result is returned if device method gives a response
......@@ -254,9 +254,11 @@ class Engine(object):
return t
def remove_timer(self,timer):
"""remove a given timer from the list"""
self.timers.remove(timer)
def process_timers(self):
"""Process all timers to find out which ones should be run"""
expire_list = []
if len(self.timers)!=0 :
......@@ -316,6 +318,9 @@ class Engine(object):
def stop(self):
self.state = EngineState.halt
def shutdown(self):
self.stop()
def run(self):
self.start()
self.state = EngineState.run
......@@ -353,6 +358,13 @@ def filter_msg_for_devices(msg, devices):
return results
def run_action(msg,device):
""" Extract an action & launch it
Return:
- action result
- None if no result
Note: If an exception raised, it's logged, and raise an XAALError.
"""
method,params = search_action(msg,device)
result = None
try:
......@@ -362,13 +374,11 @@ def run_action(msg,device):
raise XAALError("Error in method:%s params:%s" % (msg.action,params))
return result
def search_action(msg, device):
"""Extract & run an action (match with exposed method) from a msg
on the selected device.
"""Extract an action (match with methods) from a msg on the device.
Return:
- None
- result from method if method return something
- found method & matching parameters
Note: If method not found raise error, if wrong parameter error log
"""
......@@ -380,7 +390,7 @@ def search_action(msg, device):
body_params = None
if msg.body:
method_params = get_args_method(method)
body_params = msg.get_parameters()
body_params = msg.body
for k in body_params:
temp = '_%s' %k
......
......@@ -159,7 +159,7 @@ class MessageFactory(object):
-The type of the message
-The action of the message
-A body if it's necessary (None if not)
it will return a message encoded in CBOR and Ciphered.
it will return a message encoded in CBOR and ciphered.
"""
message = Message()
if dev:
......@@ -233,26 +233,6 @@ class Message(object):
def targets_as_string(self):
return [str(k) for k in self.targets]
#####################################################
# Body
#####################################################
def _get_parameters(self, args):
parameters = {}
for p in range(0, len(args)):
if isinstance(self.body[args[p]], str):
param = "'%s'" % self.body[args[p]]
else:
param = self.body[args[p]]
parameters[args[p]] = param
return parameters
def get_parameters(self):
""" request parameters are in body hash, return asis"""
return self.body
#####################################################
def dump(self):
""" dump log a message """
logger.debug("== Message (0x%x) ======================" % id(self))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment