%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/
Upload File :
Create Path :
Current File : //opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pyc

�
�ac@s�ddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZdefd��YZ
dS(i����N(tNBNStNotConnectedError(tTYPE_CLIENTtTYPE_SERVERtTYPE_WORKSTATIONtNetBIOScBskeZejd�Zedd�Zd�Zd�Zdddd�Z	ddd	�Z
d
�Zd�ZRS(sNMB.NetBIOSicCso||_tjtjtj�|_|jrL|jjtjtjd�n|rk|jjd|f�ndS(s|
        Instantiate a NetBIOS instance, and creates a IPv4 UDP socket to listen/send NBNS packets.

        :param boolean broadcast: A boolean flag to indicate if we should setup the listening UDP port in broadcast mode
        :param integer listen_port: Specifies the UDP port number to bind to for listening. If zero, OS will automatically select a free port number.
        itN(	t	broadcasttsockettAF_INETt
SOCK_DGRAMtsockt
setsockoptt
SOL_SOCKETtSO_BROADCASTtbind(tselfRtlisten_port((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pyt__init__
s		cCs|jj�d|_dS(s�
        Close the underlying and free resources.

        The NetBIOS instance should not be used to perform any operations after this method returns.

        :return: None
        N(RtclosetNone(R((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pyRs
cCs2|jstd��|jj|||f�dS(NsSocket is already closed(RtAssertionErrortsendto(Rtdatatiptport((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pytwrite#sRi�icCs�|jstd��tjdd�}|j||�}|jrR|rRd}n|sk|jjd�n|j|||�|j	||�S(sc
        Send a query on the network and hopes that if machine matching the *name* will reply with its IP address.

        :param string ip: If the NBNSProtocol instance was instianted with broadcast=True, then this parameter can be an empty string. We will leave it to the OS to determine an appropriate broadcast address.
                          If the NBNSProtocol instance was instianted with broadcast=False, then you should provide a target IP to send the query.
        :param integer port: The NetBIOS-NS port (IANA standard defines this port to be 137). You should not touch this parameter unless you know what you are doing.
        :param integer/float timeout: Number of seconds to wait for a reply, after which the method will return None
        :return: A list of IP addresses in dotted notation (aaa.bbb.ccc.ddd). On timeout, returns None.
        sSocket is already closedii��s<broadcast>sQqueryName: ip parameter is empty. OS might not transmit this query to the network(
RRtrandomtrandinttprepareNameQueryRtlogtwarningRt_pollForNetBIOSPacket(RtnameRRttimeoutttrn_idR((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pyt	queryName's
	cCs�|jstd��tjdd�}|j|t�}|j|||�|j||�}|r�td�t	d�|��SdSdS(s�
        Send a query to the machine with *ip* and hopes that the machine will reply back with its name.

        The implementation of this function is contributed by Jason Anderson.

        :param string ip: If the NBNSProtocol instance was instianted with broadcast=True, then this parameter can be an empty string. We will leave it to the OS to determine an appropriate broadcast address.
                          If the NBNSProtocol instance was instianted with broadcast=False, then you should provide a target IP to send the query.
        :param integer port: The NetBIOS-NS port (IANA standard defines this port to be 137). You should not touch this parameter unless you know what you are doing.
        :param integer/float timeout: Number of seconds to wait for a reply, after which the method will return None
        :return: A list of string containing the names of the machine at *ip*. On timeout, returns None.
        sSocket is already closedii��cSs|dS(Ni((ts((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pyt<lambda>QRcSs|dtkS(Ni(R(R%((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pyR&QRN(RRRRtprepareNetNameQuerytFalseRt_pollForQueryPackettmaptfilterR(RRRR"R#Rtret((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pytqueryIPForName>scCs:tj�|}x#tr5y�|tj�}|dkr<dStj|jj�ggg|�\}}}|ssdS|jjd�\}}t|�dkr�t�n|j	|�\}}	||kr�|	SWqtj
k
r1}
t|
�tj
kr(|
dtjkr.|
dtjkr.|
�q.q2|
�qXqWdS(Nii��(ttimetTrueRtselectRtfilenotrecvfromtlenRtdecodePacketterrorttypettypest	TupleTypeterrnotEINTRtEAGAIN(Rtwait_trn_idR"tend_timet_timeouttreadyt_RR#R,tex((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pyR Ys(	-	&cCs:tj�|}x#tr5y�|tj�}|dkr<dStj|jj�ggg|�\}}}|ssdS|jjd�\}}t|�dkr�t�n|j	|�\}}	||kr�|	SWqtj
k
r1}
t|
�tj
kr(|
dtjkr.|
dtjkr.|
�q.q2|
�qXqWdS(Nii��(R.R/RR0RR1R2R3RtdecodeIPQueryPacketR5R6R7R8R9R:R;(RR<R"R=R>R?R@RR#R,RA((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pyR)ws(	-	&(
t__name__t
__module__tloggingt	getLoggerRR/RRRR$R-R R)(((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pyRs			(tosRERRR.R0tbaseRRt
nmb_constantsRRRR(((s@/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOS.pyt<module>sH

Zerion Mini Shell 1.0