duplicity.gpg module

duplicity’s gpg interface, builds upon Frank Tobin’s GnuPGInterface which is now patched with some code for iterative threaded execution see duplicity’s README for details

exception duplicity.gpg.GPGError[source]

Bases: exceptions.Exception

Indicate some GPG Error

class duplicity.gpg.GPGFile(encrypt, encrypt_path, profile)[source]

File-like object that encrypts decrypts another file on the fly

close()[source]
get_signature()[source]

Return keyID of signature, or None if none

gpg_failed()[source]
read(length=-1)[source]
seek(offset)[source]
set_signature()[source]

Set self.signature to signature keyID

This only applies to decrypted files. If the file was not signed, set self.signature to None.

tell()[source]
write(buf)[source]
class duplicity.gpg.GPGProfile(passphrase=None, sign_key=None, recipients=None, hidden_recipients=None)[source]

Just hold some GPG settings, avoid passing tons of arguments

get_gpg_major(binary)[source]
duplicity.gpg.GPGWriteFile(block_iter, filename, profile, size=209715200, max_footer_size=16384)[source]

Write GPG compressed file of given size

This function writes a gpg compressed file by reading from the input iter and writing to filename. When it has read an amount close to the size limit, it “tops off” the incoming data with incompressible data, to try to hit the limit exactly.

block_iter should have methods .next(size), which returns the next block of data, which should be at most size bytes long. Also .get_footer() returns a string to write at the end of the input file. The footer should have max length max_footer_size.

Because gpg uses compression, we don’t assume that putting bytes_in bytes into gpg will result in bytes_out = bytes_in out. However, do assume that bytes_out <= bytes_in approximately.

Returns true if succeeded in writing until end of block_iter.

duplicity.gpg.GzipWriteFile(block_iter, filename, size=209715200, gzipped=True)[source]

Write gzipped compressed file of given size

This is like the earlier GPGWriteFile except it writes a gzipped file instead of a gpg’d file. This function is somewhat out of place, because it doesn’t deal with GPG at all, but it is very similar to GPGWriteFile so they might as well be defined together.

The input requirements on block_iter and the output is the same as GPGWriteFile (returns true if wrote until end of block_iter).

duplicity.gpg.PlainWriteFile(block_iter, filename, size=209715200, gzipped=False)[source]

Write plain uncompressed file of given size

This is like the earlier GPGWriteFile except it writes a gzipped file instead of a gpg’d file. This function is somewhat out of place, because it doesn’t deal with GPG at all, but it is very similar to GPGWriteFile so they might as well be defined together.

The input requirements on block_iter and the output is the same as GPGWriteFile (returns true if wrote until end of block_iter).

duplicity.gpg.get_hash(hash, path, hex=1)[source]

Return hash of path

hash should be “MD5” or “SHA1”. The output will be in hexadecimal form if hex is true, and in text (base64) otherwise.