Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.72 KB

README.md

File metadata and controls

43 lines (32 loc) · 1.72 KB

Petact

PyPI version Codacy Badge GitHub code size in bytes License

A package extraction tool for Python

Petact is a library used for installing and updating compressed tar files. When install_package is called, it downloads an md5 file and compares it with the md5 of the locally downloaded tar. If they are different, the old extracted files are deleted and the new tar is downloaded and extracted to the same place.

Usage

from os.path import isdir
from petact import install_package, download, download_extract_tar, calc_md5


install_package(
    tar_url='http://mysite.com/binaries.tar.gz', folder='place/for/binaries',
    md5_url='http://mysite.com/binaries.tar.gz.md5', 
    on_download=lambda: print('Updating...'),
    on_complete=lambda: print('Update Complete.')
)


# Other utility functions
words = download('http://mysite.com/words.txt').split(b' ')
download('http://mysite.com/anotherfile.bin', 'anotherfile.bin')
md5_str = calc_md5('anotherfile.bin')
if not isdir('data'):
    download_extract_tar('http://mysite.com/data.tar.gz', 'data')

Installation

pip3 install petact