Ejemplo n.º 1
0
        def get_actions(self):
            """
                **Return a list of actions available for the service**

                Returns a list of available actions for the service.

                :return: List of actions available for this service
                :rtype: list
            """

            if self.description == exceptions.NotAvailableError:
                raise exceptions.NotAvailableError(
                    'Can\'t get actions because a description for this service is'
                    ' not available.')
            return list(self.actions.values())
Ejemplo n.º 2
0
        def __getattr__(self, action_name):
            """
                **Allow executing an action through an attribute**

                Allows executing the specified action on the service through an attribute.

                :param action_name: Name of the action to execute on the service
                :return: Response from the device's service after executing the specified action
                :rtype: dict
            """

            if self.description == exceptions.NotAvailableError:
                raise exceptions.NotAvailableError(
                    'Can\'t execute actions because a description for this service is'
                    ' not available.')

            try:
                return self.actions[action_name]
            except KeyError:
                raise exceptions.ActionNotFoundError(
                    f'The "{action_name}" action is not available for this service.',
                    action_name)