예제 #1
0
    def getContentInformation(self):
        """Get view content information

       :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`

       :returns: :class:`pyircc.unr.UNR_ContentInformation`
       """
        if self.trace:
            print ">>> getContentInformation"
        if self.version == '1.2' or self.force:
            result = None
            try:
                result = http_get(self.actionUrls['getContentInformation'],
                                  self._getActionHeaders())
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                if e.code == 503:
                    return None
                raise NotImplementedError()

            if not result:
                raise NotImplementedError()

            xml = et.fromstring(result)

            return UNR_ContentInformation(xml)
예제 #2
0
    def getRemoteCommandList(self):
        """Get device remote commands

        :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`
        """
        if self.trace:
            print ">>> getRemoteCommandList"
        if self.version == '1.2' or self.force:
            result = None
            try:
                result = http_get(self.actionUrls['getRemoteCommandList'],
                                  self._getActionHeaders())
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                raise NotImplementedError()

            if not result:
                raise NotImplementedError()

            xml = et.fromstring(result)

            self.remoteCommands = {}
            for commandElement in xml.iterfind("command"):
                command = UNR_RemoteCommand(commandElement)
                self.remoteCommands[command.name] = command

            return self.remoteCommands
예제 #3
0
    def getStatus(self):
        """Get current view status

       :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`

       :returns: :class:`pyircc.unr.UNR_Status`
       """
        if self.trace:
            print ">>> getStatus"
        if self.version == '1.2' or self.force:
            result = None
            try:
                result = http_get(self.actionUrls['getStatus'],
                                  self._getActionHeaders())
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                raise NotImplementedError()

            if not result:
                raise NotImplementedError()

            xml = et.fromstring(result)

            statusList = {}
            for s in xml.iterfind('status'):
                status = UNR_Status(s)
                statusList[status.name] = status
            return statusList
예제 #4
0
    def getText(self):
        """Get text from displayed text input screen, Returns None if there is no text input screen displayed

        :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`

        :returns: string or Null
        """
        if self.trace:
            print ">>> getText"
        if self.version == '1.2' or self.force:
            result = None
            try:
                result = http_get(self.actionUrls['getText'],
                                  self._getActionHeaders())
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                if e.code == 406:
                    return None
                raise NotImplementedError()

            if not result:
                raise NotImplementedError()

            xml = et.fromstring(result)

            return xml.text
예제 #5
0
파일: unr.py 프로젝트: fuzeman/PyIRCC
    def getContentInformation(self):
        """Get view content information

       :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`

       :returns: :class:`pyircc.unr.UNR_ContentInformation`
       """
        if self.trace:
            print ">>> getContentInformation"
        if self.version == '1.2' or self.force:
            result = None
            try:
                result = http_get(self.actionUrls['getContentInformation'], self._getActionHeaders())
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                if e.code == 503:
                    return None
                raise NotImplementedError()

            if not result:
                raise NotImplementedError()

            xml = et.fromstring(result)

            return UNR_ContentInformation(xml)
예제 #6
0
파일: unr.py 프로젝트: fuzeman/PyIRCC
    def getStatus(self):
        """Get current view status

       :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`

       :returns: :class:`pyircc.unr.UNR_Status`
       """
        if self.trace:
            print ">>> getStatus"
        if self.version == '1.2' or self.force:
            result = None
            try:
                result = http_get(self.actionUrls['getStatus'], self._getActionHeaders())
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                raise NotImplementedError()

            if not result:
                raise NotImplementedError()

            xml = et.fromstring(result)

            statusList = {}
            for s in xml.iterfind('status'):
                status = UNR_Status(s)
                statusList[status.name] = status
            return statusList
예제 #7
0
파일: unr.py 프로젝트: fuzeman/PyIRCC
    def getText(self):
        """Get text from displayed text input screen, Returns None if there is no text input screen displayed

        :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`

        :returns: string or Null
        """
        if self.trace:
            print ">>> getText"
        if self.version == '1.2' or self.force:
            result = None
            try:
                result = http_get(self.actionUrls['getText'], self._getActionHeaders())
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                if e.code == 406:
                    return None
                raise NotImplementedError()

            if not result:
                raise NotImplementedError()

            xml = et.fromstring(result)

            return xml.text
예제 #8
0
파일: unr.py 프로젝트: fuzeman/PyIRCC
    def getRemoteCommandList(self):
        """Get device remote commands

        :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`
        """
        if self.trace:
            print ">>> getRemoteCommandList"
        if self.version == '1.2' or self.force:
            result = None
            try:
                result = http_get(self.actionUrls['getRemoteCommandList'],
                                  self._getActionHeaders())
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                raise NotImplementedError()

            if not result:
                raise NotImplementedError()

            xml = et.fromstring(result)

            self.remoteCommands = {}
            for commandElement in xml.iterfind("command"):
                command = UNR_RemoteCommand(commandElement)
                self.remoteCommands[command.name] = command

            return self.remoteCommands
예제 #9
0
파일: unr.py 프로젝트: fuzeman/PyIRCC
    def sendText(self, text):
        """Send text to replace current text in displayed text input screen

       :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`

       :returns: boolean
       """
        if self.trace:
            print ">>> sendText"
        if self.version == '1.2' or self.force:
            try:
                http_get(self.actionUrls['sendText'], self._getActionHeaders(),
                                  text=text)
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                if e.code == 406:
                    return False
                raise NotImplementedError()

            return True
예제 #10
0
    def register(self,
                 name="PyIRCC",
                 registrationType='initial',
                 deviceId="PyIRCC:00-00-00-00-00-00"):
        """Register with Device

        :param name: Control Name
        :type name: string

        :param registrationType: Control Registration Type
        :type registrationType: 'initial'

        :param deviceId: Control Device ID
        :type deviceId: string

        :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`
        """
        if self.trace:
            print ">>> register", name, registrationType, deviceId

        self.deviceName = name
        self.deviceId = deviceId

        if self.version == '1.2' or self.force:
            try:
                http_get(self.actionUrls['register'],
                         self._getActionHeaders(),
                         name=name,
                         registrationType=registrationType,
                         deviceId=deviceId)
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                if e.code == 403:
                    return UNR_REGISTER_RESULT_DECLINED
                raise NotImplementedError()

            self.registered = True
            return UNR_REGISTER_RESULT_OK
예제 #11
0
    def sendText(self, text):
        """Send text to replace current text in displayed text input screen

       :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`

       :returns: boolean
       """
        if self.trace:
            print ">>> sendText"
        if self.version == '1.2' or self.force:
            try:
                http_get(self.actionUrls['sendText'],
                         self._getActionHeaders(),
                         text=text)
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                if e.code == 406:
                    return False
                raise NotImplementedError()

            return True
예제 #12
0
파일: unr.py 프로젝트: fuzeman/PyIRCC
    def register(self, name="PyIRCC", registrationType='initial', deviceId="PyIRCC:00-00-00-00-00-00"):
        """Register with Device

        :param name: Control Name
        :type name: string

        :param registrationType: Control Registration Type
        :type registrationType: 'initial'

        :param deviceId: Control Device ID
        :type deviceId: string

        :raises: :class:`pyircc.spec.NotSupportedError`, :class:`NotImplementedError`
        """
        if self.trace:
            print ">>> register", name, registrationType, deviceId

        self.deviceName = name
        self.deviceId = deviceId

        if self.version == '1.2' or self.force:
            try:
                http_get(
                    self.actionUrls['register'],
                    self._getActionHeaders(),
                    name=name,
                    registrationType=registrationType,
                    deviceId=deviceId
                )
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                if e.code == 403:
                    return UNR_REGISTER_RESULT_DECLINED
                raise NotImplementedError()

            self.registered = True
            return UNR_REGISTER_RESULT_OK
예제 #13
0
    def sendIRCC(self, codeName):
        """Send Remote Command

        :param codeName: Command Name
        :type codeName: string

        :raises: :class:`pyircc.spec.InvalidArgumentError`, NotImplementedError
        """
        if self.trace:
            print ">>> sendIRCC", codeName

        if codeName is None:
            raise InvalidArgumentError()

        if self.version == '1.0' or self.force:
            self._load()

            if not self._device.unr.remoteCommands.has_key(codeName):
                raise InvalidArgumentError()

            command = self._device.unr.remoteCommands[codeName]

            if command.type == UNR_RemoteCommand.TYPE_IRCC:
                try:
                    self._client.call('X_SendIRCC', IRCCCode=command.value)
                    return
                except SoapFault, e:
                    if e.faultcode == 's:Client' and e.faultstring == 'UPnPError':
                        raise InvalidArgumentError()

                    if self.trace:
                        print e.faultcode, e.faultstring
                    raise NotImplementedError()
            else:
                http_get(command.value, self._device.unr._getActionHeaders())
                return
예제 #14
0
파일: ircc.py 프로젝트: fuzeman/PyIRCC
    def sendIRCC(self, codeName):
        """Send Remote Command

        :param codeName: Command Name
        :type codeName: string

        :raises: :class:`pyircc.spec.InvalidArgumentError`, NotImplementedError
        """
        if self.trace:
            print ">>> sendIRCC", codeName

        if codeName is None:
            raise InvalidArgumentError()

        if self.version == '1.0' or self.force:
            self._load()

            if not self._device.unr.remoteCommands.has_key(codeName):
                raise InvalidArgumentError()

            command = self._device.unr.remoteCommands[codeName]

            if command.type == UNR_RemoteCommand.TYPE_IRCC:
                try:
                    self._client.call('X_SendIRCC', IRCCCode=command.value)
                    return
                except SoapFault, e:
                    if e.faultcode == 's:Client' and e.faultstring == 'UPnPError':
                        raise InvalidArgumentError()

                    if self.trace:
                        print e.faultcode, e.faultstring
                    raise NotImplementedError()
            else:
                http_get(command.value, self._device.unr._getActionHeaders())
                return
예제 #15
0
파일: unr.py 프로젝트: fuzeman/PyIRCC
    def getSystemInformation(self):
        """Get device system information

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

        if self.version == '1.2' or self.force:
            result = None
            try:
                result = http_get(self.actionUrls['getSystemInformation'], {})  # No headers to send yet.
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                raise NotImplementedError()

            xml = et.fromstring(result)
            if xml is None:
                return None

            self.systemInformation = UNR_SystemInformationResult(xml)
            return self.systemInformation
예제 #16
0
    def getSystemInformation(self):
        """Get device system information

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

        if self.version == '1.2' or self.force:
            result = None
            try:
                result = http_get(self.actionUrls['getSystemInformation'],
                                  {})  # No headers to send yet.
            except urllib2.HTTPError, e:
                if self.trace:
                    print e
                raise NotImplementedError()

            xml = et.fromstring(result)
            if xml is None:
                return None

            self.systemInformation = UNR_SystemInformationResult(xml)
            return self.systemInformation