Bundler Python Module

Main Bundler module containing classes and methods to handle bundling.

class pacifica.uploader.bundler.bundler.Bundler(md_obj, file_data, **kwargs)[source]

Class to handle bundling of files to stream a tarfile.

__init__(md_obj, file_data, **kwargs)[source]

Constructor of the bundler class.

Add the MetaData object md_obj and file file_data to create. The file_data object should be a list of hashes. That are fed to TarInfo objects except for fileobj which is passed to addfile method.

Note: The arcname keyword argument MUST be provided when calling the tarfile.TarFile.gettarinfo() method.

Example MetaData Obj:

    'name': 'archive file path',
    'fileobj': 'open file object for read',
    'size': 'size of the file',
    'mtime': 'modify time of the file'
_build_file_info(file_data, hashsum)[source]

Build the FileObj to and return it.


Build the total size from the files and save the total.

_setup_notify_thread(callback, sleeptime=5)[source]

Setup a notification thread calling callback with percent complete.

static _strip_subdir(fname)[source]

Remove the data subdir from the file path.


Return a tarinfo object from file_data.

file_data = None
md_obj = None
stream(fileobj, callback=None, sleeptime=5)[source]

Stream the bundle to the fileobj.

This method is a blocking I/O operation. The fileobj should be an open file like object with ‘wb’ options. An asynchronous callback method MAY be provided via the optional callback keyword argument. Periodically, the callback method is provided with the current percentage of completion.

class pacifica.uploader.bundler.bundler.HashFileObj(filedesc, hashval, upref)[source]

File like object used for reading and hashing files.

__init__(filedesc, hashval, upref)[source]

Create the hash file object.


Return the hash digest for the file.


Read wrapper function.