def __querynodestatus(self, nbname, destaddr, type, scope, timeout):
    self._setup_connection(destaddr)
    trn_id = randint(1, 32000)
    p = NetBIOSPacket()
    p.set_trn_id(trn_id)
    netbios_name = string.upper(nbname)
    qn_label = encode_name(netbios_name, type, scope)
    p.addQuestion(qn_label, QUESTION_TYPE_NBSTAT, QUESTION_CLASS_IN)
    if (not destaddr):
        p.set_nm_flags(NM_FLAGS_BROADCAST)
        destaddr = self.__broadcastaddr
    req = p.rawData()
    tries = 3
    while 1:
        try:
            self.__sock.sendto(req, 0, (destaddr, self.__servport))
            (ready, _, _) = select.select([self.__sock.fileno()], [], [], timeout)
            if (not ready):
                if tries:
                    tries -= 1
                else:
                    raise NetBIOSTimeout
            else:
                try:
                    (data, _) = self.__sock.recvfrom(65536, 0)
                except Exception as e:
                    raise NetBIOSError(('recvfrom error: %s' % str(e)))
                self.__sock.close()
                res = NetBIOSPacket(data)
                if (res.get_trn_id() == p.get_trn_id()):
                    if res.get_rcode():
                        if (res.get_rcode() == 3):
                            raise NetBIOSError('Cannot get data from server')
                        else:
                            raise NetBIOSError('Negative name query response', ERRCLASS_QUERY, res.get_rcode())
                    answ = NBNodeStatusResponse(res.get_answers())
                    self.mac = answ.get_mac()
                    return answ.get_node_names()
        except select.error as ex:
            if ((ex[0] != errno.EINTR) and (ex[0] != errno.EAGAIN)):
                raise NetBIOSError('Error occurs while waiting for response', ERRCLASS_OS, ex[0])
        except socket.error as ex:
            raise NetBIOSError(('Connection error: %s' % str(ex)))
def __querynodestatus(self, nbname, destaddr, type, scope, timeout):
    self._setup_connection(destaddr)
    trn_id = randint(1, 32000)
    p = NetBIOSPacket()
    p.set_trn_id(trn_id)
    netbios_name = string.upper(nbname)
    qn_label = encode_name(netbios_name, type, scope)
    p.addQuestion(qn_label, QUESTION_TYPE_NBSTAT, QUESTION_CLASS_IN)
    if (not destaddr):
        p.set_nm_flags(NM_FLAGS_BROADCAST)
        destaddr = self.__broadcastaddr
    req = p.rawData()
    tries = 3
    while 1:
        try:
            self.__sock.sendto(req, 0, (destaddr, self.__servport))
            (ready, _, _) = select.select([self.__sock.fileno()], [], [], timeout)
            if (not ready):
                if tries:
                    tries -= 1
                else:
                    raise NetBIOSTimeout
            else:
                try:
                    (data, _) = self.__sock.recvfrom(65536, 0)
                except Exception as e:
                    raise NetBIOSError(('recvfrom error: %s' % str(e)))
                self.__sock.close()
                res = NetBIOSPacket(data)
                if (res.get_trn_id() == p.get_trn_id()):
                    if res.get_rcode():
                        if (res.get_rcode() == 3):
                            raise NetBIOSError('Cannot get data from server')
                        else:
                            raise NetBIOSError('Negative name query response', ERRCLASS_QUERY, res.get_rcode())
                    answ = NBNodeStatusResponse(res.get_answers())
                    self.mac = answ.get_mac()
                    return answ.get_node_names()
        except select.error as ex:
            if ((ex[0] != errno.EINTR) and (ex[0] != errno.EAGAIN)):
                raise NetBIOSError('Error occurs while waiting for response', ERRCLASS_OS, ex[0])
        except socket.error as ex:
            raise NetBIOSError(('Connection error: %s' % str(ex)))