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)
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
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
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
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
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
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
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
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