bbarchivist package

Submodules

bbarchivist.archiveutils module

This module is used to operate with archives.

bbarchivist.archiveutils.calculate_strength()[source]

Determine zip/gzip/bzip2 strength by OS bit setting.

bbarchivist.archiveutils.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.archiveutils.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.archiveutils.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.archiveutils.compressfilter(filepath, selective=False)[source]

Filter directory listing of working directory.

Parameters:
  • filepath (str) – Working directory. Required.
  • selective (bool/str) – Only compress autoloaders. Default is false.
bbarchivist.archiveutils.compressfilter_select(filepath, files, selective=False)[source]
Parameters:
  • filepath (str) – Working directory. Required.
  • files (list(str)) – List of files in filepath.
  • selective (bool/str) – Only compress autoloaders. Default is false.
bbarchivist.archiveutils.decide_verifier(file, szexe=None)[source]

Decide which verifier function to use.

Parameters:
  • file (str) – Filename.
  • szexe (str) – Path to 7z executable, if needed.
bbarchivist.archiveutils.decide_verifier_printer(file, verif)[source]

Print status of verifier function.

Parameters:
  • file (str) – Filename.
  • verif (bool) – If the file is OK or not.
bbarchivist.archiveutils.extract_android_tools(tooldir)[source]

Extract Android SDK platform tools archives.

Parameters:tooldir (str) – Directory containing platform tools zips.
bbarchivist.archiveutils.extract_zip(infile, outpath)[source]

Extract a zip file to a given output path.

Parameters:
  • infile (str) – Path to input zip file.
  • outpath (str) – Path to extract input zip to.
bbarchivist.archiveutils.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.archiveutils.filter_method_nosz(method, szexe=None)[source]

Make sure 7-Zip is OK.

Parameters:
  • method (str) – Compression method to use.
  • szexe (str) – Path to 7z executable, if needed.
bbarchivist.archiveutils.filter_with_boolfilt(files, criterion, critargs)[source]

Return everything that matches criterion.

Parameters:
  • files (list(str)) – Files to work on.
  • criterion (func) – Function to use for evaluation.
  • critargs (list) – Arguments for function, other than file.
bbarchivist.archiveutils.filter_without_boolfilt(files, criterion, critargs)[source]

Return everything that doesn’t match criterion.

Parameters:
  • files (list(str)) – Files to work on.
  • criterion (func) – Function to use for evaluation.
  • critargs (list) – Arguments for function, other than file.
bbarchivist.archiveutils.filtercomp(files, criterion, critargs, boolfilt=True)[source]
Parameters:
  • files (list(str)) – Files to work on.
  • criterion (func) – Function to use for evaluation.
  • critargs (list) – Arguments for function, other than file.
  • boolfilt (bool) – True if comparing criterion, False if comparing not criterion.
bbarchivist.archiveutils.generic_compresslevel(archivename, filename, method, strength=5)[source]

Pack a file into a gzip/bzip2 tarfile.

Parameters:
  • archivename (str) – Archive name.
  • filename (str) – Name of file to pack into archive.
  • method (str) – Tarfile compress method.
  • strength (int) – Compression strength. 5 is normal, 9 is ultra.
bbarchivist.archiveutils.generic_nocompresslevel(archivename, filename, method)[source]

Pack a file into an uncompressed/LZMA tarfile.

Parameters:
  • archivename (str) – Archive name.
  • filename (str) – Name of file to pack into archive.
  • method (str) – Tarfile compress method.
bbarchivist.archiveutils.generic_tarfile_compress(archivename, filename, method, strength=5)[source]

Pack a file into an uncompressed/gzip/bzip2/LZMA tarfile.

Parameters:
  • archivename (str) – Archive name.
  • filename (str) – Name of file to pack into archive.
  • method (str) – Tarfile compress method.
  • strength (int) – Compression strength. 5 is normal, 9 is ultra.
bbarchivist.archiveutils.generic_tarfile_verify(filepath, method)[source]

Verify that a tar/tgz/tbz/txz file is valid and working.

Parameters:
  • filepath (str) – Filename.
  • method (str) – Tarfile read method.
bbarchivist.archiveutils.pack_tclloader_zip(dirname, filename)[source]

Compress Android autoloader folder into a zip file.

Parameters:
  • dirname (str) – Target folder.
  • filename (str) – File title, without extension.
bbarchivist.archiveutils.prep_compress_function(method='7z', szexe=None, errors=False)[source]

Prepare compression function and partial arguments.

Parameters:
  • method (str) – Compression type. Default is “7z”.
  • szexe (str) – Path to 7z executable, if needed.
  • errors (bool) – Print completion status message. Default is false.
bbarchivist.archiveutils.smart_is_tarfile(filepath)[source]

tarfile.is_tarfile() plus error handling.

Parameters:filepath (str) – Filename.
bbarchivist.archiveutils.tar_verify(filepath)[source]

Verify that a tar file is valid and working.

Parameters:filepath (str) – Filename.
bbarchivist.archiveutils.tarzip_verifier(file)[source]

Assign .tar.xxx, .tar and .zip verifiers.

Parameters:file (str) – Filename.
bbarchivist.archiveutils.tbz_verify(filepath)[source]

Verify that a tar.bz2 file is valid and working.

Parameters:filepath (str) – Filename.
bbarchivist.archiveutils.tgz_verify(filepath)[source]

Verify that a tar.gz file is valid and working.

Parameters:filepath (str) – Filename.
bbarchivist.archiveutils.txz_verify(filepath)[source]

Verify that a tar.xz file is valid and working.

Parameters:filepath (str) – Filename.
bbarchivist.archiveutils.verify(filepath, method='7z', szexe=None, selective=False)[source]

Verify specific archive files in a given folder.

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 verify autoloaders. Default is false.
bbarchivist.archiveutils.verify_android_tools(tooldir)[source]

Verify Android SDK platform tools archives.

Parameters:tooldir (str) – Directory containing platform tools zips.
bbarchivist.archiveutils.zip_verify(filepath)[source]

Verify that a .zip file is valid and working.

Parameters:filepath (str) – Filename.

bbarchivist.argutils module

This module is used for argument utilities.

bbarchivist.argutils.arg_verify_none(argval, message)[source]

Check if an argument is None, error out if it is.

Parameters:
  • argval (str) – Argument to check.
  • message (str) – Error message to print.
bbarchivist.argutils.default_parser(name=None, desc=None, flags=None, vers=None)[source]

A generic form of argparse’s ArgumentParser.

Parameters:
  • name (str) – App name.
  • desc (str) – App description.
  • flags (tuple(str)) – Tuple of sections to add.
  • vers – Versions: [git commit hash, git commit date]
  • vers – list(str)
bbarchivist.argutils.default_parser_flags(parser, flags=None)[source]

Handle flags for default parser.

Parameters:
  • parser (argparse.ArgumentParser) – Parser to modify.
  • flags (tuple(str)) – Tuple of sections to add.
bbarchivist.argutils.default_parser_vers(vers=None)[source]

Prepare version for default parser.

Parameters:
  • vers – Versions: [git commit hash, git commit date]
  • vers – list(str)
bbarchivist.argutils.dpf_flags_folder(parser, flags=None)[source]

Add generic folder flag to parser.

Parameters:
  • parser (argparse.ArgumentParser) – Parser to modify.
  • flags (tuple(str)) – Tuple of sections to add.
bbarchivist.argutils.dpf_flags_osr(parser, flags=None)[source]

Add generic OS/radio/software flags to parser.

Parameters:
  • parser (argparse.ArgumentParser) – Parser to modify.
  • flags (tuple(str)) – Tuple of sections to add.
bbarchivist.argutils.droidlookup_devicetype(device)[source]

Check if Android autoloader device type is valid.

Parameters:device (str) – Android autoloader types to check.
bbarchivist.argutils.droidlookup_hashtype(method)[source]

Check if Android autoloader lookup hash type is valid.

Parameters:method (str) – None for regular OS links, “sha256/512” for SHA256 or 512 hash.
bbarchivist.argutils.escreens_duration(duration)[source]

Check if Engineering Screens duration is valid.

Parameters:duration (int) – Duration to check.
bbarchivist.argutils.escreens_pin(pin)[source]

Check if given PIN is valid, raise argparse error if it isn’t.

Parameters:pin (str) – PIN to check.
bbarchivist.argutils.external_version(parser, addition)[source]

Modify the version string of argparse.ArgumentParser, adding something.

Parameters:
  • parser (argparse.ArgumentParser) – Parser to modify.
  • addition (str) – What to add.
bbarchivist.argutils.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.argutils.generic_windows_shim(scriptname, scriptdesc, target, version)[source]

Generic CFP/CAP runner; Windows only.

Parameters:
  • scriptname (str) – Script name, ‘bb-something’.
  • scriptdesc (str) – Script description, i.e. scriptname -h.
  • target (str) – Path to file to execute.
  • version (str) – Version of target.
bbarchivist.argutils.longversion()[source]

Get long app version (Git tag + commits + hash).

bbarchivist.argutils.positive_integer(input_int)[source]

Check if number > 0, raise argparse error if it isn’t.

Parameters:input_int (str) – Integer to check.
bbarchivist.argutils.shortversion()[source]

Get short app version (Git tag).

bbarchivist.argutils.signed_file_args(files)[source]

Check if there are between 1 and 6 files supplied to argparse.

Parameters:files (list(str)) – List of signed files, between 1 and 6 strings.
bbarchivist.argutils.slim_preamble(appname)[source]

Standard app name header.

Parameters:appname (str) – Name of app.
bbarchivist.argutils.standard_preamble(appname, osversion, softwareversion, radioversion, altsw=None)[source]

Standard app name, OS, radio and software (plus optional radio software) print block.

Parameters:
  • appname (str) – Name of app.
  • osversion (str) – OS version, 10.x.y.zzzz. Required.
  • radioversion (str) – Radio version, 10.x.y.zzzz. Can be guessed.
  • softwareversion (str) – Software release, 10.x.y.zzzz. Can be guessed.
  • altsw (str) – Radio software release, if not the same as OS.
bbarchivist.argutils.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.argutils.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.argutils.valid_method_poptxz(methodlist)[source]

Remove .tar.xz support if system is too old.

Parameters:methodlist (tuple(str)) – List of all methods.

bbarchivist.barutils module

This module is used to operate with bar files.

bbarchivist.barutils.atomic_move(infile, outdir)[source]

Move file to given folder, removing if things break.

Parameters:
  • infile (str) – Path to file to move.
  • outdir (str) – Directory to move to.
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.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.dirsizer(file, osdir, raddir, maxsize=90000000)[source]

Return output directory based in input filesize.

Parameters:
  • file (str) – The file to sort. Absolute paths, please.
  • osdir (str) – Large file destination.
  • raddir (str) – Small file destination.
  • maxsize (int) – Return osdir if filesize > maxsize else raddir. Default is 90MB.
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.extract_individual_bar(file, filepath)[source]

Generate bar file contents and extract signed files.

Parameters:
  • file (str) – Bar file to extract.
  • filepath (str) – Path to bar file directory.
bbarchivist.barutils.extract_signed_file(zfile, names, filepath)[source]

Extract signed file from a provided bar.

Parameters:
  • zfile (zipfile.ZipFile) – Open (!!!) ZipFile instance.
  • names (list(str)) – List of bar file contents.
  • filepath (str) – Path to bar file directory.
bbarchivist.barutils.get_sha512_from_manifest(manf)[source]

Retrieve asset name and hash from MANIFEST.MF file.

Parameters:manf (list(bytes)) – Content of MANIFEST.MF file, in bytes.
bbarchivist.barutils.get_sha512_manifest(zfile)[source]

Get MANIFEST.MF from a bar file.

Parameters:zfile (zipfile.ZipFile) – Open (!!!) ZipFile instance.
bbarchivist.barutils.indiv_folder_remove(curdir, subdirs, files)[source]

Remove a folder if it’s empty, the actual function.

Parameters:
  • curdir (str) – Target folder.
  • subdirs (list(str)) – Subdirectories inside target folder.
  • files (list(str)) – Files inside target folder.
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_dirpairs(localdir, root, osversion, radioversion)[source]

Create a pair of directories, with OS/radio versions for names.

Parameters:
  • localdir (str) – Top level folder.
  • root (str) – Name for folder containing OS/radio pairs.
  • osversion (str) – OS version.
  • radioversion (str) – Radio version.
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.make_folder(localdir, root)[source]

Make a folder if it doesn’t exist.

Parameters:
  • localdir (str) – Top level folder.
  • root (str) – Folder to create.
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_loader_pairs(files, dir_os, dir_rad)[source]

Move autoloaders to zipped/loaders directories.

Parameters:
  • files (list(str)) – List of autoloader files.
  • dir_os (str) – Large autoloader destination.
  • dir_rad (str) – Small autoloader destination.
bbarchivist.barutils.move_loaders(ldir, exedir_os, exedir_rad, zipdir_os, zipdir_rad)[source]

Move autoloaders to zipped and loaders directories in localdir.

Parameters:
  • ldir (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.move_loaders_prep(ldir, suf)[source]

Prepare a list of filenames for moving loaders.

Parameters:
  • ldir (str) –
  • suf (str or list or tuple) – Suffix(es) to check.
bbarchivist.barutils.persistent_move(infile, outdir)[source]

Move file to given folder, removing file if it exists in folder.

Parameters:
  • infile (str) – Path to file to move.
  • outdir (str) – Directory to move to.
bbarchivist.barutils.persistent_remove(afile)[source]

Remove a file, and if it doesn’t want to remove, keep at it.

Parameters:afile (str) – Path to file you want terminated with extreme prejudice.
bbarchivist.barutils.remove_empty_folder(curdir, subdirs, files)[source]

Remove a folder if it’s empty.

Parameters:
  • curdir (str) – Target folder.
  • subdirs (list(str)) – Subdirectories inside target folder.
  • files (list(str)) – Files inside target folder.
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.replace_bar_pair(localdir, osfile, radfile)[source]

Move pair of OS and radio bars to a given folder.

Parameters:
  • localdir (str) – Final bar directory.
  • osfile (str) – Path to OS file.
  • radfile (str) – Path to radio file.
bbarchivist.barutils.replace_bars_bulk(localdir, barfiles)[source]

Move set of OS and radio bars to a given folder.

Parameters:
  • localdir (str) – Final bar directory.
  • barfiles (list(str)) – List of OS/radio file paths.
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.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', '.tar', '.zip', '.txz', '.tbz', '.tgz', '.bar')

Archive files.

bbarchivist.bbconstants.ARCSPLUS = ('.7z', '.tar.xz', '.tar.bz2', '.tar.gz', '.zip', '.tar', '.exe')

Archive files plus executables.

bbarchivist.bbconstants.CAP = <bbarchivist.bbconstants.Datafile object>

CAP

bbarchivist.bbconstants.CFP = <bbarchivist.bbconstants.Datafile object>

CFP

bbarchivist.bbconstants.COMMITDATE = '2018-12-01T17:32:50-0400'

Git commit timestamp.

bbarchivist.bbconstants.COMMITHASH = 'g72461dc'

Git commit hash.

bbarchivist.bbconstants.DEVICES = ('STL100-1', 'STL100-2/3/P9982', 'STL100-4', 'Q10/Q5/P9983', 'Z30/CLASSIC/LEAP', 'Z3', 'PASSPORT')

Devices.

bbarchivist.bbconstants.DIRECTORY = '/home/docs/checkouts/readthedocs.org/user_builds/bbarchivist/envs/latest/lib/python3.5/site-packages/bbarchivist-3.9.0-py3.5.egg/bbarchivist'

File folder.

bbarchivist.bbconstants.DIRTY = '+devel'

If we’re in a development build.

class bbarchivist.bbconstants.Datafile(version, datatype, size)[source]

Bases: object

Structure for information about a data file included with this app.

bbarchivist.bbconstants.FLASHBAT = <bbarchivist.bbconstants.Datafile object>

flashall.bat.dat

bbarchivist.bbconstants.FLASHBATBBF = <bbarchivist.bbconstants.Datafile object>

flashallbbf.bat.dat

bbarchivist.bbconstants.FLASHSH = <bbarchivist.bbconstants.Datafile object>

flashall.sh.dat

bbarchivist.bbconstants.FLASHSHBBF = <bbarchivist.bbconstants.Datafile object>

flashallbbf.sh.dat

bbarchivist.bbconstants.JSONDIR = '/home/docs/checkouts/readthedocs.org/user_builds/bbarchivist/envs/latest/lib/python3.5/site-packages/bbarchivist-3.9.0-py3.5.egg/bbarchivist/json'

JSON storage directory.

bbarchivist.bbconstants.LOCATION = '/home/docs/checkouts/readthedocs.org/user_builds/bbarchivist/envs/latest/lib/python3.5/site-packages/bbarchivist-3.9.0-py3.5.egg/bbarchivist/bbconstants.py'

File location.

bbarchivist.bbconstants.LONGVERSION = '3.9.0+devel-g72461dc'

App version, tag + commits.

bbarchivist.bbconstants.METHODS = ('7z', 'tbz', 'tgz', 'zip', 'txz', 'tar')

Compression methods.

bbarchivist.bbconstants.PREFIXES = ('Q10', 'Z10', 'Z30', 'Z3', 'Passport')

Autoloader/archive filename beginnings.

bbarchivist.bbconstants.SERVERS = {'a1': 'https://alpha.sl.eval.blackberry.com/slscse/srVersionLookup/2.0.0/', 'a2': 'https://alpha2.sl.eval.blackberry.com/slscse/srVersionLookup/2.0.0/', '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/'}

Lookup server list.

bbarchivist.bbconstants.SUPPS = ('.asc', '.cksum')

Support files.

bbarchivist.bbconstants.TCLMASTERS = ('g2master-us-east.tctmobile.com', 'g2master-us-west.tctmobile.com', 'g2master-eu-west.tctmobile.com', 'g2master-ap-south.tctmobile.com', 'g2master-ap-north.tctmobile.com', 'g2master-sa-east.tctmobile.com')

Master servers.

bbarchivist.bbconstants.VERSION = '3.9.0'

App version.

bbarchivist.bbconstants.frozen_versions()[source]

Version grabbing when frozen with cx_Freeze.

bbarchivist.compat module

This module is used for backwards compatibility for older Python 3.

bbarchivist.compat.enum_cpus()[source]

Backwards compatibility wrapper for CPU count.

bbarchivist.compat.perf_clock()[source]

Backwards compatibility wrapper for system clock.

bbarchivist.compat.where_which(path)[source]

Backwards compatibility wrapper for approximating which/where.

Parameters:path (str) – Path to a file.

bbarchivist.decorators module

This module is used for decorators.

bbarchivist.decorators.enter_to_exit(checkfreeze=True)[source]

Press enter to exit a script.

Parameters:checkfreeze (bool) – If this triggers only in frozen executables. Default is true.
bbarchivist.decorators.sql_excepthandler(integrity)[source]

Decorator to handle sqlite3.Error.

Parameters:integrity (bool) – Whether to allow sqlite3.IntegrityError.
bbarchivist.decorators.sql_exceptwrapper(method, integrity, *args, **kwargs)[source]

Try function, handle sqlite3.Error, optionally pass sqlite3.IntegrityError.

Parameters:
  • method (function) – Method to use.
  • integrity (bool) – Whether to allow sqlite3.IntegrityError.
bbarchivist.decorators.sql_existhandler(sqlpath)[source]

Decorator to check if SQL database exists.

Parameters:sqlpath (str) – Path to SQL database.
bbarchivist.decorators.timer(method)[source]

Decorator to time a function.

Parameters:method (function) – Method to time.
bbarchivist.decorators.wrap_keyboard_except(method)[source]

Decorator to absorb KeyboardInterrupt.

Parameters:method (function) – Method to use.

bbarchivist.dummy module

This module is used for dummy exceptions, stdout, etc.

class bbarchivist.dummy.UselessStdout[source]

Bases: object

A dummy IO stream. Does nothing, by design.

static flush()[source]

Do nothing.

static isatty()[source]

Convince module we’re in a terminal.

static write(inp)[source]

Do nothing.

bbarchivist.exceptions module

This module is used to handle/provide exceptions.

exception bbarchivist.exceptions.DummyException[source]

Bases: Exception

Exception that is not raised at all.

bbarchivist.exceptions.handle_exception(exc, msg='SOMETHING WENT WRONG', xit=<class 'SystemExit'>)[source]

Print msg, then text of exception exc, then raise exception xit.

Parameters:
  • exc (Exception) – Exception to handle.
  • msg (str) – Message to raise, “SOMETHING WENT WRONG” by default.
  • xit (Exception) – Exception to raise upon exit, SystemExit by default.

bbarchivist.gpgutils module

This module is used to generate file PGP signatures.

bbarchivist.gpgutils.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.gpgutils.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.gpgutils.gpg_prepends(file, selective=False)[source]

Check if file matches certain criteria.

Parameters:
  • file (str) – File inside workingdir that is being verified.
  • selective (bool) – Filtering filenames/extensions. Default is false.
bbarchivist.gpgutils.gpg_supps(selective=False)[source]

Prepare list of support files.

Parameters:selective (bool) – Filtering filenames/extensions. Default is false.
bbarchivist.gpgutils.gpgfile(filepath, gpginst, key=None, pword=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.
  • key (str) – Key ID. 0xABCDEF01
  • pword (str) – Passphrase for key.
bbarchivist.gpgutils.gpgrunner(workingdir, keyid=None, pword=None, selective=False)[source]

Create ASCII-armored PGP signatures for all files in a given directory, in parallel.

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.gpgutils.gpgrunner_clean(gpg, workingdir, keyid=None, pword=None, selective=False)[source]

Run GPG signature generation after filtering out errors.

Parameters:
  • gpg (gnupg.GPG()) – Instance of Python GnuPG executable.
  • 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.gpgutils.gpgwriter(gpg, xec, file, workingdir, selective=False, keyid=None, pword=None)[source]

Write individual GPG signatures.

Parameters:
  • gpg (gnupg.GPG()) – Instance of Python GnuPG executable.
  • xec (concurrent.futures.ThreadPoolExecutor) – ThreadPoolExecutor instance.
  • file (str) – File inside workingdir that is being verified.
  • workingdir (str) – Path containing files you wish to verify.
  • selective (bool) – Filtering filenames/extensions. Default is false.
  • keyid (str) – Key to use. 8-character hexadecimal, with or without 0x.
  • pword (str) – Passphrase for given key.
bbarchivist.gpgutils.gpgwriter_clean(gpg, xec, file, workingdir, keyid=None, pword=None)[source]

Write individual GPG signatures after filtering file list.

Parameters:
  • gpg (gnupg.GPG()) – Instance of Python GnuPG executable.
  • xec (concurrent.futures.ThreadPoolExecutor) – ThreadPoolExecutor instance.
  • file (str) – File inside workingdir that is being verified.
  • 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.
bbarchivist.gpgutils.prep_gpgkeyid(keyid=None)[source]

Prepare GPG key ID.

Parameters:keyid (str) – Key to use. 8-character hexadecimal, with or without 0x.
bbarchivist.gpgutils.prep_gpgrunner(workingdir, keyid=None)[source]

Prepare key and files for gpgrunner function.

Parameters:
  • workingdir (str) – Path containing files you wish to verify.
  • keyid (str) – Key to use. 8-character hexadecimal, with or without 0x.

bbarchivist.hashutils module

This module is used to generate file hashes/checksums.

bbarchivist.hashutils.base_hash(hashtype, source, workingdir, block, target, kwargs=None)[source]

Generic hash function; get hash, write to file.

Parameters:
  • hashtype (str) – Hash type.
  • source (str) – File to be hashed; foobar.ext
  • workingdir (str) – Path containing files you wish to verify.
  • block (int) – Blocksize, in bytes.
  • target (file) – File to write to.
  • kwargs (dict) – Values. Refer to :func:verifier_config_loader.
bbarchivist.hashutils.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.hashutils.filefilter(file, workingdir, extras=())[source]

Check if file in folder is a folder, or if it’s got a forbidden extension.

Parameters:
  • file (str) – File to be hashed.
  • workingdir (str) – Path containing files you wish to verify.
  • extras (tuple) – Tuple of extra extensions.
bbarchivist.hashutils.get_engine(hashtype)[source]

Get hashlib engine from hash type.

Parameters:hashtype (str) – Hash type.
bbarchivist.hashutils.get_hashfunc(hashtype)[source]

Get genericized hash function from hash type.

Parameters:hashtype (str) – Hash type.
bbarchivist.hashutils.hash_get(filename, hashfunc, hashtype, 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.
  • hashtype (str) – Hash type.
  • workingdir (str) – Working directory.
  • blocksize (int) – Block size. Default is 16MB.
bbarchivist.hashutils.hash_writer(source, dest, workingdir, kwargs=None)[source]

Write per-file hashes.

Parameters:
  • source (str) – File to be hashed; foobar.ext
  • dest (str) – Destination file; foobar.ext.cksum
  • workingdir (str) – Path containing files you wish to verify.
  • kwargs (dict) – Values. Refer to :func:verifier_config_loader.
bbarchivist.hashutils.hashfunc_reader(filepath, engine, blocksize=16777216)[source]

Generate hash from file contents.

Parameters:
  • filepath (str) – File you wish to verify.
  • engine (_hashlib.HASH) – Hash object to update with file contents.
  • blocksize (int) – How much of file to read at once. Default is 16MB.
bbarchivist.hashutils.hashlib_hash(filepath, engine, blocksize=16777216)[source]

Return MD5/SHA-1/SHA-2/SHA-3 hash of a file.

Parameters:
  • filepath (str) – File you wish to verify.
  • engine (_hashlib.HASH) – Hash object to update with file contents.
  • blocksize (int) – How much of file to read at once. Default is 16MB.
bbarchivist.hashutils.prep_verifier(ldir, selective=False)[source]

Prepare files for verifier function.

Parameters:
  • ldir (str) – Path containing files you wish to verify.
  • selective (bool) – Filtering filenames/extensions. Default is false.
bbarchivist.hashutils.ssl_hash(filepath, method, blocksize=16777216)[source]

Return SSL-library dependent hash of a file.

Parameters:
  • filepath (str) – File you wish to verify.
  • method (str) – Method to use: algorithms in hashlib that are not guaranteed.
  • blocksize (int) – How much of file to read at once. Default is 16MB.
bbarchivist.hashutils.verifier(ldir, kwargs=None, selective=False)[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:
  • ldir (str) – Path containing files you wish to verify.
  • kwargs (dict) – Values. Refer to :func:verifier_config_loader.
  • selective (bool) – Filtering filenames/extensions. Default is false.
bbarchivist.hashutils.verifier_config_loader(homepath=None)[source]

Read a ConfigParser file to get hash preferences.

Parameters:homepath (str) – Folder containing ini file. Default is user directory.
bbarchivist.hashutils.verifier_config_writer(resultdict=None, homepath=None)[source]

Write a ConfigParser file to store hash preferences.

Parameters:
  • resultdict (dict({str, bool})) – Dictionary of results: {method, bool}
  • homepath (str) – Folder containing ini file. Default is user directory.
bbarchivist.hashutils.verifier_individual(xec, ldir, file, kwargs)[source]

Individually verify files through a ThreadPoolExecutor.

Parameters:
  • xec (concurrent.futures.ThreadPoolExecutor) – ThreadPoolExecutor instance.
  • ldir (str) – Path containing files you wish to verify.
  • file (str) – Filename.
  • kwargs (dict) – Values. Refer to :func:verifier_config_loader.
bbarchivist.hashutils.zlib_handler(method)[source]

Prepare hash method and seed depending on CRC32/Adler32.

Parameters:method (str) – “crc32” or “adler32”.
bbarchivist.hashutils.zlib_hash(filepath, method, blocksize=16777216)[source]

Return zlib-based (i.e. CRC32/Adler32) checksum of a file.

Parameters:
  • filepath (str) – File you wish to verify.
  • method (str) – “crc32” or “adler32”.
  • blocksize (int) – How much of file to read at once. Default is 16MB.

bbarchivist.iniconfig module

This module is used for generic configuration parsing.

bbarchivist.iniconfig.conditional_move(oldfile, newfile)[source]

Migrate from user directory to dedicated appdata/.local dir.

Parameters:
  • oldfile (str) – Path to old config file.
  • newfile (str) – Path to new config file.
bbarchivist.iniconfig.config_conffile(conffile)[source]

Create ini file if it doesn’t exist.

Parameters:conffile (str) – Path to config ini file.
bbarchivist.iniconfig.config_emptysection(config, section)[source]

Create empty configuration section.

Parameters:
  • config (configparser.ConfigParser) – Configuration dictionary.
  • section (str) – Section of ini file to return.
bbarchivist.iniconfig.config_homepath(homepath, logpath=False, cachepath=False)[source]

Fix path for ini file.

Parameters:
  • homepath (str) – Path to ini file.
  • logpath (bool) – True if processing log folder, False if not. Default is False.
  • cachepath (bool) – True if processing cache folder, False if not. Default is False.
bbarchivist.iniconfig.config_location(homepath=None)[source]

Return config location.

Parameters:homepath (str) – Folder containing ini file. Default is user directory.
bbarchivist.iniconfig.config_rawdir(logpath=False, cachepath=False)[source]

Get new config dir.

Parameters:
  • logpath (bool) – True if processing log folder, False if not. Default is False.
  • cachepath (bool) – True if processing cache folder, False if not. Default is False.
bbarchivist.iniconfig.generic_loader(section, homepath=None)[source]

Read a ConfigParser file, return section.

Parameters:
  • section (str) – Section of ini file to return.
  • homepath (str) – Folder containing ini file. Default is user directory.
bbarchivist.iniconfig.generic_preamble(section, homepath=None)[source]

Read a ConfigParser file, return whole config.

Parameters:
  • section (str) – Section of ini file to return.
  • homepath (str) – Folder containing ini file. Default is user directory.
bbarchivist.iniconfig.generic_writer(section, resultdict, homepath=None)[source]

Write a ConfigParser file.

Parameters:
  • section (str) – Section of ini file to write.
  • resultdict (dict({str, bool})) – Dictionary of configs: {key: value}
  • homepath (str) – Folder containing ini file. Default is user directory.
bbarchivist.iniconfig.log_move(olddir, homepath)[source]

Migrate logs from user directory subfolder to dedicated appdata/.local dir.

Parameters:
  • olddir (str) – Path to old log dir.
  • homepath (str) – Path to new log directory.
bbarchivist.iniconfig.migrate_files(homepath)[source]

Prepare ini file and SQL DB for new homepath.

Parameters:homepath (str) – Path to data directory.
bbarchivist.iniconfig.migrate_logs(homepath)[source]

Prepare log directory for new homepath.

Parameters:homepath (str) – Path to data directory.
bbarchivist.iniconfig.process_homepath(homepath, logpath=False, cachepath=False)[source]

Prepare homepath if it doesn’t exist.

Parameters:
  • homepath (str) – Path to data directory.
  • logpath (bool) – True if processing log folder, False if not. Default is False.
  • cachepath (bool) – True if processing cache folder, False if not. Default is False.

bbarchivist.jsonutils module

This module is used for JSON tools.

bbarchivist.jsonutils.certchecker_prep(table, device)[source]

Extract model, family and HWID from a device table.

Parameters:
  • table (list(dict)) – List of device entries.
  • device (str) – HWID, FCCID or name of device.
bbarchivist.jsonutils.extract_cert(table, device)[source]

Extract PTCRB info from a list of dicts.

Parameters:
  • table (list(dict)) – List of device entries.
  • device (str) – HWID, FCCID or name of device.
bbarchivist.jsonutils.extract_cert_check(key, device, not_secret)[source]

Check function for extracting PTCRB info.

Parameters:
  • key (dict) – Device entry.
  • device (str) – HWID, FCCID or name of device.
  • not_secret (bool) – If device is not market as secret.
bbarchivist.jsonutils.extract_cert_secret(key, device)[source]

Check if device is marked as secret.

Parameters:
  • key (dict) – Device entry.
  • device – HWID, FCCID or name of device.
  • device – str
bbarchivist.jsonutils.fubar(message)[source]

What to do when things go bad.

Parameters:message (str) – Error message.
bbarchivist.jsonutils.grab_json(filename)[source]

Figure out where JSON is, local or system-supplied.

Parameters:filename (str) – Desired JSON database name.
bbarchivist.jsonutils.list_available_certs(table)[source]

List all certified devices in a device table.

Parameters:table (list(dict)) – List of device entries.
bbarchivist.jsonutils.list_devices(table)[source]

List all devices, certified or not, in a device table.

Parameters:table (list(dict)) – List of device entries.
bbarchivist.jsonutils.list_family(table)[source]

List all valid (certified) families in a device table.

Parameters:table (list(dict)) – List of device entries.
bbarchivist.jsonutils.list_prds(table)[source]

List all PRDs in a PRD table.

Parameters:table (dict(str: list)) – Dictionary of device : PRD list pairs.
bbarchivist.jsonutils.load_json(table, jfile=None)[source]

Load JSON file, return specific table (dict or list).

Parameters:
  • table (str) – Name of sub-structure to return.
  • jfile (str) – Path to JSON file.
bbarchivist.jsonutils.read_family(table, device)[source]

Get all devices of a given family in a device table.

Parameters:
  • table (list(dict)) – List of device entries.
  • device (str) – HWID, FCCID or name of device.

bbarchivist.loadergen module

This module is used for creation of autoloaders.

bbarchivist.loadergen.find_signed_file(match, localdir, title, silent=False)[source]

Use pattern matching to find a signed file in a directory.

Parameters:
  • match (str) – Match pattern to use.
  • localdir (str) – Directory to use.
  • title (str) – File type, in case it isn’t found.
  • silent (bool) – Don’t print that a file wasn’t found. Default is False.
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_individual_loaders(filtrad, osversion, radioversion, suffix, filedict, radios, localdir)[source]

Generate individual loaders when generating several at once.

Parameters:
  • filtrad (list(str)) – List of radio files, if they exist.
  • osversion (str) – OS version, 10.x.y.zzzz.
  • radioversion (str) – Radio version, 10.x.y.zzzz.
  • suffix (str) – Alternate radio, or blank.
  • filedict (dict(str: str)) – Dictionary of radio:OS pairs.
  • radios (bool) – Whether to make radios or not. True by default.
  • localdir (str) – Working path. Default is local dir.
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_lazy_set(osversion, device, osfile, suffix, absoglob, localdir=None)[source]

Get radio file and then generate autoloader.

Parameters:
  • osversion (str) – OS version, 10.x.y.zzzz.
  • device (int) – Selected device, from
  • osfile (str) – OS signed filename.
  • suffix (str) – Loader name suffix.
  • absoglob (str) – Local path + path separator.
  • localdir (str) – Working path. Default is local dir.
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_os_fixes(core=False)[source]

Generate name regexes for OS signed files.

Parameters: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.versionpad(splitver)[source]

Properly pad an OS/radio version.

Parameters:splitver (list(str)) – OS/radio version, but split into quarters.
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.loadergen.zeropad(splitver, idx, padlen)[source]

Zero-pad an element of an OS/radio version to a certain length.

Parameters:
  • splitver (list(str)) – OS/radio version, but split into quarters.
  • idx (int) – Index of splitver which must be checked.
  • padlen (int) – Length to pad to.

bbarchivist.loadergentcl module

This module is used for creation of TCL autoloaders.

bbarchivist.loadergentcl.generate_google_host(hostin, hostout)[source]

Generate host directory from Google platform tools, i.e. fastboot.

Parameters:
  • hostin (str) – Directory containing files to copy.
  • hostout (str) – Directory that files are to be copied to.
bbarchivist.loadergentcl.generate_tclloader(localdir, dirname, platform, localtools=False, wipe=True)[source]

Generate Android loader from extracted template files.

Parameters:
  • localdir (str) – Directory containing extracted template files.
  • dirname (str) – Name for final directory and loader.
  • platform (str) – Platform type (i.e. subdirectory of target/product).
  • localtools (bool) – If host files will be copied from a template rather than a download. Default is False.
  • wipe (bool) – If the final loader wipes userdata. Default is True.
bbarchivist.loadergentcl.generate_tclloader_carriers(sigin, sigout)[source]

Collect carrier variant signature files.

Parameters:
  • sigin (str) – Directory containing files to copy.
  • sigout (str) – Directory that files are to be copied to.
bbarchivist.loadergentcl.generate_tclloader_carriter(sigin, sigout, prods)[source]

Iterate carrier variant signature files.

Parameters:
  • sigin (str) – Directory containing files to copy.
  • sigout (str) – Directory that files are to be copied to.
  • prods (set(str)) – Set of carriers.
bbarchivist.loadergentcl.generate_tclloader_csig(sigin, sigout, carrier)[source]

Generate carrier variant signature files.

Parameters:
  • sigin (str) – Directory containing files to copy.
  • sigout (str) – Directory that files are to be copied to.
  • carrier (str) – Carrier to check: att, sprint, china, vzw
bbarchivist.loadergentcl.generate_tclloader_deps(platform)[source]

Generate platform-specific file names.

Parameters:platform (str) – Platform type (i.e. subdirectory of target/product).
bbarchivist.loadergentcl.generate_tclloader_host(hostin, hostout)[source]

Generate host directory from autoloader template, i.e. fastboot.

Parameters:
  • hostin (str) – Directory containing files to copy.
  • hostout (str) – Directory that files are to be copied to.
bbarchivist.loadergentcl.generate_tclloader_img(imgin, imgout, platform)[source]

Generate partition images and radios.

Parameters:
  • imgin (str) – Directory containing files to copy.
  • imgout (str) – Directory that files are to be copied to.
  • platform (str) – Platform type (i.e. subdirectory of target/product).
bbarchivist.loadergentcl.generate_tclloader_looseends(imgout, platform)[source]

Handle files that need to be handled.

Parameters:
  • imgout (str) – Directory that files are to be copied to.
  • platform (str) – Platform type (i.e. subdirectory of target/product).
bbarchivist.loadergentcl.generate_tclloader_mbn(mbnin, mbnout, platform)[source]

Generate mbn files.

Parameters:
  • mbnin (str) – Directory containing files to copy.
  • mbnout (str) – Directory that files are to be copied to.
  • platform (str) – Platform type (i.e. subdirectory of target/product).
bbarchivist.loadergentcl.generate_tclloader_oemfilt(oemin, oems)[source]

Filter non-existent OEM variants.

Parameters:
  • oemin (str) – Directory containing files to copy.
  • oems (list(str)) – List of OEM variants.
bbarchivist.loadergentcl.generate_tclloader_oemset(oemin, oems)[source]

Generate sets for OEM variants.

Parameters:
  • oemin (str) – Directory containing files to copy.
  • oems (list(str)) – List of OEM variants.
bbarchivist.loadergentcl.generate_tclloader_omniset(omnin, omnilist, prefix, suffix, filt)[source]

Generic function to generate sets.

Parameters:
  • omnin (str) – Directory containing files to copy.
  • omnilist (list(str)) – List of variants.
  • prefix (str) – Prefix, before items in list.
  • suffix (str) – Suffix, after items in list.
  • filt (str) – Filter, required to pick file out of directory listing.
bbarchivist.loadergentcl.generate_tclloader_platimg(platform)[source]

Generate platform-specific .img files.

Parameters:platform (str) – Platform type (i.e. subdirectory of target/product).
bbarchivist.loadergentcl.generate_tclloader_platmbn(platform)[source]

Generate platform-specific MBN files.

Parameters:platform (str) – Platform type (i.e. subdirectory of target/product).
bbarchivist.loadergentcl.generate_tclloader_platother(platform)[source]

Generate platform-specific other files.

Parameters:platform (str) – Platform type (i.e. subdirectory of target/product).
bbarchivist.loadergentcl.generate_tclloader_radfilt(radin, rads)[source]

Filter non-existent radio variants.

Parameters:
  • radin (str) – Directory containing files to copy.
  • rads (list(str)) – List of radio variants.
bbarchivist.loadergentcl.generate_tclloader_radset(radin, rads)[source]

Generate sets for radio variants.

Parameters:
  • radin (str) – Directory containing files to copy.
  • rads (list(str)) – List of radio variants.
bbarchivist.loadergentcl.generate_tclloader_script(dirname, batchfile, shfile, wipe=True)[source]

Copy script files from site-packages to loader directory.

Parameters:
  • dirname (str) – Name for final directory and loader.
  • batchfile (str) – Path to flashall.bat.
  • shfile (str) – Path to flashall.sh.
  • wipe (bool) – If the final loader wipes userdata. Default is True.
bbarchivist.loadergentcl.generate_tclloader_scripttype(platform)[source]

Get the right scripts for the right platform.

Parameters:platform (str) – Platform type (i.e. subdirectory of target/product).
bbarchivist.loadergentcl.generate_tclloader_sig(sigin, sigout)[source]

Generate common signature files.

Parameters:
  • sigin (str) – Directory containing files to copy.
  • sigout (str) – Directory that files are to be copied to.
bbarchivist.loadergentcl.looseends_krypton(imgout)[source]

Handle files that need to be handled, for the Motion platform.

Parameters:imgout (str) – Directory that files are to be copied to.
bbarchivist.loadergentcl.point_point_bulk(inpath, outpath, files)[source]

Copy a list of files from one absolute path to another.

Parameters:
  • inpath (str) – Input path.
  • outpath (str) – Output path.
  • files (list(str)) – List of filenames.
bbarchivist.loadergentcl.point_point_copy(inpath, outpath, filename)[source]

Copy a file from one absolute path to another.

Parameters:
  • inpath (str) – Input path.
  • outpath (str) – Output path.
  • filename (str) – Filename.
bbarchivist.loadergentcl.tclloader_nowipe(infile)[source]

Modify a script file to strike references to wiping the phone.

Parameters:infile (str) – Path to script file to modify.

bbarchivist.networkutils module

This module is used for network connections; APIs, downloading, etc.

bbarchivist.networkutils.availability(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.available_bundle_lookup(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.base_metadata(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.base_metadata_url(alternate=None)[source]

Return metadata URL.

Parameters:alternate (str) – If the URL is for the simulator metadata. Default is False.
bbarchivist.networkutils.bulk_droid_skeletons(devs, build, method=None)[source]

Prepare list of Android autoloader/hash URLs.

Parameters:
  • devs (list(str)) – List of devices.
  • build (str) – Build to check, 3 letters + 3 numbers.
  • method (str) – None for regular OS links, “sha256/512” for SHA256 or 512 hash.
bbarchivist.networkutils.carrier_checker(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.carrier_query(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.chunker(iterable, inc)[source]

Convert an iterable into a list of inc sized lists.

Parameters:
  • iterable (list/tuple/string) – Iterable to chunk.
  • inc (int) – Increment; how big each chunk is.
bbarchivist.networkutils.clean_availability(results, server)[source]

Clean availability for autolookup script.

Parameters:
  • results (dict(str: str)) – Result dict.
  • server (str) – Server, key for result dict.
bbarchivist.networkutils.dev_dupe_cleaner(finals)[source]

Clean duplicate autoloader entries.

Parameters:finals (dict(str: str)) – Dict of URL:content-length pairs.
bbarchivist.networkutils.dev_dupe_dicter(finals)[source]

Prepare dictionary to clean duplicate autoloaders.

Parameters:finals (dict(str: str)) – Dict of URL:content-length pairs.
bbarchivist.networkutils.dev_dupe_remover(finals, dupelist)[source]

Filter dictionary of autoloader entries.

Parameters:
  • finals (dict(str: str)) – Dict of URL:content-length pairs.
  • dupelist – List of duplicate URLs.
bbarchivist.networkutils.devalpha_urls(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.devalpha_urls_bootstrap(osversion, skeletons, session=None)[source]

Get list of valid Dev Alpha autoloader URLs.

Parameters:
  • osversion (str) – OS version.
  • skeletons (list) – List of skeleton formats to try.
  • session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.devalpha_urls_bulk(osversion, skeletons, xec, session=None)[source]

Construct list of valid Dev Alpha autoloader URLs.

Parameters:
  • osversion (str) – OS version.
  • skeletons (list) – List of skeleton formats to try.
  • xec (concurrent.futures.ThreadPoolExecutor) – ThreadPoolExecutor instance.
  • session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.devalpha_urls_serieshandler(osversion, skeletons)[source]

Process list of candidate Dev Alpha autoloader URLs.

Parameters:
  • osversion (str) – OS version.
  • skeletons (list) – List of skeleton formats to try.
bbarchivist.networkutils.download(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.download_android_tools(downloaddir=None)[source]

Download Android SDK platform tools.

Parameters:downloaddir (str) – Directory name, default is “plattools”.
bbarchivist.networkutils.download_bootstrap(urls, outdir=None, workers=5, session=None)[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.
  • session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.download_writer(url, fname, lfname, sname, session=None)[source]

Download file and write to disk.

Parameters:
  • url (str) – URL to download from.
  • fname (str) – File path.
  • lfname (str) – Long filename.
  • sname (str) – Short name, for printing to screen.
  • session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.droid_scanner(build, device, method=None, session=None)[source]

Check for Android autoloaders on BlackBerry’s site.

Parameters:
  • build (str) – Build to check, 3 letters + 3 numbers.
  • device (str) – Device to check.
  • method (str) – None for regular OS links, “sha256/512” for SHA256 or 512 hash.
  • session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.droid_scanner_worker(xec, skels, session=None)[source]

Worker to check for Android autoloaders.

Parameters:
  • xec (concurrent.futures.ThreadPoolExecutor) – ThreadPoolExecutor instance.
  • skels (list(str)) – List of skeleton formats.
  • session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.generic_session(session=None, uagent_type=None)[source]

Create a Requests session object on the fly, if need be.

Parameters:
  • session (requests.Session()) – Requests session object, created if this is None.
  • uagent_type (string) – To force a desktop/tablet/smartphone User-Agent. Default is None.
bbarchivist.networkutils.generic_soup_parser(url, session=None)[source]

Get a BeautifulSoup HTML parser for some URL.

Parameters:
  • url (str) – The URL to check.
  • session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.get_length(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.getcode(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.grab_pem()[source]

Work with either local cacerts or system cacerts.

bbarchivist.networkutils.kernel_scraper(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.loader_page_chunker_bbm(ull)[source]

Given a loader page list, chunk it into lists of list items.

Parameters:ull (bs4.element.Tag) – HTML unordered list tag.
bbarchivist.networkutils.loader_page_chunker_og(idx, table, headers)[source]

Given a loader page table, chunk it into lists of table cells.

Parameters:
  • idx (int) – Index of enumerating tables.
  • table (bs4.element.Tag) – HTML table tag.
  • headers (list(str)) – List of table headers.
bbarchivist.networkutils.loader_page_printer(chunk)[source]

Print individual cell texts given a list of table cells.

Parameters:chunk (list(bs4.element.Tag)) – List of td tags.
bbarchivist.networkutils.loader_page_scraper(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.loader_page_scraper_bbm(session=None)[source]

Return scraped autoloader page, new site.

Parameters:session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.loader_page_scraper_og(session=None)[source]

Return scraped autoloader page, original site.

Parameters:session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.make_droid_skeleton(method, build, device, variant='common')[source]

Make an Android autoloader/hash URL.

Parameters:
  • method (str) – None for regular OS links, “sha256/512” for SHA256 or 512 hash.
  • build (str) – Build to check, 3 letters + 3 numbers.
  • device (str) – Device to check.
  • variant (str) – Autoloader variant. Default is “common”.
bbarchivist.networkutils.make_droid_skeleton_bbm(method, build, device, variant='common')[source]

Make an Android autoloader/hash URL, on the BB Mobile site.

Parameters:
  • method (str) – None for regular OS links, “sha256/512” for SHA256 or 512 hash.
  • build (str) – Build to check, 3 letters + 3 numbers.
  • device (str) – Device to check.
  • variant (str) – Autoloader variant. Default is “common”.
bbarchivist.networkutils.make_droid_skeleton_og(method, build, device, variant='common')[source]

Make an Android autoloader/hash URL, on the original site.

Parameters:
  • method (str) – None for regular OS links, “sha256/512” for SHA256 or 512 hash.
  • build (str) – Build to check, 3 letters + 3 numbers.
  • device (str) – Device to check.
  • variant (str) – Autoloader variant. Default is “common”.
bbarchivist.networkutils.ndk_metadata(session=None)[source]

Get BBNDK target metadata.

Parameters:session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.pem_wrapper(method)[source]

Decorator to set REQUESTS_CA_BUNDLE.

Parameters:method (function) – Method to use.
bbarchivist.networkutils.prepare_droid_list(device)[source]

Convert single devices to a list, if necessary.

Parameters:device (str) – Device to check.
bbarchivist.networkutils.ptcrb_cleaner_multios(item)[source]

Discard multiple entries for “OS”.

Parameters:item (str) – The item to clean.
bbarchivist.networkutils.ptcrb_cleaner_spaces(item)[source]

Pad item with spaces to the right length.

Parameters:item (str) – The item to clean.
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(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.remove_empty_download(fname)[source]

Remove file if it’s empty.

Parameters:fname (str) – File path.
bbarchivist.networkutils.return_npc(mcc, mnc)[source]

Format MCC and MNC into a NPC.

Parameters:
  • mcc (int) – Country code.
  • mnc (int) – Network code.
bbarchivist.networkutils.root_generator(folder, build, variant='common')[source]

Generate roots for the SHAxxx hash lookup URLs.

Parameters:
  • folder (dict(str: str)) – Dictionary of variant: loader name pairs.
  • build (str) – Build to check, 3 letters + 3 numbers.
  • variant (str) – Autoloader variant. Default is “common”.
bbarchivist.networkutils.runtime_metadata(session=None)[source]

Get BBNDK runtime metadata.

Parameters:session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.series_generator(osversion)[source]

Generate series/branch name from OS version.

Parameters:osversion (str) – OS version.
bbarchivist.networkutils.sim_metadata(session=None)[source]

Get BBNDK simulator metadata.

Parameters:session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.space_pad(instring, minlength)[source]

Pad a string with spaces until it’s the minimum length.

Parameters:
  • instring (str) – String to pad.
  • minlength (int) – Pad while len(instring) < minlength.
bbarchivist.networkutils.sr_lookup(*args, **kwargs)[source]

Set REQUESTS_CA_BUNDLE before doing function.

bbarchivist.networkutils.sr_lookup_bootstrap(osv, session=None, no2=False)[source]

Run lookups for each server for given OS.

Parameters:
  • osv (str) – OS to check.
  • session (requests.Session()) – Requests session object, default is created on the fly.
  • no2 (bool) – Whether to skip Alpha2/Beta2 servers. Default is false.
bbarchivist.networkutils.sr_lookup_poster(query, server, session=None)[source]

Post the XML payload for a software release lookup.

Parameters:
  • query (str) – XML payload.
  • server (str) – Server to use.
  • session (requests.Session()) – Requests session object, default is created on the fly.
bbarchivist.networkutils.table_header_filter(ptag)[source]

Validate p tag, to see if it’s relevant.

Parameters:ptag (bs4.element.Tag) – P tag.
bbarchivist.networkutils.table_headers(pees)[source]

Generate table headers from list of p tags.

Parameters:pees (list(bs4.element.Tag)) – List of p tags.
bbarchivist.networkutils.try_try_again(method)[source]

Decorator to absorb timeouts, proxy errors, and other common exceptions.

Parameters:method (function) – Method to use.
bbarchivist.networkutils.unicode_filter(intext)[source]

Remove Unicode crap.

Parameters:intext (str) – Text to filter.

bbarchivist.networkutilstcl module

This module is used for network connections for TCL tools.

bbarchivist.networkutilstcl.check_prep(curef, mode=4, fvver='AAA000', cltp=2010, cktp=2, rtd=1, chnl=2, devid=None)[source]

Prepare variables for TCL update check.

Parameters:
  • curef (str) – PRD of the phone variant to check.
  • mode (int) – 4 if downloading autoloaders, 2 if downloading OTA deltas.
  • fvver (str) – Initial software version, must be specific if downloading OTA deltas.
  • cltp (int) – 2010 to always show latest version, 10 to show actual updates. Default is 2010.
  • cktp (int) – 2 if checking manually, 1 if checking automatically. Default is 2.
  • rtd (int) – 2 if rooted, 1 if not. Default is 1.
  • chnl (int) – 2 if checking on WiFi, 1 if checking on mobile. Default is 2.
  • devid (str) – Serial number/IMEI. Default is fake, not that it matters.
bbarchivist.networkutilstcl.download_request_prep(curef, tvver, fwid, salt, vkh, mode=4, fvver='AAA000', cltp=2010, devid=None)[source]

Prepare variables for download server check.

Parameters:
  • curef (str) – PRD of the phone variant to check.
  • tvver (str) – Target software version.
  • fwid (str) – Firmware ID for desired download file.
  • salt (str) – Salt hash.
  • vkh (str) – VDKey-based hash.
  • mode (int) – 4 if downloading autoloaders, 2 if downloading OTA deltas.
  • fvver (str) – Initial software version, must be specific if downloading OTA deltas.
  • cltp (int) – 2010 to always show latest version, 10 to show actual updates. Default is 2010.
  • devid (str) – Serial number/IMEI. Default is fake, not that it matters.
bbarchivist.networkutilstcl.encrypt_header_prep(address, encslave)[source]

Prepare variables for encrypted header check.

Parameters:
  • address (str) – File URL minus host.
  • encslave (str) – Server hosting header script.
bbarchivist.networkutilstcl.tcl_default_id(devid)[source]

Get an IMEI or a serial number or something.

Parameters:devid (str) – Return default if this is None.
bbarchivist.networkutilstcl.tcl_master()[source]

Get a random master server.

bbarchivist.networkutilstcl.tcl_salt()[source]

Generate salt value for TCL server tools.

bbarchivist.networkutilstcl.unpack_vdkey()[source]

Draw the curtain back.

bbarchivist.networkutilstcl.vkhash(curef, tvver, fwid, salt, mode=4, fvver='AAA000', cltp=2010, devid=None)[source]

Generate hash from TCL update server variables.

Parameters:
  • curef (str) – PRD of the phone variant to check.
  • tvver (str) – Target software version.
  • fwid (str) – Firmware ID for desired download file.
  • salt (str) – Salt hash.
  • mode (int) – 4 if downloading autoloaders, 2 if downloading OTA deltas.
  • fvver (str) – Initial software version, must be specific if downloading OTA deltas.
  • cltp (int) – 2010 to always show latest version, 10 to show actual updates. Default is 2010.
  • devid (str) – Serial number/IMEI. Default is fake, not that it matters.

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, files, folder=None)[source]

Prepare for creation of autoloader.

Parameters:
  • filename (str) – Name of autoloader.
  • files (list(str)) – List of 1-6 signed files to add into autoloader.
  • folder (str) – Working folder. Optional, default is local.
bbarchivist.pseudocap.make_offset(files, folder=None)[source]

Create magic offset for use in autoloader creation. Cap.exe MUST match separator version. Version defined in bbarchivist.bbconstants.CAP.version.

Parameters:
  • files (list(str)) – List of 1-6 signed files.
  • folder (str) – Working folder. Optional. Default is local.
bbarchivist.pseudocap.make_sizes(filelist)[source]

Get sizes of list of signed files.

Parameters:filelist (list(str)) – List of 1-6 signed files.
bbarchivist.pseudocap.make_starts(beginlength, capsize, pad, sizes)[source]

Get list of starting positions for each signed file.

Parameters:
  • beginlength (int) – Length of beginning offset.
  • capsize (int) – Size of cap executable.
  • pad (bytes) – Padding character.
  • sizes (list(int)) – List of signed file sizes.
bbarchivist.pseudocap.write_4k(infile, outfile, text='FILE')[source]

Write to a file from another file, 4k bytes at a time.

Parameters:
  • infile (str) – Filename. Input file.
  • outfile (str) – Open (!!!) file handle. Output file.
  • text (str) – Writing <text>…
bbarchivist.pseudocap.write_autoloader(filename, folder, offset, filelist)[source]

Write cap.exe, magic offset, and signed files to a .exe file.

Parameters:
  • filename (str) – Name of autoloader.
  • folder (str) – Working folder.
  • offset (bytes) – Offset bytestring.
  • filelist (list(str)) – List of absolute filepaths to write into autoloader.
bbarchivist.pseudocap.write_autoloader_guard(filename, folder, offset, filelist)[source]

Try/except guard for writing autoloader.

Parameters:
  • filename (str) – Name of autoloader.
  • folder (str) – Working folder.
  • offset (bytes) – Offset bytestring.
  • filelist (list(str)) – List of absolute filepaths to write into autoloader.
bbarchivist.pseudocap.write_offset(inbytes, outfile)[source]

Write to a file from the offset bytestring.

Parameters:
  • inbytes (bytes) – Bytestring.
  • outfile (str) – Open (!!!) file handle. Output file.

bbarchivist.scriptutils module

This module contains various utilities for the scripts folder.

bbarchivist.scriptutils.autolookup_logger(record, out)[source]

Write autolookup results to file.

Parameters:
  • record (str) – The file to log to.
  • out (str) – Output block.
bbarchivist.scriptutils.autolookup_output(osversion, swrelease, avail, avpack, sql=False)[source]

Prepare autolookup block, and add to SQL database.

Parameters:
  • osversion (str) – OS version.
  • swrelease (str) – Software release.
  • avail (str) – “Unavailable” or “Available”.
  • avpack (list(str)) – Availabilities: alpha 1 and 2, beta 1 and 2, production.
  • sql (bool) – If we’re adding this to our SQL database.
bbarchivist.scriptutils.autolookup_output_sql(osversion, swrelease, avail, sql=False)[source]

Add OS to SQL database.

Parameters:
  • osversion (str) – OS version.
  • swrelease (str) – Software release.
  • avail (str) – “Unavailable” or “Available”.
  • sql (bool) – If we’re adding this to our SQL database.
bbarchivist.scriptutils.autolookup_printer(out, avail, log=False, quiet=False, record=None)[source]

Print autolookup results, logging if specified.

Parameters:
  • out (str) – Output block.
  • avail (str) – Availability. Can be “Available” or “Unavailable”.
  • log (bool) – If we’re logging to file.
  • quiet (bool) – If we only note available entries.
  • record (str) – If we’re logging, the file to log to.
bbarchivist.scriptutils.bar_broken_individual(brokens, urllist, brokenlist)[source]

What to do if a downloaded bar file is broken.

Parameters:
  • brokens (str) – None if bar is OK, filename if it is not.
  • urllist (list(str)) – List of URLs to check.
  • brokenlist (list(str)) – List of URLs to download later.
bbarchivist.scriptutils.bulk_avail(urllist)[source]

Filter 404 links out of URL list.

Parameters:urllist (list(str)) – URLs to check.
bbarchivist.scriptutils.bulk_hash(dirs, compressed=True, deleted=True, radios=True, hashdict=None)[source]

Hash files in several folders based on flags.

Parameters:
  • dirs (list(str)) – Folders: [OS_bars, radio_bars, OS_exes, radio_exes, OS_zips, radio_zips]
  • compressed (bool) – Whether to hash compressed files. True by default.
  • deleted (bool) – Whether to delete uncompressed files. True by default.
  • radios (bool) – Whether to hash radio autoloaders. True by default.
  • hashdict (dict({str: bool})) – Dictionary of hash rules, in ~barchivist.ini.
bbarchivist.scriptutils.bulk_info(dirs, osv, compressed=True, deleted=True, radios=True, rad=None, swv=None, dev=None)[source]

Generate info files in several folders based on flags.

Parameters:
  • dirs (list(str)) – Folders: [OS_bars, radio_bars, OS_exes, radio_exes, OS_zips, radio_zips]
  • osver (str) – OS version, required for both types.
  • compressed (bool) – Whether to hash compressed files. True by default.
  • deleted (bool) – Whether to delete uncompressed files. True by default.
  • radios (bool) – Whether to hash radio autoloaders. True by default.
  • rad (str) – Radio version, required for QNX.
  • swv (str) – Software release, required for QNX.
  • dev (str) – Device type, required for Android.
bbarchivist.scriptutils.bulk_verify(dirs, compressed=True, deleted=True, radios=True)[source]

Verify files in several folders based on flags.

Parameters:
  • dirs (list(str)) – Folders: [OS_bars, radio_bars, OS_exes, radio_exes, OS_zips, radio_zips]
  • compressed (bool) – Whether to hash compressed files. True by default.
  • deleted (bool) – Whether to delete uncompressed files. True by default.
  • radios (bool) – Whether to hash radio autoloaders. True by default.
bbarchivist.scriptutils.check_altsw(altcheck=False)[source]

Ask for and return alternate software release, if needed.

Parameters:altcheck (bool) – If we’re using an alternate software release.
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_bulk_handle()[source]

Handle no existing OS links.

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_bulk_go(radiourls, radioversion)[source]

Replace radio version and URLs, and keep going.

Parameters:
  • radiourls (list(str)) – Radio URLs to check.
  • radioversion (str) – Radio version.
bbarchivist.scriptutils.check_radio_bulk_notfound(radiourls, radioversion)[source]

What to do if radio links aren’t found.

Parameters:
  • radiourls (list(str)) – Radio URLs to check.
  • radioversion (str) – Radio version.
bbarchivist.scriptutils.check_radio_bulk_stop()[source]

Ask if we should keep going once no radio has been found.

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, altsw=False)[source]

Check existence of software release.

Parameters:
  • baseurl (str) – Base URL (from http to hashed SW release).
  • softwareversion (str) – Software release.
  • swchecked (bool) – If we checked the sw release already.
  • altsw (bool) – If this is the radio-only release. Default is false.
bbarchivist.scriptutils.check_sw_actual(baseurl, softwareversion)[source]

Get the status of a software release.

Parameters:
  • baseurl (str) – Base URL (from http to hashed SW release).
  • softwareversion (str) – Software release.
bbarchivist.scriptutils.check_sw_handle(softwareversion)[source]

Handle non-existent software release.

Parameters:softwareversion (str) – Software release.
bbarchivist.scriptutils.clean_barlist(cleanfiles, stoppers)[source]

Remove certain bars from barlist based on keywords.

Parameters:
  • cleanfiles (list(str)) – List of files to clean.
  • stoppers (list(str)) – List of keywords (i.e. bar names) to exclude.
bbarchivist.scriptutils.clean_swrel(swrelset)[source]

Clean a list of software release lookups.

Parameters:swrelset (set(str)) – List of software releases.
bbarchivist.scriptutils.comp_joiner(rootdir, localdir, filelist)[source]

Join rootdir, localdir to every file in filelist.

Parameters:
  • rootdir (str) – Root directory.
  • localdir (str) – Subfolder inside rootdir.
  • filelist (list(str)) – List of files to return this path for.
bbarchivist.scriptutils.enn_ayy(quant)[source]

Cheeky way to put a N/A placeholder for a string.

Parameters:quant (str) – What to check if it’s None.
bbarchivist.scriptutils.export_cchecker(files, npc, hwid, osv, radv, swv, upgrade=False, forced=None)[source]

Write carrierchecker lookup links to file.

Parameters:
  • files (list(str)) – List of file URLs.
  • npc (int) – MCC + MNC (ex. 302220).
  • hwid (str) – Device hardware ID.
  • osv (str) – OS version.
  • radv (str) – Radio version.
  • swv (str) – Software release.
  • upgrade (bool) – Whether or not to use upgrade files. Default is false.
  • forced (str) – Force a software release. None to go for latest.

Generate blitz URLs (i.e. all OS and radio links). :param files: List of file URLs. :type files: list(str)

Parameters:
  • osv (str) – OS version.
  • radv (str) – Radio version.
  • swv (str) – Software release.
bbarchivist.scriptutils.generate_workfolder(folder=None)[source]

Check if a folder exists, make it if it doesn’t, set it to home if None.

Parameters:folder (str) – Folder to check.
bbarchivist.scriptutils.get_baseurls(softwareversion, altsw=None)[source]

Generate base URLs for bar links.

Parameters:
  • softwareversion (str) – Software version.
  • altsw (str) – Radio software version, if necessary.
bbarchivist.scriptutils.get_sz_executable(compmethod)[source]

Get 7z executable.

Parameters:compmethod (str) – Compression method.
bbarchivist.scriptutils.info_header(afile, osver, radio=None, software=None, device=None)[source]

Write header for info file.

Parameters:
  • afile (File object) – Open file to write to.
  • osver (str) – OS version, required for both types.
  • radio (str) – Radio version, required for QNX.
  • software (str) – Software release, required for QNX.
  • device (str) – Device type, required for Android.
bbarchivist.scriptutils.kernchecker_dict(splitkerns, platforms)[source]

Prepare results dictionary.

Parameters:
  • splitkerns (list(str)) – Split kernel branches.
  • platforms (list(dict)) – List of platform dicts.
bbarchivist.scriptutils.kernchecker_prep(kernlist)[source]

Prepare output from kernel list.

Parameters:kernlist (list(str)) – List of kernel branches.
bbarchivist.scriptutils.linkgen(osversion, radioversion=None, softwareversion=None, altsw=None, temp=False, sdk=False)[source]

Generate debrick/core/radio links for given OS, radio, software release.

Parameters:
  • osversion (str) – OS version, 10.x.y.zzzz.
  • radioversion (str) – Radio version, 10.x.y.zzzz. Can be guessed.
  • softwareversion (str) – Software version, 10.x.y.zzzz. Can be guessed.
  • altsw (str) – Radio software release, if not the same as OS.
  • temp (bool) – If file we write to is temporary. Default is False.
  • sdk (bool) – If we specifically want SDK images. Default is False.
bbarchivist.scriptutils.linkgen_sdk(sdk, oses, cores)[source]

Generate SDK debrick/core images.

Parameters:
  • sdk (bool) – If we specifically want SDK images. Default is False.
  • oses (dict(str:str)) – Dictionary of radio and debrick pairs.
  • cores (dict(str:str)) – Dictionary of radio and core pairs.
bbarchivist.scriptutils.linkgen_sdk_dicter(indict, origtext, newtext)[source]

Prepare SDK radio/OS dictionaries.

Parameters:
  • indict – Dictionary of radio and OS pairs.
  • origtext (str) – String in indict’s values that must be replaced.
  • newtext (str) – What to replace origtext with.
Type:

dict(str:str)

bbarchivist.scriptutils.make_info(filepath, osver, radio=None, software=None, device=None)[source]

Create a new-style info (names, sizes and hashes) file.

Parameters:
  • filepath (str) – Path to folder to analyze.
  • osver (str) – OS version, required for both types.
  • radio (str) – Radio version, required for QNX.
  • software (str) – Software release, required for QNX.
  • device (str) – Device type, required for Android.
bbarchivist.scriptutils.package_blitz(bardir, swv)[source]

Package and verify a blitz package.

Parameters:
  • bardir (str) – Path to folder containing bar files.
  • swv (str) – Software version.
bbarchivist.scriptutils.prep_export_cchecker(files, npc, hwid, osv, radv, swv, upgrade=False, forced=None)[source]

Prepare carrierchecker lookup links to write to file.

Parameters:
  • files (list(str)) – List of file URLs.
  • npc (int) – MCC + MNC (ex. 302220).
  • hwid (str) – Device hardware ID.
  • osv (str) – OS version.
  • radv (str) – Radio version.
  • swv (str) – Software release.
  • upgrade (bool) – Whether or not to use upgrade files. Default is false.
  • forced (str) – Force a software release. None to go for latest.
bbarchivist.scriptutils.prep_info(filepath, osver, device=None)[source]

Prepare file list for new-style info file.

Parameters:
  • filepath (str) – Path to folder to analyze.
  • osver (str) – OS version, required for both types.
  • device (str) – Device type, required for Android.
bbarchivist.scriptutils.prod_avail(results, mailer=False, osversion=None, password=None)[source]

Clean availability for production lookups for autolookup script.

Parameters:
  • results (dict(str: str)) – Result dict.
  • mailer (bool) – If we’re mailing links. Default is false.
  • osversion (str) – OS version.
  • password (str) – Email password.
bbarchivist.scriptutils.prod_avail_mailprep(prel, avail, osversion=None, mailer=False, password=None)[source]

Do SQL/SMTP prep work after a good production lookup hit.

Parameters:
  • prel (str) – Software lookup result.
  • avail (bool) – If software lookup result is available for download.
  • osversion (str) – OS version.
  • mailer (bool) – If we’re mailing links. Default is false.
  • password (str) – Email password.
bbarchivist.scriptutils.questionnaire_device(message=None)[source]

Get device from questionnaire.

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.sw_check_contingency(softwareversion)[source]

Ask in the event software release isn’t found.

Parameters:softwareversion (str) – Software release version.
bbarchivist.scriptutils.test_bar_files(localdir, urllist)[source]

Test bar files after download.

Parameters:
  • localdir (str) – Directory.
  • urllist (list(str)) – List of URLs to check.
bbarchivist.scriptutils.test_bar_files_individual(file, localdir, urllist, brokenlist)[source]

Test bar file after download.

Parameters:
  • file (str) – Bar file to check.
  • localdir (str) – Directory.
  • urllist (list(str)) – List of URLs to check.
  • brokenlist (list(str)) – List of URLs to download later.
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.scriptutils.test_single_loader(loaderfile)[source]

Test single loader file after creation.

Parameters:loaderfile (str) – File to check.
bbarchivist.scriptutils.verify_gpg_credentials()[source]

Read GPG key/pass from file, verify if incomplete.

bbarchivist.scriptutils.verify_gpg_key(gpgkey=None)[source]

Verify GPG key.

Parameters:gpgkey (str) – Key, use None to take from input.
bbarchivist.scriptutils.verify_gpg_pass(gpgpass=None)[source]

Verify GPG passphrase.

Parameters:gpgpass (str) – Passphrase, use None to take from input.
bbarchivist.scriptutils.write_info(infile, index, filecount, outfile)[source]

Write a new-style info (names, sizes and hashes) file.

Parameters:
  • infile (str) – Path to file whose name, size and hash are to be written.
  • index (int) – Which file index out of the list of files we’re writing.
  • filecount (int) – Total number of files we’re to write; for excluding terminal newline.
  • outfile (str) – Open (!!!) file handle. Output file.

bbarchivist.scriptutilstcl module

This module contains various utilities for TCL tools.

bbarchivist.scriptutilstcl.tcl_delta_filename(curef, fvver, tvver, filename, original=True)[source]

Generate compatible filenames for deltas, if needed.

Parameters:
  • curef (str) – PRD of the phone variant to check.
  • fvver (str) – Initial software version.
  • tvver (str) – Target software version.
  • filename (str) – File name from download URL, passed through if not changing filename.
  • original (bool) – If we’ll download the file with its original filename. Default is True.
bbarchivist.scriptutilstcl.tcl_delta_remote(curef)[source]

Prepare remote version for delta scanning.

Parameters:curef (str) – PRD of the phone variant to check.
bbarchivist.scriptutilstcl.tcl_download(downloadurl, filename, filesize, filehash, verify=True)[source]

Download autoloader file, rename, and verify.

Parameters:
  • downloadurl (str) – Download URL.
  • filename (str) – Name of autoloader file.
  • filesize (str) – Size of autoloader file.
  • filehash (str) – SHA-1 hash of autoloader file.
  • verify (bool) – Whether to verify the file after downloading. Default is True.
bbarchivist.scriptutilstcl.tcl_findprd(prddict, floor=0, ceiling=999, export=False, noprefix=False, key2mode=False)[source]

Check for new PRDs based on PRD database.

Parameters:
  • prddict (collections.defaultdict(str: list)) – PRD center:[ends] dictionary.
  • floor (int) – When to start. Default is 0.
  • ceiling (int) – When to stop. Default is 999.
  • export (bool) – Whether to export XML response to file. Default is False.
  • noprefix (bool) – Whether to skip adding “PRD-” prefix. Default is False.
  • key2mode (bool) – Whether to use new-style prefix. Default is False.
bbarchivist.scriptutilstcl.tcl_findprd_centerscan(center, prddict, session, floor=0, ceiling=999, export=False, noprefix=False, key2mode=False)[source]

Individual scanning for the center of a PRD.

Parameters:
  • center (str) – PRD-center-end.
  • prddict (collections.defaultdict(str: list)) – PRD center:[ends] dictionary.
  • session (requests.Session) – Session object.
  • floor (int) – When to start. Default is 0.
  • ceiling (int) – When to stop. Default is 999.
  • export (bool) – Whether to export XML response to file. Default is False.
  • noprefix (bool) – Whether to skip adding “PRD-” prefix. Default is False.
  • key2mode (bool) – Whether to use new-style prefix. Default is False.
bbarchivist.scriptutilstcl.tcl_findprd_checkfilter(prddict, tocheck=None)[source]

Filter PRD dict if needed.

Parameters:
  • prddict (collections.defaultdict(str: list)) – PRD center:[ends] dictionary.
  • tocheck (list(str)) – Specific PRD(s) to check, None if all will be checked. Default is None.
bbarchivist.scriptutilstcl.tcl_findprd_prepcuref(center, tail, noprefix=False, key2mode=False)[source]

Prepare candidate PRD.

Parameters:
  • center (str) – PRD-center-tail.
  • tail (int) – PRD-center-tail.
  • noprefix (bool) – Whether to skip adding “PRD-” prefix. Default is False.
  • key2mode (bool) – Whether to use new-style prefix. Default is False.
bbarchivist.scriptutilstcl.tcl_findprd_prepd_end(prdx)[source]

Convert list of center:end entries to final center:[ends] dict.

Parameters:prdx (list(dict(str: str))) – List of center:end dict entries.
bbarchivist.scriptutilstcl.tcl_findprd_prepd_middle(prda)[source]

Convert PRD entries to list of center:end entries.

Parameters:prda (list(str)) – List of PRD-xxxxx-yyy entries.
bbarchivist.scriptutilstcl.tcl_findprd_prepd_start(prddict)[source]

Collect list of PRD entries.

Parameters:prddict (dict(str: list)) – Device:PRD dictionary.
bbarchivist.scriptutilstcl.tcl_findprd_prepdict(prddict)[source]

Prepare dict of center:[ends] entries.

Parameters:prddict (dict(str: list)) – Device:PRD dictionary.
bbarchivist.scriptutilstcl.tcl_findprd_safehandle(curef, checktext)[source]

Parse API output and print the relevant bits.

Parameters:
  • curef (str) – PRD of the phone variant to check.
  • checktext (str) – The XML formatted data returned from the first stage API check.
bbarchivist.scriptutilstcl.tcl_findprd_safescan(safes, center, session, export=False, noprefix=False, key2mode=False)[source]

Scan for PRDs known not to be in database.

Parameters:
  • safes (list(int)) – List of ends within given range that aren’t in database.
  • center (str) – PRD-center-end.
  • session (requests.Session) – Session object.
  • export (bool) – Whether to export XML response to file. Default is False.
  • noprefix (bool) – Whether to skip adding “PRD-” prefix. Default is False.
  • key2mode (bool) – Whether to use new-style prefix. Default is False.
bbarchivist.scriptutilstcl.tcl_mainscan_preamble(ota=None)[source]

Prepare preamble for TCL scanning.

Parameters:ota (str) – The starting version if OTA, None if not. Default is None.
bbarchivist.scriptutilstcl.tcl_mainscan_printer(curef, tvver, ota=None)[source]

Print output of TCL scanning.

Parameters:
  • curef (str) – PRD of the phone variant to check.
  • tvver (str) – Target software version.
  • ota (str) – The starting version if OTA, None if not. Default is None.
bbarchivist.scriptutilstcl.tcl_prd_print(tvver, downloadurl, filename, statcode, encslave, session)[source]

Print output from PRD scanning.

Parameters:
  • tvver (str) – Target software version.
  • downloadurl (str) – File to download.
  • filename (str) – File name from download URL.
  • statcode (int) – Status code of download URL.
  • encslave (str) – Server hosting header script.
  • session (requests.Session) – Session object.
bbarchivist.scriptutilstcl.tcl_prd_scan(curef, download=False, mode=4, fvver='AAA000', original=True, export=False, verify=True)[source]

Scan one PRD and produce download URL and filename.

Parameters:
  • curef (str) – PRD of the phone variant to check.
  • download (bool) – If we’ll download the file that this returns. Default is False.
  • mode (int) – 4 if downloading autoloaders, 2 if downloading OTA deltas.
  • fvver (str) – Initial software version, must be specific if downloading OTA deltas.
  • original (bool) – If we’ll download the file with its original filename. Default is True.
  • export (bool) – Whether to export XML response to file. Default is False.
  • verify (bool) – Whether to verify the file after downloading. Default is True.
bbarchivist.scriptutilstcl.tcl_prep_otaver(ota=None)[source]

Prepare variables for OTA versus full check.

Parameters:ota (str) – The starting version if OTA, None if not. Default is None.
bbarchivist.scriptutilstcl.tclloader_filename(loaderdir, osver, loadername=None)[source]

Prepare platform and filename.

Parameters:
  • loaderdir (str) – Path to input folder.
  • osver (str) – OS version.
  • loadername (str) – Name of final autoloader. Default is auto-generated.
bbarchivist.scriptutilstcl.tclloader_prep(loaderfile, directory=False)[source]

Prepare directory name and OS version.

Parameters:
  • loaderfile (str) – Path to input file/folder.
  • directory (bool) – If the input file is a folder. Default is False.

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.prep_smtp_instance(kwargs)[source]

Prepare a smtplib.SMTP/SMTP_SSL instance.

Parameters:
  • is_ssl (bool) – True if server uses SSL, False if TLS only.
  • server (str) – SMTP email server.
  • port (int) – Port to use.
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.send_email_post(kwargs)[source]

Send email through SSL/TLS.

Parameters:
  • server (str) – SMTP email server.
  • port (int) – Port to use.
  • username (str) – Email address.
  • password (str) – Email password.
  • message (MIMEText) – Message to send, with body and subject.
bbarchivist.smtputils.smtp_config_generator(results)[source]

Take user input to create the SMTP config settings.

Parameters:results (dict) – The results to put in bbarchivist.ini.
bbarchivist.smtputils.smtp_config_generator_password(results)[source]

Generate password config.

Parameters:results (dict) – Values. Refer to :func:smtp_config_writer.
bbarchivist.smtputils.smtp_config_generator_port(results)[source]

Generate port config.

Parameters:results (dict) – Values. Refer to :func:smtp_config_writer.
bbarchivist.smtputils.smtp_config_generator_ssl(results)[source]

Generate SSL/TLS config.

Parameters:results (dict) – Values. Refer to :func:smtp_config_writer.
bbarchivist.smtputils.smtp_config_generator_str(results, key, inp)[source]

Set server/username config.

Parameters:
  • kwargs (dict) – Values. Refer to :func:smtp_config_writer.
  • key (str) – Key for results dict.
  • inp (str) – Input question.
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(**kwargs)[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.smtputils.smtp_config_writer_kwargs(kwargs, config, key)[source]

Set server/port/username/password config.

Parameters:
  • kwargs (dict) – Values. Refer to :func:smtp_config_writer.
  • config (dict) – Configuration dictionary.
  • key (str) – Key for kwargs and config dict.
bbarchivist.smtputils.smtp_config_writer_ssl(kwargs, config)[source]

Set SSL/TLS config.

Parameters:
  • kwargs (dict) – Values. Refer to :func:smtp_config_writer.
  • config (dict) – Configuration dictionary.

bbarchivist.sqlutils module

This module is used for dealing with SQL databases, including CSV export.

bbarchivist.sqlutils.prepare_path()[source]

Figure out where the path is.

bbarchivist.textgenerator module

This module is used for generation of URLs and related text files.

bbarchivist.textgenerator.app_individual_writer(app, target)[source]

Write individual app link to file.

Parameters:
  • app (str) – App URL.
  • target (file) – File to write to.

Write app links to file.

Parameters:
  • target (file) – File to write to.
  • urls (dict(str: str)) – Dictionary of URLs; name: URL

Write Dev Alpha autooloader links to file.

Parameters:
  • target (file) – File to write to.
  • finals (dict(str: str)) – Dict of URL:content-length pairs.
bbarchivist.textgenerator.export_devloader(osversion, finals)[source]

Export Dev Alpha URLs to file.

Parameters:
  • osversion (str) – OS version.
  • finals (dict(str: str)) – Dict of URL:content-length pairs.
bbarchivist.textgenerator.get_fnone(fsize)[source]

Get sentinel value for filesize when writing OS/radio links.

Parameters:fsize (int) – Filesize.
bbarchivist.textgenerator.prep_thename(softwareversion, appendbars=False, temp=False)[source]

Generate name for output file.

Parameters:
  • softwareversion (str) – Software release version.
  • appendbars (bool) – Whether to add app bars to file. Default is false.
  • temp (bool) – If file we write to is temporary. Default is false.
bbarchivist.textgenerator.system_individual_writer(appname, appurl, target, fsize)[source]

Write individual OS/radio link to file.

Parameters:
  • appname (str) – App name.
  • appurl (str) – App URL.
  • target (file) – File to write to.
  • fsize (int) – Filesize.

Write OS/radio links to file.

Parameters:
  • target (file) – File to write to.
  • urls (dict(str: str)) – Dictionary of URLs; name: URL
  • avlty (bool) – If this OS release is available. Default is false.
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.url_gen_dicter(inlist, filelist)[source]

Prepare name:URL dicts for a given pair of names and URLs.

Parameters:
  • inlist (list(str)) – List of dictionary keys (OS/radio platforms)
  • filelist (list(str)) – List of dictionary values (URLs)
bbarchivist.textgenerator.url_gen_filter(osversion, oslist, radlist)[source]

Filter OS and radio name list.

Parameters:
  • osversion (str) – OS version.
  • oslist (list(str)) – List of OS platforms.
  • radlist (list(str)) – List of radio platforms.
bbarchivist.textgenerator.write_altsw(target, altsw)[source]

Write alternate software release to file.

Parameters:
  • target (file) – File to write to.
  • altsw (str) – Radio software release version, if different.
bbarchivist.textgenerator.write_appbars(target, appendbars, appurls)[source]

Write app bar links to file.

Parameters:
  • target (file) – File to write to.
  • appendbars (bool) – Whether to add app bars to file. Default is false.
  • appurls – App bar URLs to add.
bbarchivist.textgenerator.write_disclaimer(target, avlty)[source]

Write availability disclaimer to file.

Parameters:
  • target (file) – File to write to.
  • avlty (bool) – Availability of links to download. Default is false.
bbarchivist.textgenerator.write_header(target, softwareversion, osversion, radioversion)[source]

Write header for file.

Parameters:
  • target (file) – File to write to.
  • softwareversion (str) – Software release version.
  • osversion (str) – OS version.
  • radioversion (str) – Radio version.

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. Default is false.
  • altsw (str) – Radio software release version, if different.
bbarchivist.textgenerator.write_signedbars(target, urllist, avlty, message)[source]

Write debrick/core/radio URLs to file.

Parameters:
  • target (file) – File to write to.
  • urllist (list(str)) – List of URLs to write.
  • avlty (bool) – Availability of links to download. Default is false.
  • message (str) – Header for this section: debrick, core or radio.

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.

loop()[source]

Spin if scanning, clean up if not.

start()[source]

Begin the spinner.

stop()[source]

Stop the spinner.

class bbarchivist.utilities.Spinner[source]

Bases: object

A basic spinner using itertools. No need for progress.

after()[source]

Iterate over itertools.cycle, write to file.

stop()[source]

Kill output.

bbarchivist.utilities.bulk_urls(softwareversion, osversion, radioversion, core=False, altsw=None)[source]

Generate all URLs, plus extra Verizon URLs.

Parameters:
  • softwareversion (str) – Software version to hash.
  • osversion (str) – OS version.
  • radioversion (str) – Radio version.
  • device (int) – Device to use.
  • core (bool) – Whether or not to return core URLs as well.
  • altsw (str) – Radio software release, if not the same as OS.
bbarchivist.utilities.bulk_urls_altsw(radurls, baseurl, altsw=None)[source]

Handle alternate software release for radio.

Parameters:
  • radurls (list(str)) – List of radio URLs.
  • baseurl (str) – Base URL (from http to hashed SW release).
  • altsw (str) – Radio software release, if not the same as OS.
bbarchivist.utilities.bulkfilter(files)[source]

Verify all loader files in a given list.

Parameters:files (list(str)) – List of files.
bbarchivist.utilities.bulkfilter_printer(afile)[source]

Print filename and verify a loader file.

Parameters:afile (str) – Path to file.
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.cond_check(dofunc, goargs, restargs=None, condition=True, checkif=True, checkifnot=True)[source]

Do cond_do() based on a condition, then do it again based on a second condition.

Parameters:
  • dofunc (function) – Function to do.
  • goargs (list(str)) – List of variable arguments.
  • restargs (list(str)) – Rest of arguments, which are constant.
  • condition (bool) – Condition to check in order to use secondarg.
  • checkif (bool) – Do cond_do() if this is True.
  • checkifnot (bool) – Do cond_do() if this is False.
bbarchivist.utilities.cond_do(dofunc, goargs, restargs=None, condition=True)[source]

Do a function, check a condition, then do same function but swap first argument.

Parameters:
  • dofunc (function) – Function to do.
  • goargs (list(str)) – List of variable arguments.
  • restargs (list(str)) – Rest of arguments, which are constant.
  • condition (bool) – Condition to check in order to use secondarg.
bbarchivist.utilities.cpu_workers(input_data)[source]

Count number of CPU workers, smaller of number of threads and length of data.

Parameters:input_data (list) – Input data, some iterable.
bbarchivist.utilities.create_bar_url(softwareversion, appname, appversion, clean=False)[source]

Make the URL for any production server file.

Parameters:
  • softwareversion (str) – Software version to hash.
  • appname (str) – Application name, preferably like on server.
  • appversion (str) – Application version.
  • clean (bool) – Whether or not to clean up app name. Default is False.
bbarchivist.utilities.create_base_url(softwareversion)[source]

Make the root URL for production server files.

Parameters:softwareversion (str) – Software version to hash.
bbarchivist.utilities.def_args(dirs)[source]

Return prepared argument list for most instances of cond_check:().

Parameters:dirs (list(str)) – List of directories.
bbarchivist.utilities.dirhandler(directory, defaultdir)[source]

If directory is None, turn it into defaultdir.

Parameters:
  • directory (str) – Target directory.
  • defaultdir (str) – Default directory.
bbarchivist.utilities.filter_1031(osurl, splitos, device)[source]

Modify URLs to reflect changes in 10.3.1.

Parameters:
  • osurl (str) – OS URL to modify.
  • splitos (list(int)) – OS version, split and cast to int: [10, 3, 2, 2876]
  • device (int) – Device to use.
bbarchivist.utilities.filter_osversion(osurl, device, filterdict)[source]

Modify URLs based on device index and dictionary of changes.

Parameters:
  • osurl (str) – OS URL to modify.
  • device (int) – Device to use.
  • filterdict (dict(int:(str, str))) – Dictionary of changes: {device : (before, after)}
bbarchivist.utilities.filter_urls(osurls, radiourls, osversion)[source]

Filter lists of OS and radio URLs.

Parameters:
  • osurls (list(str)) – List of OS URLs.
  • radiourls (list(str)) – List of radio URLs.
  • osversion (str) – OS version.
bbarchivist.utilities.format_app_name(appname)[source]

Convert long reverse DNS name to short name.

Parameters:appname (str) – Application name (ex. sys.pim.calendar -> “calendar”)
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(softwareversion, osversion, radioversion, device)[source]

Generate a pair of OS/radio URLs based on input.

Parameters:
  • softwareversion (str) – Software version to hash.
  • osversion (str) – OS version.
  • radioversion (str) – Radio version.
  • device (int) – Device to use.
bbarchivist.utilities.generate_urls(softwareversion, osversion, radioversion, core=False)[source]

Generate a list of OS URLs and a list of radio URLs based on input.

Parameters:
  • softwareversion (str) – Software version to hash.
  • osversion (str) – OS version.
  • radioversion (str) – Radio version.
  • core (bool) – Whether or not to return core URLs as well.
bbarchivist.utilities.get_core_count()[source]

Find out how many CPU cores this system has.

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.grab_capini(datafile)[source]

Get cap location from .ini file, and write if it’s new.

Parameters:datafile (bbconstants.Datafile) – Datafile to check.
bbarchivist.utilities.grab_cfp()[source]

Figure out where cfp is, local or system-supplied.

bbarchivist.utilities.grab_datafile(datafile)[source]

Figure out where a datafile is.

Parameters:datafile (bbconstants.Datafile) – Datafile to check.
bbarchivist.utilities.i2b(input_check)[source]

Return Boolean interpretation of typed input.

Parameters:input_check (str) – Query to feed into input function.
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.is_amd64()[source]

Check if script is running on an AMD64 system (Python can be 32/64, this is for subprocess)

bbarchivist.utilities.is_windows()[source]

Check if script is running on Windows.

bbarchivist.utilities.line_begin()[source]

Go to beginning of line, to overwrite whatever’s there.

bbarchivist.utilities.list_workers(input_data, workerlimit)[source]

Count number of threads, either length of iterable or provided limit.

Parameters:
  • input_data (list) – Input data, some iterable.
  • workerlimit (int) – Maximum number of workers.
bbarchivist.utilities.lprint(iterable)[source]

A oneliner for ‘for item in x: print item’.

Parameters:iterable (list/tuple) – Iterable to print.
bbarchivist.utilities.new_enough(minver)[source]

Check if we’re at or above a minimum Python version.

Parameters:minver (int) – Minimum Python version (3.minver).
bbarchivist.utilities.newer_103(splitos, third)[source]

Return True if given split OS version is 10.3.X or newer.

Parameters:
  • splitos – OS version, split on the dots: [10, 3, 3, 2205]
  • third (int) – The X in 10.3.X.
Type:

list(int)

bbarchivist.utilities.one_and_none(first, second)[source]

Check if one element in a pair is None and one isn’t.

Parameters:
  • first (str) – To return True, this must be None.
  • second (str) – To return True, this mustbe false.
bbarchivist.utilities.pop_stl1(osurls, radiourls, splitos)[source]

Replace STL100-1 links in 10.3.3+.

Parameters:
  • osurls (list(str)) – List of OS platforms.
  • radiourls (list(str)) – List of radio platforms.
  • splitos (list(int)) – OS version, split and cast to int: [10, 3, 3, 2205]
bbarchivist.utilities.prep_filesize(file_size)[source]

Convert file size to float.

Parameters:file_size (float) – Number to parse.
bbarchivist.utilities.prep_logfile()[source]

Prepare log file, labeling it with current date. Select folder based on frozen status.

bbarchivist.utilities.prep_logfile_folder()[source]

Prepare folder to write log file to.

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.prep_seven_zip_path(path, talkative=False)[source]

Print p7zip path on POSIX, or notify if not there.

Parameters:
  • path (str) – Path to use.
  • talkative (bool) – Whether to output to screen. False by default.
bbarchivist.utilities.prep_seven_zip_posix(talkative=False)[source]

Check for p7zip on POSIX.

Parameters:talkative (bool) – Whether to output to screen. False by default.
bbarchivist.utilities.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.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.spinner_clear()[source]

Get rid of any spinner residue left in stdout.

bbarchivist.utilities.stripper(name)[source]

Strip fluff from bar filename.

Parameters:name (str) – Bar filename, must contain ‘-nto+armle-v7+signed.bar’.
bbarchivist.utilities.talkaprint(msg, talkative=False)[source]

Print only if asked to.

Parameters:
  • msg (str) – Message to print.
  • talkative (bool) – Whether to output to screen. False by default.
bbarchivist.utilities.verify_bulk_loaders(ldir)[source]

Run verify_loader_integrity() for all files in a dir.

Parameters:ldir (str) – Directory to use.
bbarchivist.utilities.verify_bulk_loaders_brokens(files)[source]

Prepare filtered file list for verify_bulk_loaders().

Parameters:files (list(str)) – List of files.
bbarchivist.utilities.verify_bulk_loaders_filefilter(ldir)[source]

Prepare file names for verify_bulk_loaders().

Parameters:ldir (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.win_seven_zip(talkative=False)[source]

For Windows, check where 7-Zip is (“where”, pretty much). Consult registry first for any installed instances of 7-Zip.

Parameters:talkative (bool) – Whether to output to screen. False by default.
bbarchivist.utilities.win_seven_zip_local(talkative=False)[source]

If 7-Zip isn’t in the registry, fall back onto supplied executables. If those aren’t there, return “error”.

Parameters:talkative (bool) – Whether to output to screen. False by default.
bbarchivist.utilities.wsz_filecount()[source]

Get count of 7-Zip executables in local folder.

bbarchivist.utilities.wsz_local_bad(talkative=False)[source]

Handle 7-Zip exe name in case of issues.

Parameters:talkative (bool) – Whether to output to screen. False by default.
bbarchivist.utilities.wsz_local_good(talkative=False)[source]

Get 7-Zip exe name if everything is good.

Parameters:talkative (bool) – Whether to output to screen. False by default.
bbarchivist.utilities.wsz_registry()[source]

Check Windows registry for 7-Zip executable location.

bbarchivist.xmlutils module

This module is used for XML handling.

bbarchivist.xmlutils.carrier_child_fileappend(child, files, baseurl, blitz=False)[source]

Append bar file links to a list from a child element.

Parameters:
  • child (xml.etree.ElementTree.Element) – Child element in use.
  • files (list(str)) – Filelist.
  • baseurl (str) – Base URL, URL minus the filename.
  • blitz (bool) – Whether or not to create a blitz package. False by default.
bbarchivist.xmlutils.carrier_child_finder(root, files, baseurl, blitz=False)[source]

Extract filenames, radio and OS from child elements.

Parameters:
  • root (xml.etree.ElementTree.ElementTree) – ElementTree we’re barking up.
  • files (list(str)) – Filelist.
  • baseurl (str) – Base URL, URL minus the filename.
  • blitz (bool) – Whether or not to create a blitz package. False by default.
bbarchivist.xmlutils.carrier_swver_get(root)[source]

Get software release from carrier XML.

Parameters:root (xml.etree.ElementTree.ElementTree) – ElementTree we’re barking up.
bbarchivist.xmlutils.cchecker_get_tags(roottext)[source]

Get country and carrier from XML.

Parameters:roottext (str) – XML text.
bbarchivist.xmlutils.parse_available_bundle(roottext)[source]

Get bundles from XML.

Parameters:roottext (str) – XML text.
bbarchivist.xmlutils.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.xmlutils.parse_sr_lookup(reqtext)[source]

Take the text of a software lookup request response and parse it as XML.

Parameters:reqtext (str) – Response text, hopefully XML formatted.
bbarchivist.xmlutils.prep_available_bundle(device, npc)[source]

Prepare bundle query XML.

Parameters:
  • device (str) – Hexadecimal hardware ID.
  • npc (int) – MCC + MNC (see func:bbarchivist.networkutils.return_npc)
bbarchivist.xmlutils.prep_carrier_query(npc, device, upg, forced)[source]

Prepare carrier query XML.

Parameters:
  • npc (int) – MCC + MNC (see func:return_npc)
  • device (str) – Hexadecimal hardware ID.
  • upg (str) – “upgrade” or “repair”.
  • forced (str) – Force a software release.
bbarchivist.xmlutils.prep_sr_lookup(osver)[source]

Prepare software lookup XML.

Parameters:osver (str) – OS version to lookup, 10.x.y.zzzz.
bbarchivist.xmlutils.sr_lookup_extractor(root)[source]

Take an ElementTree and extract a software release from it.

Parameters:root (xml.etree.ElementTree.ElementTree) – ElementTree we’re barking up.

bbarchivist.xmlutilstcl module

This module is used for XML handling for TCL tools.

bbarchivist.xmlutilstcl.dump_tcl_xml(xmldata, salt)[source]

Write XML responses to output directory.

Parameters:
  • xmldata (str) – Response XML.
  • salt (str) – Salt hash.
bbarchivist.xmlutilstcl.parse_tcl_check(data)[source]

Extract version and file info from TCL update server response.

Parameters:data (str) – The data to parse.
bbarchivist.xmlutilstcl.parse_tcl_download_request(body, mode=4)[source]

Extract file URL and encrypt slave URL from TCL update server response.

Parameters:
  • data (str) – The data to parse.
  • mode (int) – 4 if downloading autoloaders, 2 if downloading OTA deltas.

Module contents

The library portion of bbarchivist.