Beispiel #1
0
    def dump(self):
        scpd = et.Element('scpd',
                          {'xmlns': 'urn:schemas-upnp-org:service-1-0'})

        # specVersion
        specVersion = et.Element('specVersion')
        specVersion.append(make_element('major', str(self.version[0])))
        specVersion.append(make_element('minor', str(self.version[1])))
        scpd.append(specVersion)

        # actionList
        actionList = et.Element('actionList')
        for action_name, action_args in self.actions.items():
            action = et.Element('action')
            action.append(make_element('name', action_name))

            argumentList = et.Element('argumentList')
            for arg in action_args:
                argumentList.append(arg.dump())
            action.append(argumentList)

            actionList.append(action)
        scpd.append(actionList)

        # serviceStateTable
        serviceStateTable = et.Element('serviceStateTable')
        for stateVariable in self.stateVariables.values():
            serviceStateTable.append(stateVariable.dump())
        scpd.append(serviceStateTable)
#         log.msg("xml tree dumped")

        return scpd
Beispiel #2
0
 def dump(self):
     argument = et.Element('argument')
     argument.append(make_element('name', self.name))
     argument.append(make_element('direction', self.direction))
     argument.append(make_element(
         'relatedStateVariable', self.stateVariable))
     return argument
Beispiel #3
0
 def dump(self):
     argument = et.Element('argument')
     argument.append(make_element('name', self.name))
     argument.append(make_element('direction', self.direction))
     argument.append(
         make_element('relatedStateVariable', self.stateVariable))
     return argument
Beispiel #4
0
    def dump(self):
        scpd = et.Element('scpd',
                          {'xmlns': 'urn:schemas-upnp-org:service-1-0'})

        # specVersion
        specVersion = et.Element('specVersion')
        specVersion.append(make_element('major', str(self.version[0])))
        specVersion.append(make_element('minor', str(self.version[1])))
        scpd.append(specVersion)

        # actionList
        actionList = et.Element('actionList')
        for action_name, action_args in self.actions.items():
            action = et.Element('action')
            action.append(make_element('name', action_name))

            argumentList = et.Element('argumentList')
            for arg in action_args:
                argumentList.append(arg.dump())
            action.append(argumentList)

            actionList.append(action)
        scpd.append(actionList)

        # serviceStateTable
        serviceStateTable = et.Element('serviceStateTable')
        for stateVariable in self.stateVariables.values():
            serviceStateTable.append(stateVariable.dump())
        scpd.append(serviceStateTable)
        #         log.msg("xml tree dumped")

        return scpd
Beispiel #5
0
 def dump(self):
     icon = et.Element('icon')
     icon.append(make_element('mimetype', self.mimetype))
     icon.append(make_element('width', str(self.width)))
     icon.append(make_element('height', str(self.height)))
     icon.append(make_element('depth', str(self.depth)))
     icon.append(make_element('url', self.url))
     return icon
Beispiel #6
0
 def dump(self):
     icon = et.Element('icon')
     icon.append(make_element('mimetype', self.mimetype))
     icon.append(make_element('width', str(self.width)))
     icon.append(make_element('height', str(self.height)))
     icon.append(make_element('depth', str(self.depth)))
     icon.append(make_element('url', self.url))
     return icon
Beispiel #7
0
    def dump(self):
        log.msg("xml tree dumped")
#         root = et.Element('root', attrib={
#             'configId': str(self.configID)
#         })
        root = et.Element('root', {'encoding': 'utf-8', 'standalone': 'yes'})
        for prefix, namespace in self.namespaces.items():
            if prefix == '':
                prefix = 'xmlns'
            else:
                prefix = 'xmlns:' + prefix
            root.attrib[prefix] = namespace

        # specVersion
        specVersion = et.Element('specVersion')
        specVersion.append(make_element('major', str(self.version[0])))
        specVersion.append(make_element('minor', str(self.version[1])))
        root.append(specVersion)

        root.append(self.dump_device())
        return root
Beispiel #8
0
    def dump(self):
        log.msg("xml tree dumped")
        #         root = et.Element('root', attrib={
        #             'configId': str(self.configID)
        #         })
        root = et.Element('root', {'encoding': 'utf-8', 'standalone': 'yes'})
        for prefix, namespace in self.namespaces.iteritems():
            if prefix == '':
                prefix = 'xmlns'
            else:
                prefix = 'xmlns:' + prefix
            root.attrib[prefix] = namespace

        # specVersion
        specVersion = et.Element('specVersion')
        specVersion.append(make_element('major', str(self.version[0])))
        specVersion.append(make_element('minor', str(self.version[1])))
        root.append(specVersion)

        root.append(self.dump_device())
        return root
Beispiel #9
0
    def dump(self):
        sendEventsStr = "no"
        if self.sendEvents:
            sendEventsStr = "yes"

        stateVariable = et.Element('stateVariable', sendEvents=sendEventsStr)

        stateVariable.append(make_element('name', self.name))
        stateVariable.append(make_element('dataType', self.dataType))

        if self.allowedValues:
            allowedValues = et.Element('allowedValueList')
            for value in self.allowedValues:
                allowedValues.append(make_element('allowedValue', value))
            stateVariable.append(allowedValues)

        if self.allowedRange:
            allowedRange = et.Element('allowedValueRange')
#             minimum = et.Element('minimum', text=str(self.allowedRange[0]))
            allowedRange.append(make_element('minimum', self.allowedRange[0]))
#             maximum = et.Element('maximum', text=str(self.allowedRange[1]))
            allowedRange.append(make_element('maximum', self.allowedRange[1]))
#             step = et.Element('step', text=str(self.allowedRange[2]))
            allowedRange.append(make_element('step', self.allowedRange[2]))
            stateVariable.append(allowedRange)

#         if self.name == 'Volume':
#             log.msg(stateVariable)
        return stateVariable
Beispiel #10
0
    def dump(self):
        sendEventsStr = "no"
        if self.sendEvents:
            sendEventsStr = "yes"

        stateVariable = et.Element('stateVariable', sendEvents=sendEventsStr)

        stateVariable.append(make_element('name', self.name))
        stateVariable.append(make_element('dataType', self.dataType))

        if self.allowedValues:
            allowedValues = et.Element('allowedValueList')
            for value in self.allowedValues:
                allowedValues.append(make_element('allowedValue', value))
            stateVariable.append(allowedValues)

        if self.allowedRange:
            allowedRange = et.Element('allowedValueRange')
            #             minimum = et.Element('minimum', text=str(self.allowedRange[0]))
            allowedRange.append(make_element('minimum', self.allowedRange[0]))
            #             maximum = et.Element('maximum', text=str(self.allowedRange[1]))
            allowedRange.append(make_element('maximum', self.allowedRange[1]))
            #             step = et.Element('step', text=str(self.allowedRange[2]))
            allowedRange.append(make_element('step', self.allowedRange[2]))
            stateVariable.append(allowedRange)


#         if self.name == 'Volume':
#             log.msg(stateVariable)
        return stateVariable
Beispiel #11
0
    def dump_device(self):
        device = et.Element('device')

        for attr_name in [
            'deviceType',
            'friendlyName',
            'manufacturer',
            'manufacturerURL',
            'modelDescription',
            'modelName',
            'modelNumber',
            'modelURL',
            'serialNumber',
            'UDN'
        ]:
            if hasattr(self, attr_name):
                val = getattr(self, attr_name)
                if val is not None:
                    device.append(make_element(attr_name, val))

        for name, val in self.extras.items():
            device.append(make_element(name, val))

        # iconList
        iconList = et.Element('iconList')
        for icon in self.icons:
            iconList.append(icon.dump())
        device.append(iconList)

        # serviceList
        serviceList = et.Element('serviceList')
        for service in self.services:
            _service = et.Element('service')
            _service.append(make_element('serviceType', service.serviceType))
            _service.append(make_element('serviceId', service.serviceId))
            _service.append(make_element(
                            'controlURL',
                            '/' + service.serviceUrl + '/control'))
            _service.append(make_element(
                            'eventSubURL',
                            '/' + service.serviceUrl + '/event'))
            _service.append(make_element('SCPDURL', '/' + service.serviceUrl))
            serviceList.append(_service)
        device.append(serviceList)

        return device
Beispiel #12
0
    def dump_device(self):
        device = et.Element('device')

        for attr_name in [
                'deviceType', 'friendlyName', 'manufacturer',
                'manufacturerURL', 'modelDescription', 'modelName',
                'modelNumber', 'modelURL', 'serialNumber', 'UDN'
        ]:
            if hasattr(self, attr_name):
                val = getattr(self, attr_name)
                if val is not None:
                    device.append(make_element(attr_name, val))

        for name, val in self.extras.items():
            device.append(make_element(name, val))

        # iconList
        iconList = et.Element('iconList')
        for icon in self.icons:
            iconList.append(icon.dump())
        device.append(iconList)

        # serviceList
        serviceList = et.Element('serviceList')
        for service in self.services:
            _service = et.Element('service')
            _service.append(make_element('serviceType', service.serviceType))
            _service.append(make_element('serviceId', service.serviceId))
            _service.append(
                make_element('controlURL',
                             '/' + service.serviceUrl + '/control'))
            _service.append(
                make_element('eventSubURL',
                             '/' + service.serviceUrl + '/event'))
            _service.append(make_element('SCPDURL', '/' + service.serviceUrl))
            serviceList.append(_service)
        device.append(serviceList)

        return device
Beispiel #13
0
    def dump_device(self):
        device = et.Element('device')

        for attr_name in [
            'deviceType',
            'friendlyName',
            'manufacturer',
            'manufacturerURL',
            'modelDescription',
            'modelName',
            'modelNumber',
            'modelURL',
            'serialNumber',
            'UDN'
        ]:
            if hasattr(self, attr_name):
                val = getattr(self, attr_name)
                if val is not None:
                    device.append(make_element(attr_name, val))

        for name, val in self.extras.iteritems():
            device.append(make_element(name, val))

        # icon List
        iconList = et.Element('iconList')
        for icon in self.icons:
            iconList.append(icon.dump())
        device.append(iconList)

        # service List
        serviceList = et.Element('serviceList')
        for service in self.services:
            _service = et.Element('service')
            _service.append(make_element('serviceType', service.serviceType))
            _service.append(make_element('serviceId', service.serviceId))
            _service.append(make_element(
                            'controlURL',
                            '/' + self.uuid + '/' +
                            service.serviceUrl + '/control'))
            _service.append(make_element(
                            'eventSubURL',
                            '/' + self.uuid + '/' +
                            service.serviceUrl + '/event'))
            _service.append(make_element('SCPDURL', '/' + self.uuid + '/' +
                                         service.serviceUrl))
            serviceList.append(_service)
        device.append(serviceList)

        # device List
        if len(self.devices) > 0:
            deviceList = et.Element('deviceList')
            for device_ in self.devices:
                _device = et.Element('device')
                _device.append(make_element('rootType', device_.deviceType))
                _spec_version = et.Element('specVersion')
                _spec_version.append(
                    make_element('major', str(device_.version[0])))
                _spec_version.append(
                    make_element('minor', str(device_.version[1])))
                _device.append(_spec_version)
                _device.append(make_element(
                    'baseURL',
                    '/' + device_.deviceUrl))
            deviceList.append(_device)
            device.append(deviceList)

        return device
Beispiel #14
0
    def dump_device(self):
        device = et.Element('device')

        for attr_name in [
                'deviceType', 'friendlyName', 'manufacturer',
                'manufacturerURL', 'modelDescription', 'modelName',
                'modelNumber', 'modelURL', 'serialNumber', 'UDN'
        ]:
            if hasattr(self, attr_name):
                val = getattr(self, attr_name)
                if val is not None:
                    device.append(make_element(attr_name, val))

        for name, val in self.extras.iteritems():
            device.append(make_element(name, val))

        # icon List
        iconList = et.Element('iconList')
        for icon in self.icons:
            iconList.append(icon.dump())
        device.append(iconList)

        # service List
        serviceList = et.Element('serviceList')
        for service in self.services:
            _service = et.Element('service')
            _service.append(make_element('serviceType', service.serviceType))
            _service.append(make_element('serviceId', service.serviceId))
            _service.append(
                make_element(
                    'controlURL',
                    '/' + self.uuid + '/' + service.serviceUrl + '/control'))
            _service.append(
                make_element(
                    'eventSubURL',
                    '/' + self.uuid + '/' + service.serviceUrl + '/event'))
            _service.append(
                make_element('SCPDURL',
                             '/' + self.uuid + '/' + service.serviceUrl))
            serviceList.append(_service)
        device.append(serviceList)

        # device List
        if len(self.devices) > 0:
            deviceList = et.Element('deviceList')
            for device_ in self.devices:
                _device = et.Element('device')
                _device.append(make_element('rootType', device_.deviceType))
                _spec_version = et.Element('specVersion')
                _spec_version.append(
                    make_element('major', str(device_.version[0])))
                _spec_version.append(
                    make_element('minor', str(device_.version[1])))
                _device.append(_spec_version)
                _device.append(make_element('baseURL',
                                            '/' + device_.deviceUrl))
            deviceList.append(_device)
            device.append(deviceList)

        return device