12. Module Reference¶
This chapter contains all the documentation auto-generated from the source code. It is probably not terribly useful for reading through, but may be useful as a searchable reference.
Contains the functions that make up the piw-initdb script.
This is the main function for the piw-initdb script. It creates the piwheels database required by the master or, if it already exists, upgrades it to the current version of the application.
Test that the user for conn is a cluster superuser (so we can drop and create anything we want in the database), and that test_user (which will be granted limited rights to various objects for the purposes of the piw-master script) exists and is not a cluster superuser.
Detect the version of the database. This is typically done by reading the contents of the
configurationtable, but before that was added we can guess a couple of versions based on what tables exist (or don’t). Returns
Noneif the database appears uninitialized, and raises
RuntimeErroris the version is so ancient we can’t do anything with it.
Return an SQLAlchemy connection to the specified dsn or raise
RuntimeErrorif the database doesn’t exist (the administrator is expected to create the database before running this script).
Generate the script to get the database from version (the result of
detect_version()) to the current version of the software. If version is
None, this is simply the contents of the
sql/create_piwheels.sqlscript. Otherwise, it is a concatenation of various update scripts.
This is an extremely crude statement splitter for PostgreSQL’s dialect of SQL. It understands
$delim$ extended strings $delim$, but not
/* C-style comments */. If you start using such things in the update scripts, you’ll need to extend this function to accommodate them.
It returns a generator which yields individiual statements from script, delimited by semi-colon terminators.
This module defines several classes which permit interested tasks to track the
state of build slaves (
SlaveState), file transfers
TransferState), build attempts (
FileState) and various loggers.
FileState(filename, filesize, filehash, package_tag, package_version_tag, py_version_tag, abi_tag, platform_tag, dependencies, transferred=False)¶
Represents the state of an individual build artifact (a package file, or wheel) including its
filesize, the SHA256
filehash, and various tags extracted from the build. Also tracks whether or not the file has been
- filename (str) – The original filename of the build artifact.
- filesize (int) – The size of the file in bytes.
- filehash (str) – The SHA256 hash of the file contents.
- package_tag (str) – The package tag extracted from the filename (first “-” separated component).
- package_version_tag (str) – The package version tag extracted from the filename (second “-” separated component).
- py_version_tag (str) – The python version tag extracted from the filename (third from last “-” separated component).
- abi_tag (str) – The python ABI tag extracted from the filename (second from last “-” separated component).
- platform_tag (str) – The platform tag extracted from the filename (last “-” separated component).
- dependencies (set) – The set of dependencies that are required to use this particular wheel.
- transferred (bool) –
Trueif the file has been transferred from the build slave that generated it to the file server.
Called to set
Trueafter a file transfer has been successfully verified.
BuildState(slave_id, package, version, abi_tag, status, duration, output, files, build_id=None)¶
Represents the state of a package build including the
duration, and all the lines of
filesattribute is a mapping containing details of each successfully built package file.
- slave_id (int) – The master’s identifier for the build slave.
- package (str) – The name of the package to build.
- version (str) – The version number of the package to build.
- abi_tag (str) – The ABI for which the build was attempted (must not be
- status (bool) –
Trueif the build succeeded,
Falseif it failed.
- duration (timedelta) – The amount of time (in seconds) it took to complete the build.
- output (str) – The log output of the build.
- files (dict) – A mapping of filenames to
FileStateobjects for each artifact produced by the build.
- build_id (int) – The integer identifier generated for the build by the database
Noneuntil the build has been inserted into the database).
Called to fill in the build’s ID in the backend database.
Returns the filename of the next file that needs transferring or
Noneif all files have been transferred.
Trueif all files have been transferred.
SlaveState(address, timeout, native_py_version, native_abi, native_platform, label)¶
Tracks the state of a build slave. The master updates this state which each request and reply sent to and received from the slave, and this class in turn manages the associated
transfer). The class also tracks the time a request was last seen from the build slave, and includes a
Tracks the state of a file transfer. All file transfers are held in temporary locations until
verify()indicates the transfer was successful, at which point they are atomically renamed into their final location.
The state is intimately tied to the file transfer protocol and includes methods to write a recevied
chunk(), and to determine the next chunk to
fetch(), as well as a property to determine when the transfer is
A set of utility routines for efficiently tracking byte ranges within a stream. These are used to track which chunks of a file have been received during file transfers from build slaves.
FileJuggler for the usage of these functions.
Given a list of ranges in ascending order, this generator function returns the list with any overlapping ranges consolidated into individual ranges. For example:
>>> list(consolidate([range(0, 5), range(4, 10)])) [range(0, 10)] >>> list(consolidate([range(0, 5), range(5, 10)])) [range(0, 10)] >>> list(consolidate([range(0, 5), range(6, 10)])) [range(0, 5), range(6, 10)]
Given a list of non-overlapping ranges in ascending order, and a range ex to exclude, this generator function returns ranges with all values covered by ex removed from any contained ranges. For example:
>>> list(exclude([range(10)], range(2))) [range(2, 10)] >>> list(exclude([range(10)], range(2, 4))) [range(0, 2), range(4, 10)]
Given two ranges range1 and range2 (which must both have a step of 1), returns the range formed by the intersection of the two ranges, or
Noneif the ranges do not overlap. For example:
>>> intersect(range(10), range(5)) range(0, 5) >>> intersect(range(10), range(10, 2)) >>> intersect(range(10), range(2, 5)) range(2, 5)
Given a list of non-overlapping ranges in ascending order, this generator function returns the list with the range containing i split into two ranges, one ending at i and the other starting at i. If i is not contained in any of the ranges, then ranges is returned unchanged. For example:
>>> list(split([range(10)], 5)) [range(0, 5), range(5, 10)] >>> list(split([range(10)], 0)) [range(0, 10)] >>> list(split([range(10)], 20)) [range(0, 10)]