%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/
Upload File :
Create Path :
Current File : //proc/self/root/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyc

�
�ac@s�ddlZddlZddlZddlmZmZddlmZmZddl	Tddl
TddlmZm
Z
mZmZdddgZd	eefd
��YZdefd��YZdS(i����N(treactortdefer(t
ClientFactorytProtocol(t*(tSMBtNotConnectedErrort
NotReadyErrort
SMBTimeouttSMBProtocolFactoryRRtSMBProtocolcBs_eZejd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�ZRS(	sSMB.SMBProtocolcCs0||j_|js"|j�n
|j�dS(N(tfactorytinstancet
is_direct_tcptrequestNMBSessiontonNMBSessionOK(tself((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytconnectionMades	
cCs"|jj|krd|_ndS(N(RRtNone(Rtreason((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytconnectionLostscCs|j|�dS(N(tfeedData(Rtdata((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytdataReceived scCs|jj|�dS(N(t	transporttwrite(RR((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyR'scCs9|jj|kr5|jj�tjd|j�ndS(Ni(RRtonAuthOKRt	callLatert_cleanupPendingRequests(R((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyR*s
cCs&|jj|kr"|jj�ndS(N(RRtonAuthFailed(R((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyR/scCs|jjd�dS(NsMCannot establish NetBIOS session. You might have provided a wrong remote_name(tlogterror(R((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytonNMBSessionFailed3scCs�|jj|kr�tj�}g}xd|jj�D]S\}}|j|kr4y|jt��Wntk
rvnX|j	|�q4q4Wx|D]}|j|=q�Wt
jd|j�ndS(Ni(
RRttimetpending_requestst	iteritemstexpiry_timeterrbackRt	ExceptiontappendRRR(Rtnowt	to_removetmidtr((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyR:s

(
t__name__t
__module__tloggingt	getLoggerRRRRRRRR R(((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyR

s							cBs-eZeZejd�ZdZdZdZ	de
e	ed�Ze
d��Ze
d��Zd�Zd	�Zd
d�ZeeBeBeBeBeBdd
d
�Zd
d�Zd
d�Zd
d�Zddd
d�Zd
d�Zd
d�Zd�Z d�Z!d�Z"dd�Z#d�Z$d�Z%RS(sSMB.SMBFactoryiiitc		CsU||_||_||_||_||_||_||_||_d|_	dS(s�
        Create a new SMBProtocolFactory instance. You will pass this instance to *reactor.connectTCP()* which will then instantiate the TCP connection to the remote SMB/CIFS server.
        Note that the default TCP port for most SMB/CIFS servers using NetBIOS over TCP/IP is 139.
        Some newer server installations might also support Direct hosting of SMB over TCP/IP; for these servers, the default TCP port is 445.

        *username* and *password* are the user credentials required to authenticate the underlying SMB connection with the remote server.
        File operations can only be proceeded after the connection has been authenticated successfully.

        :param string my_name: The local NetBIOS machine name that will identify where this connection is originating from.
                               You can freely choose a name as long as it contains a maximum of 15 alphanumeric characters and does not contain spaces and any of ``\/:*?";|+``.
        :param string remote_name: The NetBIOS machine name of the remote server.
                                   On windows, you can find out the machine name by right-clicking on the "My Computer" and selecting "Properties".
                                   This parameter must be the same as what has been configured on the remote server, or else the connection will be rejected.
        :param string domain: The network domain. On windows, it is known as the workgroup. Usually, it is safe to leave this parameter as an empty string.
        :param boolean use_ntlm_v2: Indicates whether pysmb should be NTLMv1 or NTLMv2 authentication algorithm for authentication.
                                    The choice of NTLMv1 and NTLMv2 is configured on the remote server, and there is no mechanism to auto-detect which algorithm has been configured.
                                    Hence, we can only "guess" or try both algorithms.
                                    On Sambda, Windows Vista and Windows 7, NTLMv2 is enabled by default. On Windows XP, we can use NTLMv1 before NTLMv2.
        :param int sign_options: Determines whether SMB messages will be signed. Default is *SIGN_WHEN_REQUIRED*.
                                 If *SIGN_WHEN_REQUIRED* (value=2), SMB messages will only be signed when remote server requires signing.
                                 If *SIGN_WHEN_SUPPORTED* (value=1), SMB messages will be signed when remote server supports signing but not requires signing.
                                 If *SIGN_NEVER* (value=0), SMB messages will never be signed regardless of remote server's configurations; access errors will occur if the remote server requires signing.
        :param boolean is_direct_tcp: Controls whether the NetBIOS over TCP/IP (is_direct_tcp=False) or the newer Direct hosting of SMB over TCP/IP (is_direct_tcp=True) will be used for the communication.
                                      The default parameter is False which will use NetBIOS over TCP/IP for wider compatibility (TCP port: 139).
        N(
tusernametpasswordtmy_nametremote_nametdomaintuse_ntlm_v2tsign_optionsR
RR(	RR1R2R3R4R5R6R7R
((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyt__init__Ws								cCst|jo|jj�S(s�A convenient property to return True if the underlying SMB connection has connected to remote server, has successfully authenticated itself and is ready for file operations.(tboolRthas_authenticated(R((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytisReadyscCs|jo|jjS(s]A convenient property to return True if the underlying SMB connection is using SMB2 protocol.(Rt
is_using_smb2(R((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytisUsingSMB2�scCsdS(s6
        Override this method in your *SMBProtocolFactory* subclass to add in post-authentication handling.
        This method will be called when the server has replied that the SMB connection has been successfully authenticated.
        File operations can proceed when this method has been called.
        N((R((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyR�scCsdS(sz
        Override this method in your *SMBProtocolFactory* subclass to add in post-authentication handling.
        This method will be called when the server has replied that the SMB connection has been successfully authenticated.

        If you want to retry authenticating from this method,
         1. Disconnect the underlying SMB connection (call ``self.instance.transport.loseConnection()``)
         2. Create a new SMBProtocolFactory subclass instance with different user credientials or different NTLM algorithm flag.
         3. Call ``reactor.connectTCP`` with the new instance to re-establish the SMB connection
        N((R((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyR�s
icCsD|jstd��ntj�}|jj|j|j|�|S(s�
        Retrieve a list of shared resources on remote server.

        :param integer/float timeout: Number of seconds that pysmb will wait before raising *SMBTimeout* via the returned *Deferred* instance's *errback* method.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a list of :doc:`smb.base.SharedDevice<smb_SharedDevice>` instances.
        sNot connected to server(RRRtDeferredt_listSharestcallbackR%(Rttimeouttd((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyt
listShares�s
	RcCsY|jstd��ntj�}|jj|||j|jd|d|d|�|S(s�
        Retrieve a directory listing of files/folders at *path*

        For simplicity, pysmb defines a "normal" file as a file entry that is not read-only, not hidden, not system, not archive and not a directory.
        It ignores other attributes like compression, indexed, sparse, temporary and encryption.

        Note that the default search parameter will query for all read-only (SMB_FILE_ATTRIBUTE_READONLY), hidden (SMB_FILE_ATTRIBUTE_HIDDEN),
        system (SMB_FILE_ATTRIBUTE_SYSTEM), archive (SMB_FILE_ATTRIBUTE_ARCHIVE), normal (SMB_FILE_ATTRIBUTE_INCL_NORMAL) files
        and directories (SMB_FILE_ATTRIBUTE_DIRECTORY).
        If you do not need to include "normal" files in the result, define your own search parameter without the SMB_FILE_ATTRIBUTE_INCL_NORMAL constant.
        SMB_FILE_ATTRIBUTE_NORMAL should be used by itself and not be used with other bit constants.

        :param string/unicode service_name: the name of the shared folder for the *path*
        :param string/unicode path: path relative to the *service_name* where we are interested to learn about its files/sub-folders.
        :param integer search: integer value made up from a bitwise-OR of *SMB_FILE_ATTRIBUTE_xxx* bits (see smb_constants.py).
        :param string/unicode pattern: the filter to apply to the results before returning to the client.
        :param integer/float timeout: Number of seconds that pysmb will wait before raising *SMBTimeout* via the returned *Deferred* instance's *errback* method.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a list of :doc:`smb.base.SharedFile<smb_SharedFile>` instances.
        sNot connected to servertsearchtpatternRA(RRRR>t	_listPathR@R%(Rtservice_nametpathRDRERARB((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytlistPath�s
	1cCsM|jstd��ntj�}|jj|||j|jd|�|S(s�
        Retrieve a list of available snapshots (a.k.a. shadow copies) for *path*.

        Note that snapshot features are only supported on Windows Vista Business, Enterprise and Ultimate, and on all Windows 7 editions.

        :param string/unicode service_name: the name of the shared folder for the *path*
        :param string/unicode path: path relative to the *service_name* where we are interested in the list of available snapshots
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a list of python *datetime.DateTime*
                 instances in GMT/UTC time zone
        sNot connected to serverRA(RRRR>t_listSnapshotsR@R%(RRGRHRARB((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyt
listSnapshots�s
	%cCsM|jstd��ntj�}|jj|||j|jd|�|S(s&
        Retrieve information about the file at *path* on the *service_name*.

        :param string/unicode service_name: the name of the shared folder for the *path*
        :param string/unicode path: Path of the file on the remote server. If the file cannot be opened for reading, an :doc:`OperationFailure<smb_exceptions>` will be raised.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a :doc:`smb.base.SharedFile<smb_SharedFile>` instance containing the attributes of the file.
        sNot connected to serverRA(RRRR>t_getAttributesR@R%(RRGRHRARB((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyt
getAttributes�s
	%cCs|j|||dd|�S(sf
        Retrieve the contents of the file at *path* on the *service_name* and write these contents to the provided *file_obj*.

        Use *retrieveFileFromOffset()* method if you need to specify the offset to read from the remote *path* and/or the maximum number of bytes to write to the *file_obj*.

        The meaning of the *timeout* parameter will be different from other file operation methods. As the downloaded file usually exceeeds the maximum size
        of each SMB/CIFS data message, it will be packetized into a series of request messages (each message will request about about 60kBytes).
        The *timeout* parameter is an integer/float value that specifies the timeout interval for these individual SMB/CIFS message to be transmitted and downloaded from the remote SMB/CIFS server.

        :param string/unicode service_name: the name of the shared folder for the *path*
        :param string/unicode path: Path of the file on the remote server. If the file cannot be opened for reading, an :doc:`OperationFailure<smb_exceptions>` will be called in the returned *Deferred* errback.
        :param file_obj: A file-like object that has a *write* method. Data will be written continuously to *file_obj* until EOF is received from the remote service.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a 3-element tuple of ( *file_obj*, file attributes of the file on server, number of bytes written to *file_obj* ).
                 The file attributes is an integer value made up from a bitwise-OR of *SMB_FILE_ATTRIBUTE_xxx* bits (see smb_constants.py)
        ll����(tretrieveFileFromOffset(RRGRHtfile_objRA((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytretrieveFile�sll����c
CsV|jstd��ntj�}|jj||||j|j||d|�|S(s�
        Retrieve the contents of the file at *path* on the *service_name* and write these contents to the provided *file_obj*.

        The meaning of the *timeout* parameter will be different from other file operation methods. As the downloaded file usually exceeeds the maximum size
        of each SMB/CIFS data message, it will be packetized into a series of request messages (each message will request about about 60kBytes).
        The *timeout* parameter is an integer/float value that specifies the timeout interval for these individual SMB/CIFS message to be transmitted and downloaded from the remote SMB/CIFS server.

        :param string/unicode service_name: the name of the shared folder for the *path*
        :param string/unicode path: Path of the file on the remote server. If the file cannot be opened for reading, an :doc:`OperationFailure<smb_exceptions>` will be called in the returned *Deferred* errback.
        :param file_obj: A file-like object that has a *write* method. Data will be written continuously to *file_obj* until EOF is received from the remote service.
        :param integer/long offset: the offset in the remote *path* where the first byte will be read and written to *file_obj*. Must be either zero or a positive integer/long value.
        :param integer/long max_length: maximum number of bytes to read from the remote *path* and write to the *file_obj*. Specify a negative value to read from *offset* to the EOF.
                                        If zero, the *Deferred* callback is invoked immediately after the file is opened successfully for reading.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a 3-element tuple of ( *file_obj*, file attributes of the file on server, number of bytes written to *file_obj* ).
                 The file attributes is an integer value made up from a bitwise-OR of *SMB_FILE_ATTRIBUTE_xxx* bits (see smb_constants.py)
        sNot connected to serverRA(RRRR>t_retrieveFileFromOffsetR@R%(RRGRHROtoffsett
max_lengthRARB((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyRNs
	.cCsP|jstd��ntj�}|jj||||j|jd|�|S(s&
        Store the contents of the *file_obj* at *path* on the *service_name*.

        The meaning of the *timeout* parameter will be different from other file operation methods. As the uploaded file usually exceeeds the maximum size
        of each SMB/CIFS data message, it will be packetized into a series of messages (usually about 60kBytes).
        The *timeout* parameter is an integer/float value that specifies the timeout interval for these individual SMB/CIFS message to be transmitted and acknowledged
        by the remote SMB/CIFS server.

        :param string/unicode service_name: the name of the shared folder for the *path*
        :param string/unicode path: Path of the file on the remote server. If the file at *path* does not exist, it will be created. Otherwise, it will be overwritten.
                                    If the *path* refers to a folder or the file cannot be opened for writing, an :doc:`OperationFailure<smb_exceptions>` will be called in the returned *Deferred* errback.
        :param file_obj: A file-like object that has a *read* method. Data will read continuously from *file_obj* until EOF.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a 2-element tuple of ( *file_obj*, number of bytes uploaded ).
        sNot connected to serverRA(RRRR>t
_storeFileR@R%(RRGRHRORARB((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyt	storeFiles
	(cCsM|jstd��ntj�}|jj|||j|jd|�|S(s�
        Delete one or more regular files. It supports the use of wildcards in file names, allowing for deletion of multiple files in a single request.

        :param string/unicode service_name: Contains the name of the shared folder.
        :param string/unicode path_file_pattern: The pathname of the file(s) to be deleted, relative to the service_name.
                                                 Wildcards may be used in th filename component of the path.
                                                 If your path/filename contains non-English characters, you must pass in an unicode string.
        :param integer/float timeout: Number of seconds that pysmb will wait before raising *SMBTimeout* via the returned *Deferred* instance's *errback* method.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with the *path_file_pattern* parameter.
        sNot connected to serverRA(RRRR>t_deleteFilesR@R%(RRGtpath_file_patternRARB((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytdeleteFiles1s
	%cCsG|jstd��ntj�}|jj|||j|j�|S(s�
        Creates a new directory *path* on the *service_name*.

        :param string/unicode service_name: Contains the name of the shared folder.
        :param string/unicode path: The path of the new folder (relative to) the shared folder.
                                    If the path contains non-English characters, an unicode string must be used to pass in the path.
        :param integer/float timeout: Number of seconds that pysmb will wait before raising *SMBTimeout* via the returned *Deferred* instance's *errback* method.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with the *path* parameter.
        sNot connected to server(RRRR>t_createDirectoryR@R%(RRGRHRB((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytcreateDirectoryCs

	cCsG|jstd��ntj�}|jj|||j|j�|S(s�
        Delete the empty folder at *path* on *service_name*

        :param string/unicode service_name: Contains the name of the shared folder.
        :param string/unicode path: The path of the to-be-deleted folder (relative to) the shared folder.
                                    If the path contains non-English characters, an unicode string must be used to pass in the path.
        :param integer/float timeout: Number of seconds that pysmb will wait before raising *SMBTimeout* via the returned *Deferred* instance's *errback* method.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with the *path* parameter.
        sNot connected to server(RRRR>t_deleteDirectoryR@R%(RRGRHRB((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytdeleteDirectoryTs

	cCsJ|jstd��ntj�}|jj||||j|j�|S(sF
        Rename a file or folder at *old_path* to *new_path* shared at *service_name*. Note that this method cannot be used to rename file/folder across different shared folders

        *old_path* and *new_path* are string/unicode referring to the old and new path of the renamed resources (relative to) the shared folder.
        If the path contains non-English characters, an unicode string must be used to pass in the path.

        :param string/unicode service_name: Contains the name of the shared folder.
        :param integer/float timeout: Number of seconds that pysmb will wait before raising *SMBTimeout* via the returned *Deferred* instance's *errback* method.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a 2-element tuple of ( *old_path*, *new_path* ).
        sNot connected to server(RRRR>t_renameR@R%(RRGtold_pathtnew_pathRB((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytrenamees
	"i
cCsG|jstd��ntj�}|jj||j|j|�|S(s
        Send an echo command containing *data* to the remote SMB/CIFS server. The remote SMB/CIFS will reply with the same *data*.

        :param bytes data: Data to send to the remote server. Must be a bytes object.
        :param integer/float timeout: Number of seconds that pysmb will wait before raising *SMBTimeout* via the returned *Deferred* instance's *errback* method.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with the *data* parameter.
        sNot connected to server(RRRR>t_echoR@R%(RRRARB((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytechows
	cCs,|jstd��n|jjj�dS(s�
        Disconnect from the remote SMB/CIFS server. The TCP connection will be closed at the earliest opportunity after this method returns.

        :return: None
        sNot connected to serverN(RRRtloseConnection(R((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pytcloseConnection�s	c	CsI|j|j|j|j|j|j|j|j|j�}||_	|S(N(
tprotocolR1R2R3R4R5R6R7R
R(Rtaddrtp((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyt
buildProtocol�s<	(&R,R-R
ReR.R/Rt
SIGN_NEVERtSIGN_WHEN_SUPPORTEDtSIGN_WHEN_REQUIREDtTruetFalseR8tpropertyR;R=RRRCtSMB_FILE_ATTRIBUTE_READONLYtSMB_FILE_ATTRIBUTE_HIDDENtSMB_FILE_ATTRIBUTE_SYSTEMtSMB_FILE_ATTRIBUTE_DIRECTORYtSMB_FILE_ATTRIBUTE_ARCHIVEtSMB_FILE_ATTRIBUTE_INCL_NORMALRIRKRMRPRNRURXRZR\R`RbRdRh(((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyR	Ks2(							(tosR.R!ttwisted.internetRRttwisted.internet.protocolRRt
smb_constantstsmb_structstbaseRRRRt__all__R
R	(((sD/opt/plesk/python/2.7/lib/python2.7/site-packages/smb/SMBProtocol.pyt<module>s$

">

Zerion Mini Shell 1.0