daemon.helper module

class daemon.helper.classproperty(fget)[source]

Bases: object

Helper class to read property inside a classmethod

daemon.helper.id_cleaner(docker_id, prefix=’sha256:’)[source]

Get 1st 10 characters in id created by docker

  • Parameters

    • docker_id (str) – id of docker object

    • prefix (str) – defaults to ‘sha256:’

    Return type

    str

    Returns

    shorter id

daemon.helper.get_workspace_path(workspace_id, \args*)[source]

get the path to the ws

  • Parameters

    • workspace_id (DaemonID) – the id of the ws

    • args – paths to join

    Returns

    the full path

daemon.helper.is_error_message(s)[source]

Check if the string matches an exception regex. :param s: the string to check :rtype: bool :return: whether or not it matches

daemon.helper.get_log_file_path(log_id)[source]

Get logfile path from id

  • Parameters

    log_id (DaemonID) – DaemonID in the store

    Return type

    Tuple[str, ForwardRef]

    Returns

    logfile path, workspace_id for log_id

daemon.helper.if_alive(func, raise_type=None)[source]

Decorator to be used in store for connection valiation

  • Parameters

    • func (Callable) – function to be wrapped

    • raise_type (Optional[Exception]) – Exception class to be raied

    Returns

    wrapped function

daemon.helper.error_msg_from(response)[source]

Get error message from response

  • Parameters

    response (Dict) – dict response

    Return type

    str

    Returns

    prettified response string

daemon.helper.change_cwd(path)[source]

Change the current working dir to path in a context and set it back to the original one when leaves the context. Yields nothing :param path: Target path. :yields: nothing

daemon.helper.change_env(key, val)[source]

Change the environment of key to val in a context and set it back to the original one when leaves the context. :param key: Old environment variable. :param val: New environment variable. :yields: nothing