'Send files or directory trees to the server.
The semantics of src_pattern and dst_path are similar to those of scp.
For example, the following are OK:
src_pattern=\'/tmp/foo.txt\', dst_path=\'C:\\'
(uploads a single file)
src_pattern=\'/usr/\', dst_path=\'C:\Windows\\'
(uploads a directory tree recursively)
src_pattern=\'/usr/*\', dst_path=\'C:\Windows\\'
(uploads all files and directory trees under /usr/)
The following is not OK:
src_pattern=\'/tmp/foo.txt\', dst_path=\'C:\Windows\*\'
(wildcards are only allowed in src_pattern)
:param src_pattern: A path or wildcard pattern specifying the files or
directories to send to the server
:param dst_path: A path in the server\'s filesystem where the files will
be saved
:param timeout: Time duration in seconds to wait for the transfer to
complete
:raise FileTransferTimeoutError: Raised if timeout expires
:raise FileTransferServerError: Raised if something goes wrong and the
server sends an informative error message to the client
:note: Other exceptions can be raised.'

def upload(self, src_pattern, dst_path, timeout=600):

    end_time = (time.time() + timeout)
    try:
        try:
            self._send_msg(RSS_SET_PATH)
            self._send_packet(dst_path)
            matches = glob.glob(src_pattern)
            for filename in matches:
                self._upload_file(os.path.abspath(filename), end_time)
            self._send_msg(RSS_DONE)
        except FileTransferTimeoutError:
            raise
        except FileTransferError:
            self._handle_transfer_error()
        else:
            if (not matches):
                raise FileTransferNotFoundError(('Pattern    %s    does    not    match    any    files    or    directories' % src_pattern))
            msg = self._receive_msg((end_time - time.time()))
            if (msg == RSS_OK):
                return
            elif (msg == RSS_ERROR):
                errmsg = self._receive_packet()
                raise FileTransferServerError(errmsg)
            else:
                raise FileTransferProtocolError('Received    unexpected    msg')
    except Exception:
        self.close()
        raise
