Bundler Python Module

This is the bundler library.

This module exports classes and methods for constructing and streaming bundles of files to a designated file descriptor. The file descriptor is opened once, and the stream is generated by a single pass over the specified files.

class pacifica.uploader.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.