Polo methods

class marcopolo.bindings.polo.Polo(testing=False)
__init__(testing=False)
has_service(service)

Returns true if the requested service is set to be offered

Parameters:service (string) –

The name of the service.

Please note that in order to check for an user service, the user id has to be complete (user:service)

publish_service(service, params={}, multicast_groups=['224.0.0.112', '224.0.0.113'], permanent=False, root=False)

Registers a service during execution time. See Definition of Services.

Parameters:
  • service (string) –

    Indicates the unique identifier of the service.

    If root is true, the published service will have the same identifier as the value of the parameter. Otherwise, the name of the user will be prepended (<user>:<service>).

  • multicast_groups (set) –

    Indicates the groups where the service shall be published.

    Note that the groups must be defined in the polo.conf file, or otherwise the method will throw an exception.

  • permanent (bool) – If set to true a file will be created and the service will be permanently offered until the file is deleted.
  • root (bool) –

    Stores the file in the marcopolo configuration directory.

    This feature is only available to privileged users, by default root and users in the marcopolo group.

Raise:
PoloException:Raised if the input is not valid (the message of the exception describes where the problem is)
PoloInternalException:
 Raised when internal problems occur. Such problems may be communication timeouts, malformed request/responses, encoding errors...
Returns:

The name of the service as offered. In case of root services, the name will be the value of service. If the service is a user service, it will be published as username:service

Rvalue:

str

service_info(service)

Returns a dictionary with all the information from a service

Parameters:service (string) – The name of the service
set_permanent(service, permanent=True)

Changes the status of a service (permanent/not permanent)

Parameters:
  • service (string) – The name of the service
  • permanent (bool) – Indicates whether the service must be permanent or not
unpublish_service(service, multicast_groups=['224.0.0.112', '224.0.0.113'], delete_file=False)

Removes a service. If the service is permanent, the file is only deleted if delete_file is set to True. Please note that it is required to have the “ownership” of the service (that is, the only user which can remove a service is the user who created it or the Polo instance itself) for the function to be successful. Otherwise, a PoloException will be raised.

Parameters:
  • service (string) – Name of the service
  • multicast_groups (list) – List of the groups where the service is to be deleted. By default deletes the service from all groups
  • delete_file (boolean) – Removes the file service if the service is permanent. Otherwise it is ignored.
verify_parameters(service, multicast_groups=[])

Verifies that the parameters are compliant with the following rules:

  • The service must be a string.
  • The multicast_groups parameter must be a list of valid IPv4 addresses.
Parameters:
  • service (str) – The service identifier.
  • multicast_groups (list) – The list of IPv4 addresses.

Exceptions

class marcopolo.bindings.polo.PoloInternalException

An exception raised when an internal error occurred (for example, an internal communication error)

class marcopolo.bindings.polo.PoloException

An exception raised when an error caused by a misuse of the binding (for example, a bad service ID, an already published service, etc.)