cleep package

cleep.bus module

cleep.common module

This file shares some constants and classes

class CATEGORIES

Bases: object

Cleep application categories

ALL = ['APPLICATION', 'MOBILE', 'DRIVER', 'HOMEAUTOMATION', 'MEDIA', 'SERVICE', 'HOBBY']
APPLICATION = 'APPLICATION'
DRIVER = 'DRIVER'
HOBBY = 'HOBBY'
HOMEAUTOMATION = 'HOMEAUTOMATION'
MEDIA = 'MEDIA'
MOBILE = 'MOBILE'
SERVICE = 'SERVICE'
class ExecutionStep

Bases: object

Cleep execution steps

BOOT = 0
CONFIG = 2
INIT = 1
RUN = 3
STOP = 4
class MessageRequest(command=None, event=None, params={}, to=None)

Bases: object

Object that holds message request

A message request is composed of:

  • in case of a command:

    • a command name

    • command parameters

    • the command sender

  • in case of an event:

    • an event name

    • event parameters

    • propagate flag to say if event can be propagated out of the device

    • a device id

    • a startup flag that indicates this event was sent during cleep startup

Attribute peer_infos is filled when message comes from oustide. This field must also be filled when message is intented to be sent to outside.

Members:

command (string): command name event (string): event name propagate (bool): True if event can be propagated out of the device [event only] params (dict): list of event or command parameters to (string): message module recipient sender (string): message sender [command only] device_id (string): internal virtual device identifier [event only] peer_infos (PeerInfos): peer informations. Must be filled if message comes from outside the device

Note

A message cannot be a command and an event, priority to command if both are specified.

fill_from_dict(request)

Fill instance from other request

Parameters

request (dict) – message request infos

fill_from_request(request)

Fill instance from other request

Parameters

request (MessageRequest) – message request instance

is_broadcast()

Return broadcast status

Returns

True if the request is broadcast

Return type

bool

is_command()

Return true if message is a command. If not it is an event

Returns

True if message is a command, otherwise it is an event

Return type

bool

is_external_event()

Return True if event comes from external device

Returns

True if event comes from external device

Return type

bool

to_dict(startup=False, external_sender=None)

Convert message request to dict object

Params:

startup (bool): True if the message is startup message external_sender (string): specify module name that handles message from external bus

Raises

InvalidMessage if message is not valid

class MessageResponse(error=False, message='', data=None, broadcast=False)

Bases: object

Object that holds message response

A response is composed of:

  • an error flag: True if error, False otherwise

  • a message: a message about request

  • some data: data returned by the request

fill_from_dict(response)

Fill from dict

Parameters

response (dict) – response as dict

fill_from_response(response)

Fill from other response

Parameters

response (MessageResponse) – message response instance

to_dict()

Return message response as dict

Returns

message response as dict:

{
    error (bool): True if error occured, False otherwise,
    message (str): response message. Can be an error message or info message
    data (any): response data
}

Return type

dict

class PeerInfos(uuid=None, ident=None, hostname=None, ip=None, port=80, ssl=False, macs=None, cleepdesktop=False, extra={})

Bases: object

Stores peer informations

fill_from_dict(peer_infos)

Fill infos from dict

Parameters

peer_infos (dict) – peer informations

to_dict(with_extra=False)

Return peer infos as dict

Parameters

with_extra (bool) – add extra data

Returns

peer infos

Return type

dict

cleep.core module

cleep.exception module

Cleep exceptions

exception BusError(message)

Bases: Exception

Generic bus error exception

exception CommandError(message)

Bases: Exception

Exception used when module command failed. Message will be toasted on UI.

exception CommandInfo(message)

Bases: Exception

Exception used to toast a message from backend on UI while command succeed. Message will be toasted on ui

exception InvalidMessage

Bases: Exception

InvalidMessage is raised when an invalid message is sent to bus.

exception InvalidModule(module)

Bases: Exception

InvalidModule is raised when an unknown application is requested

exception InvalidParameter(message)

Bases: Exception

InvalidParameter is raised when invalid command parameter is detected

exception MissingParameter(message)

Bases: Exception

MissingParameter is raised when missing command parameter is detected

exception NoMessageAvailable

Bases: Exception

Exception raised when no message is available. Typically when bus pull process reaches end of timeout and no message was received, it will raise this exception.

exception NoResponse(to, timeout, value)

Bases: Exception

Exception raised when no response is received while it does. Typically when a command takes too long to be processed and timeout is reached.

exception ResourceNotAvailable(resource)

Bases: Exception

Exception raised when no requested Cleep resource is not available. See CleepResource for more information.

exception Unauthorized(message)

Bases: Exception

Generic Unauthorized exception is raised when there is a problem with credentials.

cleep.inventory module

cleep.rpcserver module