Package duplicity :: Module backend :: Class Backend
[hide private]
[frames] | no frames]

Class Backend

source code


Represents a generic duplicity backend, capable of storing and retrieving files.

Concrete sub-classes are expected to implement:

Instance Methods [hide private]
 
__init__(self, parsed_url) source code
 
put(self, source_path, remote_filename=None)
Transfer source_path (Path object) to remote_filename (string)
source code
 
get(self, remote_filename, local_path)
Retrieve remote_filename and place in local_path
source code
 
list(self)
Return list of filenames (strings) present in backend
source code
 
delete(self, filename_list)
Delete each filename in filename_list, in order if possible.
source code
 
get_password(self)
Return a password for authentication purposes.
source code
 
munge_password(self, commandline)
Remove password from commandline by substituting the password found in the URL, if any, with a generic place-holder.
source code
 
run_command(self, commandline)
Execute the given command line, interpreted as a shell command, with logging and error detection.
source code
 
run_command_persist(self, commandline)
Like run_command(), but repeat the attempt several times (with a delay in between) if it fails.
source code
 
popen(self, commandline)
Like run_command(), but capture stdout and return it (the contents read from stdout) as a string.
source code
 
popen_persist(self, commandline)
Like run_command_persist(), but capture stdout and return it (the contents read from stdout) as a string.
source code
 
get_fileobj_read(self, filename, parseresults=None)
Return fileobject opened for reading of filename on backend
source code
 
get_fileobj_write(self, filename, parseresults=None, sizelist=None)
Return fileobj opened for writing, which will cause the file to be written to the backend on close().
source code
 
get_data(self, filename, parseresults=None)
Retrieve a file from backend, process it, return contents.
source code
 
put_data(self, buffer, filename, parseresults=None)
Put buffer into filename on backend after processing.
source code
 
close(self)
Close the backend, releasing any resources held and invalidating any file objects obtained from the backend.
source code
Method Details [hide private]

put(self, source_path, remote_filename=None)

source code 

Transfer source_path (Path object) to remote_filename (string)

If remote_filename is None, get the filename from the last path component of pathname.

get_password(self)

source code 
Return a password for authentication purposes. The password will be obtained from the backend URL, the environment, by asking the user, or by some other method. When applicable, the result will be cached for future invocations.

munge_password(self, commandline)

source code 

Remove password from commandline by substituting the password found in the URL, if any, with a generic place-holder.

This is intended for display purposes only, and it is not guaranteed that the results are correct (i.e., more than just the password may be substituted if the password is also a substring of another part of the command line).

run_command(self, commandline)

source code 
Execute the given command line, interpreted as a shell command, with logging and error detection. If execution fails, raise a BackendException.

get_fileobj_read(self, filename, parseresults=None)

source code 

Return fileobject opened for reading of filename on backend

The file will be downloaded first into a temp file. When the returned fileobj is closed, the temp file will be deleted.

get_fileobj_write(self, filename, parseresults=None, sizelist=None)

source code 

Return fileobj opened for writing, which will cause the file to be written to the backend on close().

The file will be encoded as specified in parseresults (or as read from the filename), and stored in a temp file until it can be copied over and deleted.

If sizelist is not None, it should be set to an empty list. The number of bytes will be inserted into the list.