# Path: zoe_lib/config.py
# def get_conf() -> Namespace:
#     """Returns the conf singleton."""
#     return _CONF


from datetime import timedelta, datetime
from typing import List, Union
from zoe_lib.config import get_conf
import logging
import os
import zoe_api.exceptions
import zoe_api.master_api
import zoe_lib.applications
import zoe_lib.exceptions
import zoe_lib.state
        if status:
            self.sql.executions.delete(exec_id)
        else:
            raise zoe_api.exceptions.ZoeRestAPIException(message)

    def service_by_id(self, user: zoe_lib.state.User, service_id: int) -> zoe_lib.state.Service:
        """Lookup a service by its ID."""
        service = self.sql.services.select(id=service_id, only_one=True)
        if service is None:
            raise zoe_api.exceptions.ZoeNotFoundException('No such execution')
        if service.user_id != user.id and not user.role.can_operate_others:
            raise zoe_api.exceptions.ZoeAuthException()
        return service

    def service_list(self, user: zoe_lib.state.User, **filters):
        """Generate a optionally filtered list of services."""
        if not user.role.can_operate_others:
            filters['user_id'] = user.id
        return self.sql.services.select(**filters)

    def service_logs(self, user: zoe_lib.state.User, service_id):
        """Retrieve the logs for the given service.
        If stream is True, a file object is returned, otherwise the log contents as a str object.
        """
        service = self.sql.services.select(id=service_id, only_one=True)
        if service is None:
            raise zoe_api.exceptions.ZoeNotFoundException('No such service')
        if service.user_id != user.id and not user.role.can_operate_others:
            raise zoe_api.exceptions.ZoeAuthException()


# Path: zoe_lib/config.py
# def get_conf() -> Namespace:
#     """Returns the conf singleton."""
#     return _CONF


# Path: zoe_api/api_endpoint.py
from datetime import timedelta, datetime
from typing import List, Union
from zoe_lib.config import get_conf
import logging
import os
import zoe_api.exceptions
import zoe_api.master_api
import zoe_lib.applications
import zoe_lib.exceptions
import zoe_lib.state

        if status:
            self.sql.executions.delete(exec_id)
        else:
            raise zoe_api.exceptions.ZoeRestAPIException(message)

    def service_by_id(self, user: zoe_lib.state.User, service_id: int) -> zoe_lib.state.Service:
        """Lookup a service by its ID."""
        service = self.sql.services.select(id=service_id, only_one=True)
        if service is None:
            raise zoe_api.exceptions.ZoeNotFoundException('No such execution')
        if service.user_id != user.id and not user.role.can_operate_others:
            raise zoe_api.exceptions.ZoeAuthException()
        return service

    def service_list(self, user: zoe_lib.state.User, **filters):
        """Generate a optionally filtered list of services."""
        if not user.role.can_operate_others:
            filters['user_id'] = user.id
        return self.sql.services.select(**filters)

    def service_logs(self, user: zoe_lib.state.User, service_id):
        """Retrieve the logs for the given service.
        If stream is True, a file object is returned, otherwise the log contents as a str object.
        """
        service = self.sql.services.select(id=service_id, only_one=True)
        if service is None:
            raise zoe_api.exceptions.ZoeNotFoundException('No such service')
        if service.user_id != user.id and not user.role.can_operate_others:
            raise zoe_api.exceptions.ZoeAuthException()


        path = os.path.join(get_conf().service_logs_base_path, get_conf().deployment_name, str(service.execution_id), service.name + '.txt')