def __init__(self, myname, remote_name, remote_host, remote_type=TYPE_SERVER, sess_port=NETBIOS_SESSION_PORT, timeout=None, local_type=TYPE_WORKSTATION, sock=None):
    if (len(myname) > 15):
        self.__myname = string.upper(myname[:15])
    else:
        self.__myname = string.upper(myname)
    self.__local_type = local_type
    assert remote_name
    if ((remote_name == '*SMBSERVER') and (sess_port == SMB_SESSION_PORT)):
        remote_name = remote_host
    if (remote_name == '*SMBSERVER'):
        nb = NetBIOS()
        try:
            res = nb.getnetbiosname(remote_host)
        except:
            res = None
            pass
        if (res is not None):
            remote_name = res
    if (len(remote_name) > 15):
        self.__remote_name = string.upper(remote_name[:15])
    else:
        self.__remote_name = string.upper(remote_name)
    self.__remote_type = remote_type
    self.__remote_host = remote_host
    if (sock is not None):
        self._sock = sock
    else:
        self._sock = self._setup_connection((remote_host, sess_port))
    if (sess_port == NETBIOS_SESSION_PORT):
        self._request_session(remote_type, local_type, timeout)
def __init__(self, myname, remote_name, remote_host, remote_type=TYPE_SERVER, sess_port=NETBIOS_SESSION_PORT, timeout=None, local_type=TYPE_WORKSTATION, sock=None):
    if (len(myname) > 15):
        self.__myname = string.upper(myname[:15])
    else:
        self.__myname = string.upper(myname)
    self.__local_type = local_type
    assert remote_name
    if ((remote_name == '*SMBSERVER') and (sess_port == SMB_SESSION_PORT)):
        remote_name = remote_host
    if (remote_name == '*SMBSERVER'):
        nb = NetBIOS()
        try:
            res = nb.getnetbiosname(remote_host)
        except:
            res = None
            pass
        if (res is not None):
            remote_name = res
    if (len(remote_name) > 15):
        self.__remote_name = string.upper(remote_name[:15])
    else:
        self.__remote_name = string.upper(remote_name)
    self.__remote_type = remote_type
    self.__remote_host = remote_host
    if (sock is not None):
        self._sock = sock
    else:
        self._sock = self._setup_connection((remote_host, sess_port))
    if (sess_port == NETBIOS_SESSION_PORT):
        self._request_session(remote_type, local_type, timeout)