def GetDeviceDetails(self, sData, tSenderAddr): oRet = QueryDict() oRet.bFound = False oRet.sFoundIP = "" oRet.uFoundPort = "" oRet.uFoundModel = "" oRet.uFoundIdentifier = "" oRet.uFoundCategory = "" oRet.sData = "" if PY2: uResponse = sData[16:] else: uResponse = ToUnicode(sData)[16:] if uResponse.find('ECN') != -1: info = re.match(self.rMatch, uResponse.strip(), re.VERBOSE).groupdict() uResponse = uResponse[10:] oRet.sFoundIP = tSenderAddr[0] oRet.uFoundPort = ToUnicode(info['iscp_port']) oRet.uFoundModel = info['model_name'] oRet.uFoundIdentifier = info['identifier'] oRet.uFoundCategory = ToUnicode(info['device_category']) oRet.sData = uResponse oRet.bFound = True return oRet
def ListDiscover(self): oSetting = self.GetSettingObjectForConfigName( uConfigName=self.uConfigName) fTimeOut = oSetting.aScriptIniSettings.fTimeOut dArgs = {} dArgs["onlyonce"] = 0 self.Discover(**dArgs) try: for dResult in self.aResults: aDevice = QueryDict() aDevice.sFoundIP = dResult["ip"] aDevice.uFoundPort = str(dResult["port"]) aDevice.uFoundModel = dResult["model"] aDevice.uFoundHostName = dResult["hostname"] Logger.info(u'Bingo: Discovered device %s:%s' % (aDevice.uFoundModel, aDevice.sFoundIP)) uTageLine = aDevice.sFoundIP + aDevice.uFoundModel if self.aDevices.get(uTageLine) is None: self.aDevices[uTageLine] = aDevice self.AddLine([ aDevice.sFoundIP, aDevice.uFoundHostName, aDevice.uFoundPort, aDevice.uFoundModel ], aDevice) except Exception as e: LogErrorSmall(u'Error on Enigma discover', e)
def GetDeviceDetails(self,sData,tSenderAddr): oRet = QueryDict() oRet.sFoundIP = tSenderAddr[0] oRet.uFoundPort = tSenderAddr[1] oRet.bFound = True oRet.sData = sData oRet.uIPVersion = self.uIPVersion return oRet
def GetDeviceDetails(self, sData, tSenderAddr): oRet = QueryDict() oRet.sFoundIP = tSenderAddr[0] oRet.sData = sData oRet.uFoundName = sData[0:8].decode('utf-8') oRet.uFoundSerial = sData[8:18].decode('utf-8') oRet.uFoundHostName = socket.gethostbyaddr(oRet.sFoundIP)[0] oRet.uIPVersion = u"IPv4" Logger.info(u'Bingo: Dicovered device %s:%s:%s at %s' % (oRet.uFoundName, oRet.uFoundHostName, oRet.uFoundSerial, oRet.sFoundIP)) return oRet
def GetDeviceDetails(self, sData, tSenderAddr): oRet = QueryDict() oRet.uFoundManufacturer = u"" oRet.uFoundModel = u"" oRet.uFoundFriendlyName = u"" oRet.uFoundServiceType = u"" oRet.sFoundIP = tSenderAddr[0] oRet.uIPVersion = self.uIPVersion[:4] oRet.bFound = False oRet.sData = sData oRet.uResult = u"" oRet.uFoundHostName = u"" uUrl = u"" if not PY2: oRet.sData = ToUnicode(oRet.sData) if oRet.uIPVersion == "IPv6": oRet.sFoundIP = "[%s}" % oRet.sFoundIP # if we got a response if '200 OK' in oRet.sData: aData = oRet.sData.splitlines() uFoundServiceType = "" # The location field as part of DIAL specification and contains a link to an XML with further device infos for uLine in aData: if uLine.upper().startswith('LOCATION:'): uUrl = uLine[9:].strip() if uLine.startswith('ST'): oRet.uFoundServiceType = uLine[3:].strip() uFoundServiceType = uFoundServiceType Logger.debug(u'Trying to get device details from %s' % uUrl) try: self.oUrlRequest = UrlRequest(uUrl, method="GET", req_body='', req_headers={ "Connection": "Keep-Alive", "Accept-Encoding": "gzip" }, timeout=self.fTimeOut, on_error=self.OnError) self.NewWait(0.05) iStatusCode = self.oUrlRequest.resp_status if iStatusCode == 200 and "device" in self.oUrlRequest.result: oRet.uResult = RemoveURN(self.oUrlRequest.result) oNode = ElementTree(fromstring(oRet.uResult)) oNode = oNode.find("device") oRet.uFoundManufacturer = oNode.find("manufacturer").text oRet.uFoundModel = oNode.find("modelName").text try: oRet.uFoundFriendlyName = oNode.find( "friendlyName").text except Exception as e: pass oRet.bFound = True Logger.debug(u'Found Device %s:%s:%s (%s)' % (oRet.uFoundManufacturer, oRet.uFoundModel, oRet.uFoundFriendlyName, oRet.sFoundIP)) except Exception as e: LogError("Can''t get device details. skipping device: " + uUrl, e) return oRet