示例#1
0
    def _parseDescription(self, descriptionUrl):
        xml = get_xml(descriptionUrl)
        if xml is None:
            raise Exception()

        xActionList = xml.find(S_SER + 'actionList')

        for xAction in xActionList.iterfind(S_SER + 'action'):
            actionName = xAction.findtext(S_SER + 'name')

            if self.actionInfo.has_key(actionName):  # Action already exists
                raise Exception()
            self.actionInfo[actionName] = {}

            xArgumentList = xAction.find(S_SER + 'argumentList')
            for xArgument in xArgumentList.iterfind(S_SER + 'argument'):
                argumentName = xArgument.findtext(S_SER + 'name')
                argumentDirection = xArgument.findtext(S_SER + 'direction')

                if self.actionInfo[actionName].has_key(argumentName):
                    raise Exception()
                self.actionInfo[actionName][argumentName] = argumentDirection

        for ak, action in self.actionInfo.items():
            funcName = ak[ak.index('X_') + 2:]
            funcName = funcName[0].lower() + funcName[1:]

            self.supportedFunctions.append(funcName)
示例#2
0
文件: ircc.py 项目: fuzeman/PyIRCC
    def _parseDescription(self, descriptionUrl):
        xml = get_xml(descriptionUrl)
        if xml is None:
            raise Exception()

        xActionList = xml.find(S_SER + 'actionList')

        for xAction in xActionList.iterfind(S_SER + 'action'):
            actionName = xAction.findtext(S_SER + 'name')

            if self.actionInfo.has_key(actionName):  # Action already exists
                raise Exception()
            self.actionInfo[actionName] = {}

            xArgumentList = xAction.find(S_SER + 'argumentList')
            for xArgument in xArgumentList.iterfind(S_SER + 'argument'):
                argumentName = xArgument.findtext(S_SER + 'name')
                argumentDirection = xArgument.findtext(S_SER + 'direction')

                if self.actionInfo[actionName].has_key(argumentName):
                    raise Exception()
                self.actionInfo[actionName][argumentName] = argumentDirection

        for ak, action in self.actionInfo.items():
            funcName = ak[ak.index('X_') + 2:]
            funcName = funcName[0].lower() + funcName[1:]

            self.supportedFunctions.append(funcName)
示例#3
0
    def _parseDeviceDescription(self, deviceDescriptionURL):
        xml = get_xml(deviceDescriptionURL)
        if xml is None:
            raise Exception()

        xDevice = xml.find('{urn:schemas-upnp-org:device-1-0}device')

        xIrccDevice = xDevice.find(S_AV + 'X_IRCC_DeviceInfo')
        self.deviceInfo.irccVersion = xIrccDevice.findtext(S_AV + 'X_IRCC_Version')
        self.deviceInfo.irccCategories = []
        categoryList = xIrccDevice.find(S_AV + 'X_IRCC_CategoryList')
        if categoryList is not None:
            for irccCategory in categoryList.iterfind(S_AV + 'X_IRCC_Category'):
                self.deviceInfo.irccCategories.append(irccCategory.findtext(S_AV + 'X_CategoryInfo'))

        xUnrDevice = xDevice.find(S_AV + 'X_UNR_DeviceInfo')
        self.deviceInfo.unrVersion = xUnrDevice.findtext(S_AV + 'X_UNR_Version')
        self.deviceInfo.unrCersActionUrl = xUnrDevice.findtext(S_AV + 'X_CERS_ActionList_URL')

        xRdisDevice = xDevice.find(S_AV + 'X_RDIS_DeviceInfo')
        self.deviceInfo.rdisVersion = xRdisDevice.findtext(S_AV + 'X_RDIS_Version')
        self.deviceInfo.rdisSessionControl = bool(xRdisDevice.findtext(S_AV + 'X_RDIS_SESSION_CONTROL'))
        self.deviceInfo.rdisEntryPort = int(xRdisDevice.findtext(S_AV + 'X_RDIS_ENTRY_PORT'))

        xS2mtvDevice = xDevice.find(S_AV + 'X_S2MTV_DeviceInfo')
        self.deviceInfo.s2mtvVersion = xS2mtvDevice.findtext(S_AV + 'X_S2MTV_Version')
        self.deviceInfo.s2mtvBaseUrl = xS2mtvDevice.findtext(S_AV + 'X_S2MTV_BaseURL')
        if self.deviceInfo.s2mtvBaseUrl[-1] != '/':
            self.deviceInfo.s2mtvBaseUrl += '/'

        self.deviceInfo.maxBgmCount = int(xDevice.findtext(S_AV + 'X_MaxBGMCount'))
        self.deviceInfo.standardDmr = xDevice.findtext(S_AV + 'X_StandardDMR')
示例#4
0
文件: unr.py 项目: fuzeman/PyIRCC
    def _parseActionList(self):
        xml = get_xml(self._deviceInfo.unrCersActionUrl)

        for action in xml.iterfind("action"):
            name = action.get('name').replace('::', '_')

            self.supportedFunctions.append(name)
            if self.actionUrls.has_key(name):
                raise Exception()
            self.actionUrls[name] = action.get('url').replace(':80:80', ':80')  # TODO: what is happening here?
示例#5
0
    def _parseActionList(self):
        xml = get_xml(self._deviceInfo.unrCersActionUrl)

        for action in xml.iterfind("action"):
            name = action.get('name').replace('::', '_')

            self.supportedFunctions.append(name)
            if self.actionUrls.has_key(name):
                raise Exception()
            self.actionUrls[name] = action.get('url').replace(
                ':80:80', ':80')  # TODO: what is happening here?
示例#6
0
文件: s2mtv.py 项目: fuzeman/PyIRCC
    def getDeviceInfo(self):
        """Get Device Information

        :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`
        """
        if self.trace:
            print ">>> getDeviceInfo"

        if self.version == '1.0' or self.force:
            url = urlparse.urljoin(self._deviceInfo.s2mtvBaseUrl, 'SSDgetDeviceInfo/')
            try:
                xml = get_xml(url)
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                if e.code == 501:
                    raise NotSupportedError()
                raise NotImplementedError()


            return S2MTV_DeviceInfo(xml)
示例#7
0
    def getDeviceInfo(self):
        """Get Device Information

        :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`
        """
        if self.trace:
            print ">>> getDeviceInfo"

        if self.version == '1.0' or self.force:
            url = urlparse.urljoin(self._deviceInfo.s2mtvBaseUrl,
                                   'SSDgetDeviceInfo/')
            try:
                xml = get_xml(url)
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                if e.code == 501:
                    raise NotSupportedError()
                raise NotImplementedError()

            return S2MTV_DeviceInfo(xml)