def soap__generic(self, *args, **kwargs): """ generic UPnP service control method, which will be used if no soap_ACTIONNAME method in the server service control class can be found """ try: action = self.actions[kwargs['soap_methodName']] except: return failure.Failure(errorCode(401)) try: instance = int(kwargs['InstanceID']) except: instance = 0 self.info("soap__generic", action, __name__, kwargs) del kwargs['soap_methodName'] if (kwargs.has_key('X_UPnPClient') and kwargs['X_UPnPClient'] == 'XBox'): if (action.name == 'Browse' and kwargs.has_key('ContainerID')): """ XXX: THIS IS SICK """ kwargs['ObjectID'] = kwargs['ContainerID'] del kwargs['ContainerID'] in_arguments = action.get_in_arguments() for arg_name, arg in kwargs.iteritems(): if arg_name.find('X_') == 0: continue l = [a for a in in_arguments if arg_name == a.get_name()] if len(l) > 0: in_arguments.remove(l[0]) else: self.critical('argument %s not valid for action %s' % (arg_name, action.name)) return failure.Failure(errorCode(402)) if len(in_arguments) > 0: self.critical('argument %s missing for action %s' % ([a.get_name() for a in in_arguments], action.name)) return failure.Failure(errorCode(402)) 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 def got_error(x): #print 'failure', x self.info('soap__generic error during call processing') return x # call plugin method for this action d = defer.maybeDeferred(callit, *args, **kwargs) d.addCallback(self.get_action_results, action, instance) d.addErrback(got_error) return d
def soap__generic(self, *args, **kwargs): """ generic UPnP service control method, which will be used if no soap_ACTIONNAME method in the server service control class can be found """ try: action = self.actions[kwargs['soap_methodName']] except: return failure.Failure(errorCode(401)) try: instance = int(kwargs['InstanceID']) except: instance = 0 self.info("soap__generic", action, __name__, kwargs) del kwargs['soap_methodName'] if( kwargs.has_key('X_UPnPClient') and kwargs['X_UPnPClient'] == 'XBox'): if(action.name == 'Browse' and kwargs.has_key('ContainerID')): """ XXX: THIS IS SICK """ kwargs['ObjectID'] = kwargs['ContainerID'] del kwargs['ContainerID'] in_arguments = action.get_in_arguments() for arg_name, arg in kwargs.iteritems(): if arg_name.find('X_') == 0: continue l = [ a for a in in_arguments if arg_name == a.get_name()] if len(l) > 0: in_arguments.remove(l[0]) else: self.critical('argument %s not valid for action %s' % (arg_name,action.name)) return failure.Failure(errorCode(402)) if len(in_arguments) > 0: self.critical('argument %s missing for action %s' % ([ a.get_name() for a in in_arguments],action.name)) return failure.Failure(errorCode(402)) 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 def got_error(x): #print 'failure', x self.info('soap__generic error during call processing') return x # call plugin method for this action d = defer.maybeDeferred( callit, *args, **kwargs) d.addCallback( self.get_action_results, action, instance) d.addErrback(got_error) return d
def soap__generic(self, *args, **kwargs): '''Generic UPnP service control method, which will be used if no soap_ACTIONNAME method in the server service control class can be found.''' try: action = self.actions[kwargs['soap_methodName']] except KeyError: return failure.Failure(errorCode(401)) try: instance = int(kwargs['InstanceID']) except (ValueError, KeyError): instance = 0 self.info(f'soap__generic {action} {__name__} {kwargs}') del kwargs['soap_methodName'] in_arguments = action.get_in_arguments() for arg_name, arg in kwargs.items(): if arg_name.find('X_') == 0: continue al = [a for a in in_arguments if arg_name == a.get_name()] if len(al) > 0: in_arguments.remove(al[0]) else: self.critical( f'argument {arg_name} not valid for action {action.name}') return failure.Failure(errorCode(402)) if len(in_arguments) > 0: args_names = [a.get_name() for a in in_arguments] self.critical(f'argument {args_names} ' f'missing for action {action.name}') return failure.Failure(errorCode(402)) def got_error(x): self.info('dbus error during call processing') return x # call plugin method for this action # print 'callit args', args # print 'callit kwargs', kwargs # print 'callit action', action # print 'callit dbus action', self.service.service.action d = defer.Deferred() self.service.service.call_action( action.name, dbus.Dictionary(kwargs, signature='ss'), reply_handler=d.callback, error_handler=d.errback, utf8_strings=True, ) d.addCallback(self.get_action_results, action, instance) d.addErrback(got_error) return d
def soap__generic(self, *args, **kwargs): """ generic UPnP service control method, which will be used if no soap_ACTIONNAME method in the server service control class can be found """ try: action = self.actions[kwargs['soap_methodName']] except: return failure.Failure(errorCode(401)) try: instance = int(kwargs['InstanceID']) except: instance = 0 self.info("soap__generic", action, __name__, kwargs) del kwargs['soap_methodName'] in_arguments = action.get_in_arguments() for arg_name, arg in kwargs.iteritems(): if arg_name.find('X_') == 0: continue l = [ a for a in in_arguments if arg_name == a.get_name()] if len(l) > 0: in_arguments.remove(l[0]) else: self.critical('argument %s not valid for action %s' % (arg_name,action.name)) return failure.Failure(errorCode(402)) if len(in_arguments) > 0: self.critical('argument %s missing for action %s' % ([ a.get_name() for a in in_arguments],action.name)) return failure.Failure(errorCode(402)) def got_error(x): self.info('dbus error during call processing') return x # call plugin method for this action #print 'callit args', args #print 'callit kwargs', kwargs #print 'callit action', action #print 'callit dbus action', self.service.service.action d = defer.Deferred() self.service.service.call_action( action.name, dbus.Dictionary(kwargs,signature='ss'), reply_handler = d.callback, error_handler = d.errback,utf8_strings=True) d.addCallback( self.get_action_results, action, instance) d.addErrback(got_error) return d