Exemplo n.º 1
0
 def callit( *args, **kwargs):
     #print 'callit args', args
     #print 'callit kwargs', kwargs
     result = {}
     callback = action.get_callback()
     if callback != None:
         return callback( **kwargs)
     return result
Exemplo n.º 2
0
 def get_action_results(self, result, action, instance):
     """ check for out arguments
         if yes: check if there are related ones to StateVariables with
                 non A_ARG_TYPE_ prefix
                 if yes: check if there is a call plugin method for this action
                         if yes: update StateVariable values with call result
                         if no:  get StateVariable values and
                                 add them to result dict
     """
     self.debug('get_action_results', result)
     #print 'get_action_results', action, instance
     r = result
     notify = []
     for argument in action.get_out_arguments():
         #print 'get_state_variable_contents', argument.name
         if argument.name[0:11] != 'A_ARG_TYPE_':
             if action.get_callback() != None:
                 variable = self.variables[instance][argument.get_state_variable()]
                 variable.update(r[argument.name])
                 #print 'update state variable contents', variable.name, variable.value, variable.send_events
                 if(variable.send_events == 'yes' and variable.moderated == False):
                     notify.append(variable)
             else:
                 variable = self.variables[instance][argument.get_state_variable()]
                 #print 'get state variable contents', variable.name, variable.value
                 r[argument.name] = variable.value
                 #print "r", r
         self.service.propagate_notification(notify)
     #r= { '%sResponse'%action.name: r}
     self.info( 'action_results unsorted', action.name, r)
     if len(r) == 0:
         return r
     ordered_result = OrderedDict()
     for argument in action.get_out_arguments():
         ordered_result[argument.name] = r[argument.name]
     self.info( 'action_results sorted', action.name, ordered_result)
     return ordered_result