buildcat module

Provides the Buildcat public API, for use by clients and integrations.

exception buildcat.Error(message, description)[source]

Bases: Exception

Base class for all Buildcat exceptions.

Parameters:
  • message (str required) – Short message describing the failure.

  • description (str required) – Detailed description of the failure, including possible remediations.

class buildcat.Serializer[source]

Bases: object

RQ serializer that uses Python pickle version 2.

We use this serializer with workers / queues, so Python 2 clients can be used with Python 3 workers.

dumps(*, protocol=2, fix_imports=True)

Return the pickled representation of the object as a bytes object.

The optional protocol argument tells the pickler to use the given protocol; supported protocols are 0, 1, 2, 3 and 4. The default protocol is 3; a backward-incompatible protocol designed for Python 3.

Specifying a negative protocol version selects the highest protocol version supported. The higher the protocol used, the more recent the version of Python needed to read the pickle produced.

If fix_imports is True and protocol is less than 3, pickle will try to map the new Python 3 names to the old module names used in Python 2, so that the pickle data stream is readable with Python 2.

loads(*, fix_imports=True, encoding='ASCII', errors='strict')

Read and return an object from the given pickle data.

The protocol version of the pickle is detected automatically, so no protocol argument is needed. Bytes past the pickled object’s representation are ignored.

Optional keyword arguments are fix_imports, encoding and errors, which are used to control compatibility support for pickle stream generated by Python 2. If fix_imports is True, pickle will try to map the old Python 2 names to the new names used in Python 3. The encoding and errors tell pickle how to decode 8-bit string instances pickled by Python 2; these default to ‘ASCII’ and ‘strict’, respectively. The encoding can be ‘bytes’ to read these 8-bit string instances as bytes objects.

buildcat.check_call(command)[source]

Run a command using subprocess.check_call().

buildcat.check_output(command)[source]

Run a command using subprocess.check_output().

buildcat.connect(*, host='127.0.0.1', port=6379, timeout=None)[source]

Connect to a listening Buildcat server.

Parameters:
  • host (str optional) – IP address or hostname of the Buildcat server. Defaults to the local loopback adapter.

  • port (int, optional) – Port number of the Buildcat server. Defaults to 6379.

  • timeout (number, optional) – Maximum time to spend waiting for a connection, in seconds. Default: never timeout.

Returns:

connection – Persistent connection to the listening server.

Return type:

redis.Redis instance

Raises:

Error – If there are any problems connecting to the server.

buildcat.executable(name)[source]

Return the platform-specific name of an executable.

Parameters:

name (str, required) – Name of the executable.

Returns:

name – The executable name, with platform-specific additions (such as .exe on Windows).

Return type:

str

buildcat.info()[source]

Returns information about the current process.

The result is intended for use by integrations that return worker information.

Returns:

metadata – A collection of key-value pairs containing information describing the current process.

Return type:

dict

buildcat.queue(*, queue='default', host='127.0.0.1', port=6379, timeout=5)[source]

Connect to a Buildcat server queue.

Parameters:
  • queue (str, optional) – Name of the queue to connect.

  • host (str, optional) – IP address or hostname of the Buildcat server. Defaults to the local loopback adapter.

  • port (int, optional) – Port number of the Buildcat server. Defaults to 6379.

  • timeout (number, optional) – Maximum time to spend waiting for a connection, in seconds. Default: 5 seconds.

Returns:

  • connection (redis.Redis instance) – Persistent connection to the listening server.

  • queue (rq.Queue instance) – Queue object.

Raises:

Error – If there are any problems connecting to the server.

buildcat.require_relative_path(path, description)[source]

Raise an exception if a path isn’t relative.

Parameters:
  • path (str, required) – Path to check.

  • description (str, required) – Description of the path, used for raised exceptions.

Returns:

path – The path.

Return type:

str instance

Raises:

Error – If the path isn’t relative.

buildcat.root()[source]

Return the worker root directory.

Returns:

root – The worker’s root directory.

Return type:

str

buildcat.submit(queue, command, *args, **kwargs)[source]

Warning

function ‘buildcat.submit’ undocumented

buildcat.wait(*, connection, job)[source]

Warning

function ‘buildcat.wait’ undocumented