def get_client(self, device, service): if self.xmldir is not None: client = None else: import importlib module_name = service.split(':')[-2] app = getattr(importlib.import_module( 'upnpy_spyne.services.templates.' + module_name.lower()), module_name) if device['network'] == 'lan': client = Client( device['services'][service]['controlURL'], Application([app], app.tns, in_protocol=Soap11(), out_protocol=Soap11())) client.set_options( out_header={'Content-Type': ['text/xml;charset="utf-8"'], 'Soapaction': [app.tns]}) else: url = (self.xmlstream, device['location'],) client = Client( url, Application([app], app.tns, in_protocol=Soap11(xml_declaration=False), out_protocol=Soap11(xml_declaration=False)), cloud=True) # print('**********%s' % service) # print(device['services'][service]) return client
def test_2(): from upnpy_spyne.services.templates.switchpower import SwitchPower # log.startLogging(sys.stdout) client = Client( 'http://192.168.0.60:8000', Application([SwitchPower], SwitchPower.tns, in_protocol=Soap11(), out_protocol=Soap11())) client.set_options( out_header={'Content-Type': ['text/xml;charset="utf-8"'], 'Soapaction': [SwitchPower.tns]}) d = client.service.GetStatus() d.addCallback(log.debug) onoff = False for i in range(6): reactor.callLater( # @UndefinedVariable i, client.service.SetTarget, not onoff) onoff = not onoff