Example #1
0
    def _parse_action_response(self, action_def, xml_data):
        """Parse xml action response response. Return out arguments."""

        # Parse Response XML
        dictionary = upnpsoap.parse_action_response(xml_data)

        # Check Response
        if dictionary['service_type'] != self.get_service_type():
            return None
        if dictionary['action_name'] != action_def['name']:
            return None        
        if len(dictionary['arguments']) != len(action_def['outargs']):
            return None

        # Convert result arguments (name, data) to python objects.
        outargs = []
        for i in range(len(action_def['outargs'])):
            outargdef = action_def['outargs'][i]
            stv = outargdef['rsv']
            if outargdef['name'] != dictionary['arguments'][i][0]:
                return None
            data = dictionary['arguments'][i][1]
            obj = upnpmarshal.loads_data_by_upnp_type(
                stv['upnpType'], data)
            outargs.append(obj)
        return outargs
Example #2
0
 def notify(self, sid, seq, var_list):
     """Event notification delivered by UPnPClient."""
     for var_name, data in var_list:
         if self._sv_def_map.has_key(var_name):
             stv = self._sv_def_map[var_name]
             obj = upnpmarshal.loads_data_by_upnp_type(
                 stv['upnpType'], data)
             for handler in self._notify_handlers:
                 handler(var_name, int(seq), obj)
Example #3
0
 def _define_state_variable(self, sv_spec):
     """Define a state variable for the stub. Called as a result of parsing
     the xml service description."""
     try:
         sv_def = {}
         sv_def['name'] = name = sv_spec['name']
         sv_def['upnpType'] = upnp_type = str(sv_spec['dataType'])
         sv_def['pyType'] = upnpmarshal.loads_python_type(upnp_type)
         dvalue = sv_spec['defaultValue']
         if  dvalue != None:
             dvalue = upnpmarshal.loads_data_by_upnp_type(upnp_type, dvalue)
         sv_def['defaultValue'] = dvalue
         sv_def['sendEvents'] = upnpmarshal.loads(types.BooleanType, 
                                                  sv_spec['sendEvents'])
         self._sv_def_map[name] = sv_def    
     except upnpmarshal.MarshalError, why:
         print why
         return