예제 #1
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', action.name, r)
     return r
예제 #2
0
파일: service.py 프로젝트: pezam/Cohen
    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 %s', 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() is not None:
              variable = self.variables[instance][argument.get_state_variable()]
              variable.update(r[argument.name])
              if variable.send_events == 'yes' and not variable.moderated:
                  notify.append(variable)
            else:
              variable = self.variables[instance][argument.get_state_variable()]
              r[argument.name] = variable.value
          self.service.propagate_notification(notify)

        self.info('action_results unsorted %s %s', 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 %s %s', action.name, ordered_result)
        return ordered_result
예제 #3
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
예제 #4
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
예제 #5
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
예제 #6
0
 def callit(*args, **kwargs):
     result = {}
     callback = action.get_callback()
     if callback != None:
         return callback(**kwargs)
     return result