pyrekordbox.utils#

This module contains common constants and methods used in other modules.

pyrekordbox.utils.warn_deprecated(name, new_name='', hint='', remove_in='')[source]#
pyrekordbox.utils.get_process_id(name, raise_exec=False)[source]#

Returns the ID of a process if it exists.

Parameters:
namestr

The name of the process, for example ‘rekordbox’.

raise_execbool, optional

Raise an exception if the process can not be found.

Returns:
pidint

The ID of the process if it exists, otherwise zero.

Raises:
RuntimeError: If raise_exec=True, raises a runtime error if the application

is not running.

Examples

>>> get_process_id("rekordbox")
12345
>>> get_process_id("rekordboxAgent")
23456
pyrekordbox.utils.get_rekordbox_pid(raise_exec=False)[source]#

Returns the process ID of the Rekordbox application.

Parameters:
raise_execbool, optional

Raise an exception if the Rekordbox process can not be found.

Returns:
pidint

The ID of the Rekordbox process if it exists, otherwise zero.

Raises:
RuntimeError: If raise_exec=True, raises a runtime error if the Rekordbox

application is not running.

Examples

>>> get_rekordbox_pid()
12345
pyrekordbox.utils.get_rekordbox_agent_pid(raise_exec=False)[source]#

Returns the process ID of the RekordboxAgent application.

Parameters:
raise_execbool, optional

Raise an exception if the RekordboxAgent process can not be found.

Returns:
pidint

The ID of the RekordboxAgent process if it exists, otherwise zero.

Raises:
RuntimeError: If raise_exec=True, raises a runtime error if the RekordboxAgent

application is not running.

Examples

>>> get_rekordbox_agent_pid()
23456
pyrekordbox.utils.pretty_xml(element, indent=None, encoding='utf-8')[source]#

Generates a formatted string of an XML element.

Parameters:
elementxml.etree.cElementTree.Element

The input XML element.

indentstr, optional

The indentation used for formatting the XML element. The default is 3 spaces.

encodingstr, optional

The encoding used for formatting the XML element. The default is ‘utf-8’.

Returns:
xml_stringstr

The formatted string of the XML element.

Notes

This method is needed for Python 3.8 and below. Starting with Python 3.9 the XML module has a built-in pretty-print function:

>>> tree = xml.ElementTree(root)  # noqa
>>> xml.indent(tree, space="\t", level=0)
>>> tree.write(path, encoding="utf-8", xml_declaration=True)  # noqa

This method will be used as soon support for Python 3.8 and below is dropped.

pyrekordbox.utils.obfuscate(plaintext)[source]#

Obfuscates a plaintext string using zlib compression and XOR encryption.

pyrekordbox.utils.deobfuscate(blob)[source]#

Deobfuscates a previously obfuscated string.