b.t.r.RemoteTransport(transport.ConnectedTransport) : class documentation

Part of bzrlib.transport.remote View In Hierarchy

Known subclasses: bzrlib.transport.remote.RemoteHTTPTransport, bzrlib.transport.remote.RemoteSSHTransport, bzrlib.transport.remote.RemoteTCPTransport, bzrlib.transport.remote.RemoteTCPTransportV2Only

Connection to a smart server.

The connection holds references to the medium that can be used to send requests to the server.

The connection has a notion of the current directory to which it's connected; this is incorporated in filenames passed to the server.

This supports some higher-level RPC operations and can also be treated like a Transport to do file-like operations.

The connection can be made over a tcp socket, an ssh pipe or a series of http requests. There are concrete subclasses for each type: RemoteTCPTransport, etc.

Method __init__ Constructor.
Method is_readonly Smart server transport can do read/write file operations.
Method get_smart_client Undocumented
Method get_smart_medium Return a smart client medium for this transport if possible.
Method has Indicate whether a remote file of the given name exists or not.
Method get Return file-like object reading the contents of a remote file.
Method get_bytes Get a raw string of the bytes for a file at the given location.
Method mkdir Create a directory at the given path.
Method open_write_stream See Transport.open_write_stream.
Method put_bytes Atomically put the supplied bytes into the given location.
Method put_bytes_non_atomic See Transport.put_bytes_non_atomic.
Method put_file Copy the file-like object into the location.
Method put_file_non_atomic Copy the file-like object into the target location.
Method append_file Append bytes from a file-like object to a file at relpath.
Method append_bytes Append bytes to a file at relpath.
Method delete Delete the item at relpath
Method external_url See bzrlib.transport.Transport.external_url.
Method recommended_page_size Return the recommended page size for this transport.
Method rename Rename a file or directory.
Method move Move the item at rel_from to the location at rel_to.
Method rmdir Remove a directory at the given path.
Method disconnect Disconnect the transport.
Method stat Return the stat information for a file.
Method listable Return True if this store supports listing.
Method list_dir Return a list of all files at the given location.
Method iter_files_recursive Iter the relative paths of files in the transports sub-tree.
Method _build_medium Create the medium if _from_transport does not provide one.
Method _report_activity See Transport._report_activity.
Method _remote_path Returns the Unicode version of the absolute path for relpath.
Method _call Undocumented
Method _call2 Call a method on the remote server.
Method _call_with_body_bytes Call a method on the remote server with body bytes.
Method _serialise_optional_mode Undocumented
Method _readv Get parts of the file at the given relative path.
Method _handle_response Undocumented
Method _ensure_ok Undocumented
Method _translate_error Translate an IOError or OSError into an appropriate bzr error.

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 _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 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 mkdir_multi Create a group of directories
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 lock_read Lock the given file for shared (read) access.
Method lock_write Lock the given file for exclusive (write) access.
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 _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 _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, url, _from_transport=None, medium=None, _client=None):
Constructor.
Parameters_from_transportAnother RemoteTransport instance that this one is being cloned from. Attributes such as the medium will be reused.
mediumThe medium to use for this RemoteTransport. If None, the medium from the _from_transport is shared. If both this and _from_transport are None, a new medium will be built. _from_transport and medium cannot both be specified.
_clientOverride the _SmartClient used by this transport. This should only be used for testing purposes; normally this is determined from the medium.
def _build_medium(self):
Create the medium if _from_transport does not provide one.

The medium is analogous to the connection for ConnectedTransport: it allows connection sharing.

def _report_activity(self, bytes, direction):
See Transport._report_activity.

Does nothing; the smart medium will report activity triggered by a RemoteTransport.

def is_readonly(self):
Smart server transport can do read/write file operations.
def get_smart_client(self):
Undocumented
def get_smart_medium(self):
Return a smart client medium for this transport if possible.

A smart medium doesn't imply the presence of a smart server: it implies that the smart protocol can be tunnelled via this transport.

RaisesNoSmartMediumif no smart server medium is available.
def _remote_path(self, relpath):
Returns the Unicode version of the absolute path for relpath.
def _call(self, method, *args):
Undocumented
def _call2(self, method, *args):
Call a method on the remote server.
def _call_with_body_bytes(self, method, args, body):
Call a method on the remote server with body bytes.
def has(self, relpath):
Indicate whether a remote file of the given name exists or not.
See AlsoTransport.has()
def get(self, relpath):
Return file-like object reading the contents of a remote file.
See AlsoTransport.get_bytes()/get_file()
def get_bytes(self, relpath):
Get a raw string of the bytes for a file at the given location.
ParametersrelpathThe relative path to the file
def _serialise_optional_mode(self, mode):
Undocumented
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 put_bytes(self, relpath, upload_contents, mode=None):
Atomically put the supplied bytes into the given location.
ParametersrelpathThe location to put the contents, relative to the transport base.
bytesA bytestring of data.
modeCreate the file with the given mode.
ReturnsNone
def put_bytes_non_atomic(self, relpath, bytes, mode=None, create_parent_dir=False, dir_mode=None):
See Transport.put_bytes_non_atomic.
def put_file(self, relpath, upload_file, mode=None):
Copy the file-like object into the location.
ParametersrelpathLocation to put the contents, relative to base.
fFile-like object.
modeThe mode for the newly created file, None means just use the default.
ReturnsThe length of the file that was written.
def put_file_non_atomic(self, relpath, f, mode=None, create_parent_dir=False, dir_mode=None):
Copy the file-like object into the target location.

This function is not strictly safe to use. It is only meant to be used when you already know that the target does not exist. It is not safe, because it will open and truncate the remote file. So there may be a time when the file has invalid contents.

ParametersrelpathThe remote location to put the contents.
fFile-like object.
modePossible access permissions for new file. None means do not set remote permissions.
create_parent_dirIf we cannot create the target file because the parent directory does not exist, go ahead and create it, and then try again.
dir_modePossible access permissions for new directories.
def append_file(self, relpath, from_file, mode=None):
Append bytes from a file-like object to a file at relpath.

The file is created if it does not already exist.

Parametersfa file-like object of the bytes to append.
modeUnix mode for newly created files. This is not used for existing files.
Returnsthe length of relpath before the content was written to it.
def append_bytes(self, relpath, bytes, mode=None):
Append bytes to a file at relpath.

The file is created if it does not already exist.

Parametersfa string of the bytes to append. (type: str)
modeUnix mode for newly created files. This is not used for existing files.
Returnsthe length of relpath before the content was written to it.
def delete(self, relpath):
Delete the item at relpath
def external_url(self):
See bzrlib.transport.Transport.external_url.
def recommended_page_size(self):
Return the recommended page size for this transport.
def _readv(self, relpath, offsets):
Get parts of the file at the given relative path.
ParametersrelpathThe path to read.
offsetsA list of (offset, size) tuples.
ReturnsA list or generator of (offset, data) tuples
def _handle_response(self, offset_stack, coalesced, response_handler, data_map, next_offset):
Undocumented
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 move(self, rel_from, rel_to):
Move the item at rel_from to the location at rel_to.

The destination is deleted if possible, even if it's a non-empty directory tree.

If a transport can directly implement this it is suggested that it do so for efficiency.

def rmdir(self, relpath):
Remove a directory at the given path.
def _ensure_ok(self, resp):
Undocumented
def _translate_error(self, err, relpath=None):
Translate an IOError or OSError into an appropriate bzr error.

This handles things like ENOENT, ENOTDIR, EEXIST, and EACCESS

def disconnect(self):
Disconnect the transport.

If and when required the transport willl reconnect automatically.

def stat(self, relpath):
Return the stat information for a file. WARNING: This may not be implementable for all protocols, so use sparingly. NOTE: This returns an object with fields such as 'st_size'. It MAY or MAY NOT return the literal result of an os.stat() call, so all access should be via named fields. ALSO NOTE: Stats of directories may not be supported on some transports.
def listable(self):
Return True if this store supports listing.
def list_dir(self, relpath):
Return a list of all files at the given location. WARNING: many transports do not support this, so trying avoid using it if at all possible.
def iter_files_recursive(self):
Iter the relative paths of files in the transports sub-tree.

NOTE: This only lists files, not subdirectories!

As with other listing functions, only some transports implement this,. you may check via listable() to determine if it will.

API Documentation for Bazaar, generated by pydoctor at 2019-12-06 00:42:00.