b.t.f.FtpTransport(ConnectedTransport) : class documentation

Part of bzrlib.transport.ftp View In Hierarchy

Known subclasses: bzrlib.transport.ftp._gssapi.GSSAPIFtpTransport

This is the transport agent for ftp:// access.
Method __init__ Set the base path where files will be stored.
Method disconnect Disconnect the transport.
Method has Does the target location exist?
Method get Get the file at the given relative path.
Method put_file Copy the file-like or string object into the location.
Method mkdir Create a directory at the given path.
Method open_write_stream See Transport.open_write_stream.
Method recommended_page_size See Transport.recommended_page_size().
Method rmdir Delete the directory at rel_path
Method append_file Append the text in the file-like object into the final
Method rename Rename a file or directory.
Method move Move the item at rel_from to the location at rel_to
Method delete Delete the item at relpath
Method external_url See bzrlib.transport.Transport.external_url.
Method listable See Transport.listable.
Method list_dir See Transport.list_dir.
Method iter_files_recursive See Transport.iter_files_recursive.
Method stat Return the stat information for a file.
Method lock_read Lock the given file for shared (read) access.
Method lock_write Lock the given file for exclusive (write) access.
Method _get_FTP Return the ftplib.FTP instance for this object.
Method _create_connection Create a new connection with the provided credentials.
Method _login Undocumented
Method _reconnect Create a new connection with the previously used credentials
Method _translate_ftp_error Try to translate an ftplib exception to a bzrlib exception.
Method _try_append Try repeatedly to append the given text to the file at relpath.
Method _fallback_append Undocumented
Method _setmode Set permissions on a path.
Method _rename Undocumented
Method _rename_and_overwrite Do a fancy rename on the remote server.
Method _delete Undocumented

Inherited from ConnectedTransport:

Method clone Return a new transport with root at self.base + offset
Method relpath Return the local path portion from a given absolute path
Method abspath Return the full url to the given relative path.
Method _user Undocumented
Method _password Undocumented
Method _host Undocumented
Method _port Undocumented
Method _path Undocumented
Method _scheme Undocumented
Static Method _split_url Undocumented
Static Method _unsplit_url Build the full URL for the given already URL encoded path.
Method _remote_path Return the absolute path part of the url to the given relative path.
Method _get_shared_connection Get the object shared amongst cloned transports.
Method _set_connection Record a newly created connection with its associated credentials.
Method _get_connection Returns the transport specific connection object.
Method _get_credentials Returns the credentials used to establish the connection.
Method _update_credentials Update the credentials of the current connection.
Method _reuse_for Returns a transport sharing the same connection if possible.

Inherited from Transport (via ConnectedTransport):

Method create_prefix Create all the directories leading down to self.base.
Method ensure_base Ensure that the directory this transport references exists.
Method get_segment_parameters Return the segment parameters for the top segment of the URL.
Method local_abspath Return the absolute path on the local filesystem.
Method has_multi Return True/False for each entry in relpaths
Method has_any Return True if any of the paths exist.
Method get_bytes Get a raw string of the bytes for a file at the given location.
Method get_smart_medium Return a smart client medium for this transport if possible.
Method readv Get parts of the file at the given relative path.
Method get_multi Get a list of file-like objects, one for each entry in relpaths.
Method put_bytes Atomically put the supplied bytes into the given location.
Method put_bytes_non_atomic Copy the string into the target location.
Method put_file_non_atomic Copy the file-like object into the target location.
Method mkdir_multi Create a group of directories
Method append_bytes Append bytes to a file at relpath.
Method append_multi Append the text in each file-like or string object to
Method copy Copy the item at rel_from to the location at rel_to.
Method copy_multi Copy a bunch of entries.
Method copy_to Copy a set of entries from self into another Transport.
Method copy_tree Copy a subtree from one relpath to another.
Method copy_tree_to_transport Copy a subtree from one transport to another.
Method move_multi Move a bunch of entries.
Method move_multi_to Move a bunch of entries to a single location.
Method delete_multi Queue up a bunch of deletes to be done.
Method delete_tree Delete an entire tree. This may require a listable transport.
Method __repr__ Undocumented
Method stat_multi Stat multiple files and return the information.
Method readlink Return a string representing the path to which the symbolic link points.
Method hardlink Create a hardlink pointing to source named link_name.
Method symlink Create a symlink pointing to source named link_name.
Method is_readonly Return true if this connection cannot be written to.
Method _translate_error Translate an IOError or OSError into an appropriate bzr error.
Method _pump Most children will need to copy from one file-like
Method _get_total Try to figure out how many entries are in multi,
Method _report_activity Notify that this transport has activity.
Method _update_pb Update the progress bar based on the current count
Method _iterate_over Iterate over all entries in multi, passing them to func,
Method _readv Get parts of the file at the given relative path.
Method _seek_and_read An implementation of readv that uses fp.seek and fp.read.
Method _sort_expand_and_combine Helper for readv.
Static Method _coalesce_offsets Yield coalesced offsets.
Method _can_roundtrip_unix_modebits Return true if this transport can store and retrieve unix modebits.
Method _redirected_to Returns a transport suitable to re-issue a redirected request.
def __init__(self, base, _from_transport=None):
Set the base path where files will be stored.
def _get_FTP(self):
Return the ftplib.FTP instance for this object.
def _create_connection(self, credentials=None):
Create a new connection with the provided credentials.

The input credentials are only the password as it may have been entered interactively by the user and may be different from the one provided in base url at transport creation time. The returned credentials are username, password.

ParameterscredentialsThe credentials needed to establish the connection.
ReturnsThe created connection and its associated credentials.
def _login(self, connection, auth, user, password):
Undocumented
def _reconnect(self):
Create a new connection with the previously used credentials
def disconnect(self):
Disconnect the transport.

If and when required the transport willl reconnect automatically.

def _translate_ftp_error(self, err, path, extra=None, unknown_exc=FtpPathError):
Try to translate an ftplib exception to a bzrlib exception.
ParameterserrThe error to translate into a bzr error
pathThe path which had problems
extraExtra information which can be included
unknown_excIf None, we will just raise the original exception otherwise we raise unknown_exc(path, extra=extra)
def has(self, relpath):
Does the target location exist?
def get(self, relpath, decode=DEPRECATED_PARAMETER, retries=0):
Get the file at the given relative path.

We're meant to return a file-like object which bzr will then read from. For now we do this via the magic of StringIO

ParametersrelpathThe relative path to the file
retriesNumber of retries after temporary failures so far for this operation.
def put_file(self, relpath, fp, mode=None, retries=0):
Copy the file-like or string object into the location.

TODO: jam 20051215 ftp as a protocol seems to support chmod, but ftplib does not

ParametersrelpathLocation to put the contents, relative to base.
fpFile-like or string object.
retriesNumber of retries after temporary failures so far for this operation.
def mkdir(self, relpath, mode=None):
Create a directory at the given path.
def open_write_stream(self, relpath, mode=None):
See Transport.open_write_stream.
def recommended_page_size(self):
See Transport.recommended_page_size().

For FTP we suggest a large page size to reduce the overhead introduced by latency.

def rmdir(self, rel_path):
Delete the directory at rel_path
def append_file(self, relpath, f, mode=None):
Append the text in the file-like object into the final location.
def _try_append(self, relpath, text, mode=None, retries=0):
Try repeatedly to append the given text to the file at relpath.

This is a recursive function. On errors, it will be called until the number of retries is exceeded.

def _fallback_append(self, relpath, text, mode=None):
Undocumented
def _setmode(self, relpath, mode):
Set permissions on a path.

Only set permissions if the FTP server supports the 'SITE CHMOD' extension.

def rename(self, rel_from, rel_to):
Rename a file or directory.

This must fail if the destination is a nonempty directory - it must not automatically remove it. It should raise DirectoryNotEmpty, or some other PathError if the case can't be specifically detected.

If the destination is an empty directory or a file this function may either fail or succeed, depending on the underlying transport. It should not attempt to remove the destination if overwriting is not the native transport behaviour. If at all possible the transport should ensure that the rename either completes or not, without leaving the destination deleted and the new file not moved in place.

This is intended mainly for use in implementing LockDir.

def _rename(self, abs_from, abs_to, f):
Undocumented
def move(self, rel_from, rel_to):
Move the item at rel_from to the location at rel_to
def _rename_and_overwrite(self, abs_from, abs_to, f):
Do a fancy rename on the remote server.

Using the implementation provided by osutils.

def delete(self, relpath):
Delete the item at relpath
def _delete(self, abspath, f):
Undocumented
def external_url(self):
See bzrlib.transport.Transport.external_url.
def listable(self):
See Transport.listable.
def list_dir(self, relpath):
See Transport.list_dir.
def iter_files_recursive(self):
See Transport.iter_files_recursive.

This is cargo-culted from the SFTP transport

def stat(self, relpath):
Return the stat information for a file.
def lock_read(self, relpath):
Lock the given file for shared (read) access. :return: A lock object, which should be passed to Transport.unlock()
def lock_write(self, relpath):
Lock the given file for exclusive (write) access. WARNING: many transports do not support this, so trying avoid using it
ReturnsA lock object, which should be passed to Transport.unlock()
API Documentation for Bazaar, generated by pydoctor at 2019-12-13 00:41:47.