The utility module is a collection of smaller functions that make the life of plugin programming easier.


Function to be used for deferred translations. Mark strings that should exist as a translation, but not be translated in the moment as N_(‘text’).

Parameter Description
message Text to be marked as a translation

Return: Target XML schema processed by stylesheet as string.

class clacks.common.utils.SystemLoad

The SystemLoad class allows to measure the current system load on Linux style systems.


Get current nodes CPU load.

Return: load level

clacks.common.utils.downloadFile(url, download_dir=None, use_filename=False)

Download file to a local (temporary or preset) path and return the resulting local path for further usage.

Parameter Description
url URL of file to be downloaded.
download_dir Directory where to place the downloaded file.
use_filename use the original filename or a temporary?

Return: local file name


Function to estimate the local timezone shift.

Return: String in the format [+-]hours:minutes


Function to emulate UNIX ‘which’ behavior.

Parameter Description
program Name of the executable to find in the PATH.

Return: Full path of the executable or None

clacks.common.utils.makeAuthURL(url, user, password)

makeAuthURL assembles a typical authentication URL from the plain URL and user/password strings:

Parameter Description
data XML string to be namespace stripped

Return: string without namespace


parseURL parses an URL string using urlparse.urlparse() and gathers extra (partly default) settings regarding the AMQP transport.

Parameter Description
URL URL string

Return: dictionary


stripNS removes the namespace from a plain XML string.

Parameter Description
data XML string to be namespace stripped

Return: string without namespace


Recursive operation which returns a tree formated as dicts and lists. Decision to add a list is to find the ‘List’ word in the actual parent tag.