bbarchivist package¶
Submodules¶
bbarchivist.barutils module¶
This module is used to operate with bar files and other archives.
-
bbarchivist.barutils.
bar_tester
(filepath)[source]¶ Use zipfile in order to test a bar for errors.
Parameters: filepath (str) – Path to bar file.
-
bbarchivist.barutils.
calculate_strength
()[source]¶ Determine zip/gzip/bzip2 strength by OS bit setting.
-
bbarchivist.barutils.
compress
(filepath, method='7z', szexe=None, selective=False, errors=False)[source]¶ Compress all autoloader files in a given folder, with a given method.
Parameters: - filepath (str) – Working directory. Required.
- method (str) – Compression type. Default is “7z”.
- szexe (str) – Path to 7z executable, if needed.
- selective (bool) – Only compress autoloaders. Default is false.
- errors (bool) – Print completion status message. Default is false.
-
bbarchivist.barutils.
compress_config_loader
(homepath=None)[source]¶ Read a ConfigParser file to get compression preferences.
Parameters: homepath (str) – Folder containing ini file. Default is user directory.
-
bbarchivist.barutils.
compress_config_writer
(method=None, homepath=None)[source]¶ Write a ConfigParser file to store compression preferences.
Parameters: - method (str) – Method to use.
- homepath (str) – Folder containing ini file. Default is user directory.
-
bbarchivist.barutils.
compress_suite
(filepath, method='7z', szexe=None, selective=False)[source]¶ Wrap compression and verification into one.
Parameters: - filepath (str) – Working directory. Required.
- method (str) – Compression type. Default is “7z”. Defined in source.
- szexe (str) – Path to 7z executable, if needed.
- selective (bool) – Only compress autoloaders. Default is false.
-
bbarchivist.barutils.
create_blitz
(a_folder, swver)[source]¶ Create a blitz file: a zipped archive of all app/core/radio bars.
Parameters: - a_folder (str) – Target folder.
- swver (str) – Software version to title the blitz.
-
bbarchivist.barutils.
extract_bars
(filepath)[source]¶ Extract .signed files from .bar files. Use system zlib.
Parameters: filepath (str) – Path to bar file directory.
-
bbarchivist.barutils.
filter_method
(method, szexe=None)[source]¶ Make sure methods are OK.
Parameters: - method (str) – Compression method to use.
- szexe (str) – Path to 7z executable, if needed.
-
bbarchivist.barutils.
loader_sorter
(file, osdir, raddir)[source]¶ Sort loaders based on size.
Parameters: - file (str) – The file to sort. Absolute paths, please.
- osdir (str) – Large file destination.
- raddir (str) – Small file destination.
-
bbarchivist.barutils.
make_dirs
(localdir, osversion, radioversion)[source]¶ Create the directory tree needed for archivist/lazyloader.
Parameters: - localdir (str) – Root folder.
- osversion (str) – OS version.
- radioversion (str) – Radio version.
-
bbarchivist.barutils.
move_bars
(localdir, osdir, radiodir)[source]¶ Move bar files to subfolders of a given folder.
Parameters: - localdir (str) – Directory to use.
- osdir (str) – OS file directory (large bars).
- radiodir (str) – Radio file directory (small bars).
-
bbarchivist.barutils.
move_loaders
(a_dir, exedir_os, exedir_rad, zipdir_os, zipdir_rad)[source]¶ Move autoloaders to zipped and loaders directories in localdir.
Parameters: - a_dir (str) – Local directory, containing files you wish to move.
- exedir_os (str) – Large autoloader .exe destination.
- exedir_rad (str) – Small autoloader .exe destination.
- zipdir_os (str) – Large autoloader archive destination.
- zipdir_rad (str) – Small autoloader archive destination.
-
bbarchivist.barutils.
prepends
(file, pre, suf)[source]¶ Check if filename starts with/ends with stuff.
Parameters: - file (str) – File to check.
- pre (str or list or tuple) – Prefix(es) to check.
- suf (str or list or tuple) – Suffix(es) to check.
-
bbarchivist.barutils.
remove_empty_folders
(a_folder)[source]¶ Remove empty folders in a given folder using os.walk().
Parameters: a_folder (str) – Target folder.
-
bbarchivist.barutils.
remove_signed_files
(a_folder)[source]¶ Remove signed files from a given folder.
Parameters: a_folder (str) – Target folder.
-
bbarchivist.barutils.
remove_unpacked_loaders
(osdir, raddir, radios)[source]¶ Remove uncompressed loader folders.
Parameters: - osdir (str) – OS loader folder.
- raddir (str) – Radio loader folder.
- radios (bool) – If we made radios this run.
-
bbarchivist.barutils.
retrieve_sha512
(filename)[source]¶ Get the premade, Base64 encoded SHA512 hash of a signed file in a bar.
Parameters: filename (str) – Bar file to check.
-
bbarchivist.barutils.
sz_compress
(filepath, filename, szexe=None, strength=5, errors=False)[source]¶ Pack a file into a LZMA2 7z file.
Parameters: - filepath (str) – Basename of file, no extension.
- filename (str) – Name of file to pack.
- szexe (str) – Path to 7z executable.
- strength (int) – Compression strength. 5 is normal, 9 is ultra.
- errors (bool) – Print completion status message. Default is false.
-
bbarchivist.barutils.
sz_verify
(filepath, szexe=None)[source]¶ Verify that a .7z file is valid and working.
Parameters: - filepath (str) – Filename.
- szexe (str) – Path to 7z executable.
-
bbarchivist.barutils.
tbz_compress
(filepath, filename, strength=5)[source]¶ Pack a file into a bzip2 tarfile.
Parameters: - filepath (str) – Basename of file, no extension.
- filename (str) – Name of file to pack.
- strength (int) – Compression strength. 5 is normal, 9 is ultra.
-
bbarchivist.barutils.
tbz_verify
(filepath)[source]¶ Verify that a tar.bz2 file is valid and working.
Parameters: filepath (str) – Filename.
-
bbarchivist.barutils.
tgz_compress
(filepath, filename, strength=5)[source]¶ Pack a file into a gzip tarfile.
Parameters: - filepath (str) – Basename of file, no extension.
- filename (str) – Name of file to pack.
- strength (int) – Compression strength. 5 is normal, 9 is ultra.
-
bbarchivist.barutils.
tgz_verify
(filepath)[source]¶ Verify that a tar.gz file is valid and working.
Parameters: filepath (str) – Filename.
-
bbarchivist.barutils.
txz_compress
(filepath, filename)[source]¶ Pack a file into a LZMA tarfile.
Parameters: - filepath (str) – Basename of file, no extension.
- filename (str) – Name of file to pack.
-
bbarchivist.barutils.
txz_verify
(filepath)[source]¶ Verify that a tar.xz file is valid and working.
Parameters: filepath (str) – Filename.
-
bbarchivist.barutils.
verify
(thepath, method='7z', szexe=None, selective=False)[source]¶ Verify specific archive files in a given folder.
Parameters: - thepath (str) – Working directory. Required.
- method (str) – Compression type. Default is “7z”. Defined in source.
- szexe (str) – Path to 7z executable, if needed.
- selective (bool) – Only verify autoloaders. Default is false.
-
bbarchivist.barutils.
verify_sha512
(filename, inithash)[source]¶ Compare the original hash value with the current.
Parameters: - filename (str) – Signed file to check.
- inithash (bytes) – Original SHA512 hash, as bytestring.
bbarchivist.bbconstants module¶
This module is used to define constants for the program.
-
bbarchivist.bbconstants.
ARCS
= ('.7z', '.tar.xz', '.tar.bz2', '.tar.gz', '.zip', '.txz', '.tbz', '.tgz', '.bar')¶ Archive files.
-
bbarchivist.bbconstants.
ARCSPLUS
= ('.7z', '.tar.xz', '.tar.bz2', '.tar.gz', '.zip', '.exe')¶ Archive files plus executables.
-
bbarchivist.bbconstants.
CAPFILENAME
= 'cap-3.11.0.22.dat'¶ cap filename.
-
bbarchivist.bbconstants.
CAPLOCATION
= 'c:\\anaconda3\\envs\\bbarchivist\\lib\\site-packages\\bbarchivist-2.3.0-py3.5.egg\\bbarchivist\\cap-3.11.0.22.dat'¶ Where cap.exe is. Should be in site-packages.
-
bbarchivist.bbconstants.
CAPVERSION
= '3.11.0.22'¶ Version of cap.exe bundled with app.
-
bbarchivist.bbconstants.
CFPFILENAME
= 'cfp-3.10.0.57.dat'¶ cfp filename.
-
bbarchivist.bbconstants.
CFPLOCATION
= 'c:\\anaconda3\\envs\\bbarchivist\\lib\\site-packages\\bbarchivist-2.3.0-py3.5.egg\\bbarchivist\\cfp-3.10.0.57.dat'¶ Where cfp.exe is. Should be in site-packages.
-
bbarchivist.bbconstants.
CFPVERSION
= '3.10.0.57'¶ Version of cfp.exe bundled with app.
-
bbarchivist.bbconstants.
DEVICES
= ('STL100-1', 'STL100-2/3/P9982', 'STL100-4', 'Q10/Q5/P9983', 'Z30/CLASSIC/LEAP', 'Z3', 'PASSPORT')¶ Devices.
-
bbarchivist.bbconstants.
DIRECTORY
= 'c:\\anaconda3\\envs\\bbarchivist\\lib\\site-packages\\bbarchivist-2.3.0-py3.5.egg\\bbarchivist'¶ File folder.
-
bbarchivist.bbconstants.
JSONFILE
= 'c:\\anaconda3\\envs\\bbarchivist\\lib\\site-packages\\bbarchivist-2.3.0-py3.5.egg\\bbarchivist\\bbconstants.json'¶ JSON storage file.
-
bbarchivist.bbconstants.
LOCATION
= 'c:\\anaconda3\\envs\\bbarchivist\\lib\\site-packages\\bbarchivist-2.3.0-py3.5.egg\\bbarchivist\\bbconstants.py'¶ File location.
-
bbarchivist.bbconstants.
METHODS
= ('7z', 'tbz', 'tgz', 'zip', 'txz')¶ Compression methods.
-
bbarchivist.bbconstants.
PREFIXES
= ('Q10', 'Z10', 'Z30', 'Z3', 'Passport')¶ Autoloader/archive filename beginnings.
-
bbarchivist.bbconstants.
SERVERS
= {'b1': 'https://beta.sl.eval.blackberry.com/slscse/srVersionLookup/2.0.0/', 'b2': 'https://beta2.sl.eval.blackberry.com/slscse/srVersionLookup/2.0.0/', 'p': 'https://cs.sl.blackberry.com/cse/srVersionLookup/2.0.0/', 'a1': 'https://alpha.sl.eval.blackberry.com/slscse/srVersionLookup/2.0.0/', 'a2': 'https://alpha2.sl.eval.blackberry.com/slscse/srVersionLookup/2.0.0/'}¶ Lookup server list.
-
bbarchivist.bbconstants.
SUPPS
= ('.asc', '.cksum')¶ Support files.
-
bbarchivist.bbconstants.
SZCODES
= {0: 'NO ERRORS', 1: 'COMPLETED WITH WARNINGS', 2: 'FATAL ERROR', 7: 'COMMAND LINE ERROR', 8: 'OUT OF MEMORY ERROR', 255: 'USER STOPPED PROCESS'}¶ 7z exit codes.
-
bbarchivist.bbconstants.
VERSION
= '2.3.0'¶ App version.
bbarchivist.filehashtools module¶
This module is used to generate file hashes/checksums and PGP signatures.
-
bbarchivist.filehashtools.
calculate_escreens
(pin, app, uptime, duration=30)[source]¶ Calculate key for the Engineering Screens based on input.
Parameters: - pin (str) – PIN to check. 8 character hexadecimal, lowercase.
- app (str) – App version. 10.x.y.zzzz.
- uptime (str) – Uptime in ms.
- duration (str) – 1, 3, 6, 15, 30 (days).
-
bbarchivist.filehashtools.
gpg_config_loader
(homepath=None)[source]¶ Read a ConfigParser file to get PGP key, password (optional)
Parameters: homepath (str) – Folder containing ini file. Default is user directory.
-
bbarchivist.filehashtools.
gpg_config_writer
(key=None, password=None, homepath=None)[source]¶ Write a ConfigParser file to store PGP key, password (optional)
Parameters: - key (str) – Key ID, leave as None to not write.
- password (str) – Key password, leave as None to not write.
- homepath (str) – Folder containing ini file. Default is user directory.
-
bbarchivist.filehashtools.
gpgfile
(filepath, gpginst, keyid=None, passphrase=None)[source]¶ Make ASCII-armored signature files with a given private key. Takes an instance of gnupg.GPG().
Parameters: - filepath (str) – File you wish to verify.
- gpginst (gnupg.GPG()) – Instance of Python GnuPG executable.
- keyid (str) – Key ID. 0xABCDEF01
- passphrase (str) – Passphrase for key.
-
bbarchivist.filehashtools.
gpgrunner
(workingdir, keyid=None, pword=None, selective=False)[source]¶ Create ASCII-armored PGP signatures for all files in a given directory.
Parameters: - workingdir (str) – Path containing files you wish to verify.
- keyid (str) – Key to use. 8-character hexadecimal, with or without 0x.
- pword (str) – Passphrase for given key.
- selective (bool) – Filtering filenames/extensions. Default is false.
-
bbarchivist.filehashtools.
ha32
(filepath, blocksize=16777216)[source]¶ Return Adler32 checksum of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.
hash_get
(filename, hashfunc, workingdir, blocksize=16777216)[source]¶ Generate and pretty format the hash result for a file.
Parameters: - filename (str) – File to hash.
- hashfunc (function) – Hash function to use.
- workingdir (str) – Working directory.
- blocksize (int) – Block size. Default is 16MB.
-
bbarchivist.filehashtools.
hash_reset
(hashlist)[source]¶ Reset list by returning only the first item.
Parameters: hashlist (list) – List to reset. First item is the type of hash.
-
bbarchivist.filehashtools.
hc32
(filepath, blocksize=16777216)[source]¶ Return CRC32 checksum of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.
hm4
(filepath, blocksize=16777216)[source]¶ Return MD4 hash of a file; depends on system SSL library.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.
hm5
(filepath, blocksize=16777216)[source]¶ Return MD5 hash of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.
hr160
(filepath, blocksize=16777216)[source]¶ Return RIPEMD160 hash of a file; depends on system SSL library.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.
hs1
(filepath, blocksize=16777216)[source]¶ Return SHA-1 hash of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.
hs224
(filepath, blocksize=16777216)[source]¶ Return SHA-224 hash of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.
hs256
(filepath, blocksize=16777216)[source]¶ Return SHA-256 hash of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.
hs384
(filepath, blocksize=16777216)[source]¶ Return SHA-384 hash of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.
hs512
(filepath, blocksize=16777216)[source]¶ Return SHA-512 hash of a file.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.
hwp
(filepath, blocksize=16777216)[source]¶ Return Whirlpool hash of a file; depends on system SSL library.
Parameters: - filepath (str) – File you wish to verify.
- blocksize (int) – How much of file to read at once.
-
bbarchivist.filehashtools.
verifier
(workingdir, kwargs=None)[source]¶ For all files in a directory, perform various hash/checksum functions. Take dict to define hashes, write output to a/individual .cksum file(s).
Parameters: - workingdir (str) – Path containing files you wish to verify.
- kwargs (dict) – Values. Refer to :func:verifier_config_loader.
bbarchivist.loadergen module¶
This module is used for creation of autoloaders.
A higher level interface for bbarchivist.pseudocap
.
-
bbarchivist.loadergen.
format_suffix
(altradio=None, radioversion=None, core=False)[source]¶ Formulate suffix for hybrid autoloaders.
Parameters: - altradio (bool) – If a hybrid autoloader is being made.
- radioversion (str) – The hybrid radio version, if applicable.
- core (bool) – If we’re using a core OS image. Default is false.
-
bbarchivist.loadergen.
generate_device
(radio)[source]¶ Read JSON to get the device integer ID from device radio.
Parameters: radio (str) – The radio filename to look up.
-
bbarchivist.loadergen.
generate_filename
(device, version, suffix=None)[source]¶ Use skeleton dict to create loader filenames.
Parameters: - device (int) – Device to use.
- version (str) – OS or radio version.
- suffix (str) – Alternate radio, or blank.
-
bbarchivist.loadergen.
generate_lazy_filename
(osversion, suffix, device)[source]¶ Read JSON to formulate a single filename.
Parameters: - osversion (str) – OS version.
- suffix (str) – Alternate radio, or just blank.
- device (int) – Device to use.
-
bbarchivist.loadergen.
generate_lazy_loader
(osversion, device, localdir=None, altradio=None, core=False)[source]¶ Create and label autoloaders for
bbarchivist.scripts.lazyloader
.generate_loaders()
, but for making one OS/radio loader.Parameters: - osversion (str) – OS version, 10.x.y.zzzz.
- device (int) – Selected device, from
- localdir (str) – Working path. Default is local dir.
- altradio (str) – The alternate radio in use, if there is one.
- core (bool) – If we’re using a core OS image. Default is false.
-
bbarchivist.loadergen.
generate_loaders
(osversion, radioversion, radios=True, localdir=None, altradio=False, core=False)[source]¶ Create and label autoloaders for
bbarchivist.scripts.archivist
.Parameters: - osversion (str) – OS version, 10.x.y.zzzz.
- radioversion (str) – Radio version, 10.x.y.zzzz.
- radios (bool) – Whether to make radios or not. True by default.
- localdir (str) – Working path. Default is local dir.
- altradio (bool) – If we’re using an alternate radio. Default is false.
- core (bool) – If we’re using a core OS image. Default is false.
-
bbarchivist.loadergen.
generate_skeletons
()[source]¶ Read JSON to get a dict of all filename components.
-
bbarchivist.loadergen.
pretty_formatter
(osversion, radioversion)[source]¶ Format OS/radio versions to cope with systems with poor sorting.
Parameters: - osversion (str) – OS version, 10.x.y.zzzz.
- radioversion (str) – Radio version, 10.x.y.zzzz.
-
bbarchivist.loadergen.
read_files
(localdir, core=False)[source]¶ Read list of signed files, return name assignments.
Parameters: - localdir (str) – Directory to use.
- core (bool) – If we’re using a core OS image. Default is false.
-
bbarchivist.loadergen.
read_os_files
(localdir, core=False)[source]¶ Read list of OS signed files, return name assignments.
Parameters: - localdir (str) – Directory to use.
- core (bool) – If we’re using a core OS image. Default is false.
-
bbarchivist.loadergen.
read_radio_files
(localdir)[source]¶ Read list of radio signed files, return name assignments.
Parameters: localdir (str) – Directory to use.
-
bbarchivist.loadergen.
wrap_pseudocap
(filename, folder, first, second=None)[source]¶ A filtered, excepting wrapper for pseudocap.
Parameters: - filename (str) – The title of the new loader.
- folder (str) – The folder to create the loader in.
- first (str) – The first signed file, required.
- second (str) – The second signed file, optional.
bbarchivist.networkutils module¶
This module is used for network connections; APIs, downloading, etc.
-
bbarchivist.networkutils.
availability
(url)[source]¶ Check HTTP status code of given URL. 200 or 301-308 is OK, else is not.
Parameters: url (str) – URL to check.
-
bbarchivist.networkutils.
available_bundle_lookup
(mcc, mnc, device)[source]¶ Check which software releases were ever released for a carrier.
Parameters: - mcc (int) – Country code.
- mnc (int) – Network code.
- device (str) – Hexadecimal hardware ID.
-
bbarchivist.networkutils.
carrier_checker
(mcc, mnc)[source]¶ Query BlackBerry World to map a MCC and a MNC to a country and carrier.
Parameters: - mcc (int) – Country code.
- mnc (int) – Network code.
-
bbarchivist.networkutils.
carrier_update_request
(npc, device, upgrade=False, blitz=False, forced=None)[source]¶ Query BlackBerry servers, check which update is out for a carrier.
Parameters: - npc (int) – MCC + MNC (see func:return_npc)
- device (str) – Hexadecimal hardware ID.
- upgrade (bool) – Whether to use upgrade files. False by default.
- blitz (bool) – Whether or not to create a blitz package. False by default.
- forced (str) – Force a software release.
-
bbarchivist.networkutils.
create_base_url
(softwareversion)[source]¶ Make the root URL for production server files.
Parameters: softwareversion (str) – Software version to hash.
-
bbarchivist.networkutils.
download
(url, output_directory=None)[source]¶ Download file from given URL.
Parameters: - url (str) – URL to download from.
- output_directory (str) – Download folder. Default is local.
-
bbarchivist.networkutils.
download_bootstrap
(urls, outdir=None, workers=5)[source]¶ Run downloaders for each file in given URL iterable.
Parameters: - urls (list) – URLs to download.
- outdir (str) – Download folder. Default is handled in
download()
. - workers (int) – Number of worker processes. Default is 5.
-
bbarchivist.networkutils.
get_length
(url)[source]¶ Get content-length header from some URL.
Parameters: url (str) – The URL to check.
-
bbarchivist.networkutils.
grab_pem
()[source]¶ Work with either local cacerts or system cacerts. Since cx_freeze is dumb.
-
bbarchivist.networkutils.
kernel_scraper
()[source]¶ Scrape BlackBerry’s GitHub kernel repo for available branches.
-
bbarchivist.networkutils.
parse_carrier_xml
(data, blitz=False)[source]¶ Parse the response to a carrier update request and return the juicy bits.
Parameters: - data (xml) – The data to parse.
- blitz (bool) – Whether or not to create a blitz package. False by default.
-
bbarchivist.networkutils.
ptcrb_item_cleaner
(item)[source]¶ Cleanup poorly formatted PTCRB entries written by an intern.
Parameters: item (str) – The item to clean.
-
bbarchivist.networkutils.
ptcrb_scraper
(ptcrbid)[source]¶ Get the PTCRB results for a given device.
Parameters: ptcrbid (str) – Numerical ID from PTCRB (end of URL).
-
bbarchivist.networkutils.
return_npc
(mcc, mnc)[source]¶ Format MCC and MNC into a NPC.
Parameters: - mcc (int) – Country code.
- mnc (int) – Network code.
bbarchivist.pseudocap module¶
This module is the Python-ized implementation of cap.exe
-
bbarchivist.pseudocap.
ghetto_convert
(intsize)[source]¶ Convert from decimal integer to little endian hexadecimal string, padded to 16 characters with zeros.
Parameters: intsize (int) – Integer you wish to convert.
-
bbarchivist.pseudocap.
make_autoloader
(filename, firstfile, secondfile='', thirdfile='', fourthfile='', fifthfile='', sixthfile='', folder=None)[source]¶ Write cap.exe, magic offset, signed files to a .exe file.
make_offset()
is used to create the offset.Parameters: - filename (str) – Name of autoloader.
- firstfile (str) – First signed file. Required.
- secondfile (str) – Second signed file. Optional.
- thirdfile (str) – Third signed file. Optional.
- fourthfile (str) – Fourth signed file. Optional.
- fifthfile (str) – Fifth signed file. Optional.
- sixthfile (str) – Sixth signed file. Optional.
- folder (str) – Working folder. Optional. Default is local.
-
bbarchivist.pseudocap.
make_offset
(firstfile, secondfile=None, thirdfile=None, fourthfile=None, fifthfile=None, sixthfile=None, folder=None)[source]¶ Create magic offset file for use in autoloader creation. Cap.exe MUST match separator version. Version defined in
bbarchivist.bbconstants.CAPVERSION
.Parameters: - firstfile (str) – First signed file. Required.
- secondfile (str) – Second signed file. Optional.
- thirdfile (str) – Third signed file. Optional.
- fourthfile (str) – Fourth signed file. Optional.
- fifthfile (str) – Fifth signed file. Optional.
- sixthfile (str) – Sixth signed file. Optional.
- folder (str) – Working folder. Optional. Default is local.
bbarchivist.scriptutils module¶
This module contains various utilities for the scripts folder.
-
bbarchivist.scriptutils.
check_os_bulk
(osurls)[source]¶ Check existence of list of OS links.
Parameters: osurls (list(str)) – OS URLs to check.
-
bbarchivist.scriptutils.
check_os_single
(osurl, osversion, device)[source]¶ Check existence of single OS link.
Parameters: - radiourl (str) – Radio URL to check.
- radioversion (str) – Radio version.
- device (int) – Device family.
-
bbarchivist.scriptutils.
check_radio_bulk
(radiourls, radioversion)[source]¶ Check existence of list of radio links.
Parameters: - radiourls (list(str)) – Radio URLs to check.
- radioversion (str) – Radio version.
-
bbarchivist.scriptutils.
check_radio_single
(radiourl, radioversion)[source]¶ Check existence of single radio link.
Parameters: - radiourl (str) – Radio URL to check.
- radioversion (str) – Radio version.
-
bbarchivist.scriptutils.
check_radio_sw
(alturl, altsw, altchecked)[source]¶ Check existence of radio software release.
Parameters: - alturl (str) – Radio base URL (from http to hashed SW release).
- altsw (str) – Radio software release.
- altchecked (bool) – If we checked the sw release already.
-
bbarchivist.scriptutils.
check_sw
(baseurl, softwareversion, swchecked)[source]¶ Check existence of software release.
Parameters: - baseurl – Base URL (from http to hashed SW release).
- softwareversion (str) – Software release.
- swchecked (bool) – If we checked the sw release already.
-
bbarchivist.scriptutils.
default_parser
(name=None, desc=None)[source]¶ A generic form of argparse’s ArgumentParser.
-
bbarchivist.scriptutils.
enter_to_exit
(checkfreeze=True)[source]¶ Press enter to exit a script.
Parameters: checkfreeze (bool) – If we need to check if we’re frozen. Default is true.
-
bbarchivist.scriptutils.
get_sz_executable
(compmethod)[source]¶ Get 7z executable.
Parameters: compmethod (str) – Compression method.
-
bbarchivist.scriptutils.
return_radio_sw_checked
(altsw, radioversion)[source]¶ Check radio software existence, return boolean.
Parameters: - altsw (str) – Software release version.
- radioversion (str) – Radio version.
-
bbarchivist.scriptutils.
return_radio_version
(osversion, radioversion=None)[source]¶ Increment radio version, if need be.
Parameters: - osversion (str) – OS version.
- radioversion (str) – Radio version, None if incremented.
-
bbarchivist.scriptutils.
return_sw_checked
(softwareversion, osversion)[source]¶ Check software existence, return boolean.
Parameters: - softwareversion (str) – Software release version.
- osversion (str) – OS version.
-
bbarchivist.scriptutils.
test_bar_files
(localdir, urllist, download)[source]¶ Test bar files after download.
Parameters: - localdir (str) – Directory.
- urllist (list(str)) – List of URLs to check.
- download (bool) – If we downloaded these files ourselves.
-
bbarchivist.scriptutils.
test_loader_files
(localdir)[source]¶ Test loader files after creation.
Parameters: localdir (str) – Directory.
-
bbarchivist.scriptutils.
test_signed_files
(localdir)[source]¶ Test signed files after extract.
Parameters: localdir (str) – Directory.
bbarchivist.smtputils module¶
This module is used for dealing with SMTP email sending.
-
bbarchivist.smtputils.
generate_message
(body, username, subject)[source]¶ Generate message body/headers.
Parameters: - body (str) – Body of text.
- username (str) – Address to send to and from.
- subject (str) – Subject of message.
-
bbarchivist.smtputils.
generate_subject
(softwarerelease, osversion)[source]¶ Generate message subject.
Parameters: - softwarerelease (str) – Software version.
- osversion (str) – OS version.
-
bbarchivist.smtputils.
parse_kwargs
(kwargs)[source]¶ Extract variables from kwargs.
Parameters: - server (str) – SMTP email server.
- port (int) – Port to use.
- username (str) – Email address.
- password (str) – Email password, optional.
-
bbarchivist.smtputils.
prep_email
(osversion, softwarerelease, password=None)[source]¶ Bootstrap the whole process.
Parameters: - osversion (str) – OS version.
- softwarerelease (str) – Software version.
- password (str) – Email password. None to prompt later.
-
bbarchivist.smtputils.
send_email
(kwargs)[source]¶ Wrap email sending based on SSL/TLS.
Parameters: - server (str) – SMTP email server.
- port (int) – Port to use.
- username (str) – Email address.
- password (str) – Email password, optional.
- is_ssl (bool) – True if server uses SSL, False if TLS only.
- software (str) – Software release.
- os (str) – OS version.
- body (str) – Email message body.
-
bbarchivist.smtputils.
smtp_config_generator
(results)[source]¶ Take user input to create the SMTP configparser settings.
Parameters: results (dict) – The results to put in bbarchivist.ini.
-
bbarchivist.smtputils.
smtp_config_loader
(homepath=None)[source]¶ Read a ConfigParser file to get email preferences.
Parameters: homepath (str) – Folder containing ini file. Default is user directory.
-
bbarchivist.smtputils.
smtp_config_writer
(server=None, port=None, username=None, password=None, is_ssl=True, homepath=None)[source]¶ Write a ConfigParser file to store email server details.
Parameters: - server (str) – SMTP email server.
- port (int) – Port to use.
- username (str) – Email address.
- password (str) – Email password, optional.
- is_ssl (bool) – True if server uses SSL, False if TLS only.
- homepath (str) – Folder containing ini file. Default is user directory.
bbarchivist.sqlutils module¶
This module is used for dealing with SQL databases, including CSV export.
-
bbarchivist.sqlutils.
check_exists
(osversion, swrelease)[source]¶ Check if we did this one already.
Parameters: - osversion (str) – OS version.
- swrelease (str) – Software release.
-
bbarchivist.sqlutils.
insert
(osversion, swrelease, available, curdate=None)[source]¶ Insert values into main SQLite database.
Parameters: - osversion (str) – OS version.
- swrelease (str) – Software release.
- servers (str) – If release is available. String converted boolean.
- curdate (str) – If None, today. For manual dates, specify this.
bbarchivist.textgenerator module¶
This module is used for generation of URLs and related text files.
-
bbarchivist.textgenerator.
url_gen
(osversion, radioversion, softwareversion)[source]¶ Return all debrick, core and radio URLs from given OS, radio software.
Parameters: - softwareversion (str) – Software release version.
- osversion (str) – OS version.
- radioversion (str) – Radio version.
-
bbarchivist.textgenerator.
write_links
(softwareversion, osversion, radioversion, osurls, coreurls, radiourls, avlty=False, appendbars=False, appurls=None, temp=False)[source]¶ Write lookup links to file. Check for availability, can include app bars.
Parameters: - softwareversion (list) – Software release version.
- osversion (str) – OS version.
- radioversion (str) – Radio version.
- osurls (dict{str:str}) – Pre-formed debrick OS URLs.
- coreurls (dict{str:str}) – Pre-formed core OS URLs.
- radiourls (dict{str:str}) – Pre-formed radio URLs.
- avlty (bool) – Availability of links to download. Default is false.
- appendbars (bool) – Whether to add app bars to file. Default is false.
- appurls – App bar URLs to add.
- temp (bool) – If file we write to is temporary.
bbarchivist.utilities module¶
This module is used for miscellaneous utilities.
-
class
bbarchivist.utilities.
SpinManager
[source]¶ Bases:
object
Wraps around the itertools spinner, runs it in another thread.
-
class
bbarchivist.utilities.
Spinner
[source]¶ Bases:
object
A basic spinner using itertools. No need for progress.
-
class
bbarchivist.utilities.
UselessStdout
[source]¶ Bases:
object
A dummy IO stream. Does nothing, by design.
-
bbarchivist.utilities.
cappath_config_loader
(homepath=None)[source]¶ Read a ConfigParser file to get cap preferences.
Parameters: homepath (str) – Folder containing ini file. Default is user directory.
-
bbarchivist.utilities.
cappath_config_writer
(cappath=None, homepath=None)[source]¶ Write a ConfigParser file to store cap preferences.
Parameters: - cappath (str) – Method to use.
- homepath (str) – Folder containing ini file. Default is user directory.
-
bbarchivist.utilities.
escreens_duration
(duration)[source]¶ Check if Engineering Screens duration is valid.
Parameters: duration (int) – Duration to check.
-
bbarchivist.utilities.
escreens_pin
(pin)[source]¶ Check if given PIN is valid, raise argparse error if it isn’t.
Parameters: pin (str) – PIN to check.
-
bbarchivist.utilities.
file_exists
(file)[source]¶ Check if file exists, raise argparse error if it doesn’t.
Parameters: file (str) – Path to a file, including extension.
-
bbarchivist.utilities.
fsizer
(file_size)[source]¶ Raw byte file size to human-readable string.
Parameters: file_size (float) – Number to parse.
-
bbarchivist.utilities.
generate_lazy_urls
(baseurl, osversion, radioversion, device)[source]¶ Generate a pair of OS/radio URLs based on input.
Parameters: - baseurl (str) – The URL, from http to the hashed software release.
- osversion (str) – OS version.
- radioversion (str) – Radio version.
- device (int) – Device to use.
-
bbarchivist.utilities.
generate_urls
(baseurl, osversion, radioversion, core=False)[source]¶ Generate a list of OS URLs and a list of radio URLs based on input.
Parameters: - baseurl (str) – The URL, from http to the hashed software release.
- osversion (str) – OS version.
- radioversion (str) – Radio version.
- core (bool) – Whether or not to return core URLs as well.
-
bbarchivist.utilities.
get_seven_zip
(talkative=False)[source]¶ Return name of 7-Zip executable. On POSIX, it MUST be 7za. On Windows, it can be installed or supplied with the script.
win_seven_zip()
is used to determine if it’s installed.Parameters: talkative (bool) – Whether to output to screen. False by default.
-
bbarchivist.utilities.
grab_cap
()[source]¶ Figure out where cap is, local, specified or system-supplied.
-
bbarchivist.utilities.
increment
(version, inc=3)[source]¶ Increment version by given number. For repeated lookups.
Parameters: - version (str) – w.x.y.ZZZZ, becomes w.x.y.(ZZZZ+increment).
- inc (str) – What to increment by. Default is 3.
-
bbarchivist.utilities.
positive_integer
(input_int)[source]¶ Check if number > 0, raise argparse error if it isn’t.
Parameters: input_int (str) – Integer to check.
-
bbarchivist.utilities.
prep_seven_zip
(talkative=False)[source]¶ Check for presence of 7-Zip. On POSIX, check for p7zip. On Windows, check for 7-Zip.
Parameters: talkative (bool) – Whether to output to screen. False by default.
-
bbarchivist.utilities.
return_and_delete
(target)[source]¶ Read text file, then delete it. Return contents.
Parameters: target (str) – Text file to read.
-
bbarchivist.utilities.
s2b
(input_check)[source]¶ Return Boolean interpretation of string input.
Parameters: input_check (str) – String to check if it means True or False.
-
bbarchivist.utilities.
stripper
(name)[source]¶ Strip fluff from bar filename.
Parameters: name (str) – Bar filename, must contain ‘-nto+armle-v7+signed.bar’.
-
bbarchivist.utilities.
valid_carrier
(mcc_mnc)[source]¶ Check if MCC/MNC is valid (1-3 chars), raise argparse error if it isn’t.
Parameters: mcc_mnc (str) – MCC/MNC to check.
-
bbarchivist.utilities.
valid_method
(method)[source]¶ Check if compression method is valid, raise argparse error if it isn’t.
Parameters: method (str) – Compression method to check.
-
bbarchivist.utilities.
verify_bulk_loaders
(a_dir)[source]¶ Run
verify_loader_integrity()
for all files in a dir.Parameters: a_dir (str) – Directory to use.
-
bbarchivist.utilities.
verify_loader_integrity
(loaderfile)[source]¶ Test for created loader integrity. Windows-only.
Parameters: loaderfile (str) – Path to loader.
-
bbarchivist.utilities.
where_which
(path)[source]¶ Backwards compatibility wrapper for approximating which/where.
Module contents¶
The library portion of bbarchivist.