Build information

The following functions and classes allow you to programmatically retrieve version and build information for various components.

Information about Qblox instruments

qblox_instruments.get_build_info() BuildInfo[source]

Get build information for Qblox Instruments.

Returns:

Build information structure for Qblox Instruments.

Return type:

BuildInfo

class qblox_instruments.BuildInfo(version: str | Tuple[int, int, int], build: str | int | datetime, hash: str | int, dirty: str | bool)[source]

Bases: object

Class representing build information for a particular component.

__init__(version: str | Tuple[int, int, int], build: str | int | datetime, hash: str | int, dirty: str | bool)[source]

Makes a build information object.

Parameters:
  • version (Union[str, Tuple[int, int, int]]) – Either a canonical version string or a three-tuple of integers.

  • build (Union[str, int, datetime],) – The build timestamp, either as a string formatted like “17/11/2021-19:04:53” (as used in *IDN?), a Unix timestamp in seconds, or a Python datetime object.

  • hash (Union[str, int]) – The git hash of the repository that the build was run from, either as a hex string with at least 8 characters, or as an integer. If 0x is prefixed, the hash may have less than 8 digits, implying zeros in front.

  • dirty (Union[str, bool]) – Whether the git repository was dirty at the time of the build, either as a 0 or 1 string (as in *IDN?) or as the boolean itself.

property version: Tuple[int, int, int]

The version as a three-tuple.

Type:

Tuple[int, int, int]

property version_str: str

The version as a string.

Type:

str

property build: datetime

The build timestamp as a datetime object.

Type:

datetime

property build_str: str

The build time as a string, as formatted for *IDN?.

Type:

str

property build_iso: str

The build time as a string, formatted using the ISO date format.

Type:

str

property build_unix: int

The build time as a unix timestamp in seconds.

Type:

int

property hash: int

The git hash as an integer.

Type:

int

property hash_str: str

The git hash as a string.

Type:

str

property dirty: bool

Whether the repository was dirty during the build.

Type:

bool

property dirty_str: str

The dirty flag as a 0 or 1 string (as used for *IDN?).

Type:

str

classmethod from_idn(idn: str, prefix: str = '') BuildInfo | None[source]

Constructs a build information structure from an *IDN? string.

Parameters:
  • idn (str) – The *IDN? string.

  • prefix (str) – The prefix used for each key (currently fw, kmod, sw, or cfgMan).

Returns:

The build information structure if data is available for the given key, or None if not.

Return type:

Optional[BuildInfo]

to_idn(prefix: str = '') str[source]

Formats this build information object in the same way *IDN? is formatted.

Parameters:

prefix (str) – The prefix used for each key (currently fw, kmod, sw, or cfgMan).

Returns:

The part of the *IDN? string for this build information object.

Return type:

str

classmethod from_dict(build_data: dict) BuildInfo[source]

Constructs a build information structure from a JSON-capable dict, as used in ZeroMQ/CBOR descriptions, plug&play descriptions, update file metadata, and various other places.

Parameters:

build_data (dict) –

Dictionary with (at least) the following keys:

  • "version": iterable of three integers representing the version;

  • "build": Unix timestamp in seconds representing the build timestamp;

  • "hash": the first 8 hex digits of the git hash as an integer; and

  • "dirty": boolean dirty flag.

Returns:

The build information structure.

Return type:

BuildInfo

to_dict() dict[source]

Formats this build information object as a JSON-capable dict, as used in ZeroMQ/CBOR descriptions, plug&play descriptions, update file metadata, and various other places.

Parameters:

None

Returns:

The generated dictionary, having the following keys:

  • "version": iterable of three integers representing the version;

  • "build": Unix timestamp in seconds representing the build timestamp;

  • "hash": the first 8 hex digits of the git hash as an integer; and

  • "dirty": boolean dirty flag.

Return type:

dict

to_idn_dict() dict[source]

Formats this build information object as a human-readable JSON-capable dict, as used in get_idn.

Returns:

The generated dictionary, having the following keys:

  • "version": string representation of the version;

  • "build": string representation of timestamp in seconds representing the build timestamp;

  • "hash": string representation of the first 8 hex digits of the git hash; and

  • "dirty": boolean dirty flag.

Return type:

dict

to_tuple() tuple[source]

Formats this build information object as a tuple for ordering purposes.

Parameters:

None

Returns:

A tuple, containing all the information in this structure in a canonical format.

Return type:

tuple

Information about an instrument

qblox_instruments.get_device_info(identifier: str | AddressInfo | ConnectionInfo) DeviceInfo[source]

Fetches a complete DeviceInfo structure for the given device.

Parameters:

identifier (Union[str, AddressInfo, ConnectionInfo]) – Instrument identifier. See resolve() for more information.

Returns:

The device information.

Return type:

DeviceInfo

Raises:

RuntimeError – if we failed to connect.

class qblox_instruments.DeviceInfo(manufacturer: str, model: str, serial: str | None = None, sw_build: BuildInfo | None = None, fw_build: BuildInfo | None = None, kmod_build: BuildInfo | None = None, cfg_man_build: BuildInfo | None = None)[source]

Bases: object

Class representing the build and model information of a device. Has the same information content as what *IDN? returns.

__init__(manufacturer: str, model: str, serial: str | None = None, sw_build: BuildInfo | None = None, fw_build: BuildInfo | None = None, kmod_build: BuildInfo | None = None, cfg_man_build: BuildInfo | None = None)[source]
property manufacturer: str

The manufacturer name, in lowercase_with_underscores format.

Type:

str

property model: str

The model name, in lowercase_with_underscores format.

Type:

str

property device: str

The model name, in lowercase_with_underscores format.

Type:

str

property serial: str | None

The serial number, if known.

Type:

Optional[str]

property sw_build: BuildInfo | None

The software/application build information, if known.

Type:

Optional[BuildInfo]

property fw_build: BuildInfo | None

The FPGA firmware build information, if known.

Type:

Optional[BuildInfo]

property kmod_build: BuildInfo | None

The kernel module build information, if known.

Type:

Optional[BuildInfo]

property cfg_man_build: BuildInfo | None

The configuration management build information, if known.

Type:

Optional[BuildInfo]

get_build_info(key: str) BuildInfo | None[source]

Returns build information for the given key.

Parameters:

key (str) –

The key. Must be one of:

  • "sw": returns the application build info;

  • "fw": returns the FPGA firmware build info;

  • "kmod": returns the kernel module build info; or

  • "cfg_man" or "cfgMan": returns the configuration manager build info.

Returns:

The build information structure, if known.

Return type:

Optional[BuildInfo]

Raises:

KeyError – For unknown keys.

classmethod from_idn(idn: str) DeviceInfo[source]

Constructs a device information structure from an *IDN? string.

Parameters:

idn (str) – The *IDN? string.

Returns:

The parsed device information structure.

Return type:

DeviceInfo

to_idn() str[source]

Formats this device information object in the same way *IDN? is formatted.

Returns:

The *IDN? string.

Return type:

str

classmethod from_dict(description: dict) DeviceInfo[source]

Constructs a device information structure from a JSON-capable dict, as used in ZeroMQ/CBOR descriptions, plug&play descriptions, update file metadata, and various other places.

Parameters:

description (dict) –

Dictionary with the following keys:

  • "manufacturer": manufacturer name (string);

  • "model": model name (string);

  • "ser": serial number (string);

  • "sw": application build information (dict);

  • "fw": FPGA firmware build information (dict);

  • "kmod": kernel module build information (dict); and

  • "cfg_man": configuration management build information (dict);

Returns:

The build information structure.

Return type:

DeviceInfo

to_dict() dict[source]

Formats this device information object as a JSON-capable dict, as used in ZeroMQ/CBOR descriptions, plug&play descriptions, update file metadata, and various other places.

Returns:

The generated dictionary, having the following keys:

  • "manufacturer": manufacturer name (string);

  • "model": model name (string);

  • "ser": serial number (string);

  • "sw": application build information (dict);

  • "fw": FPGA firmware build information (dict);

  • "kmod": kernel module build information (dict); and/or

  • "cfg_man": configuration management build information (dict);

Some keys may be omitted if the information is not available.

Return type:

dict

to_idn_dict() dict[source]

Formats this device information object as a human-readable JSON-capable dict, as used get_idn.

Returns:

The generated dictionary, having the following keys:

  • "manufacturer": manufacturer name (string);

  • "model": model name (string);

  • "serial_number": serial number (string);

  • "firmware": build info (dict);
    • "fpga": FPGA firmware build information (dict);

    • "kernel_mod": kernel module build information (dict);

    • "application": application build information (dict); and

    • "driver": driver build information (dict);

Some keys may be omitted if the information is not available.

Return type:

dict

to_tuple() tuple[source]

Formats this device information object as a tuple for ordering purposes.

Returns:

A tuple, containing all the information in this structure in a canonical format.

Return type:

tuple