def __iter__(self): backend_options = sorted( [(k, Markup(f'<b>{k.capitalize()}</b><br>{v.__doc__.strip()}')) for k, v in get_backends().items()], key=operator.itemgetter(1)) for backend_option in backend_options: yield backend_option
def get_backend(state): backend_name = None backend_field_name = f'{state.type}_backend_settings' if state.account and getattr(state.account, backend_field_name): backend_name = state.account[backend_field_name].get('_backend') else: backend_name = request.values.get('backend') if backend_name: state.backend = get_backends().get(backend_name)
def flax_status(self, request): """Get the status of the flax server. """ import version backend_list = backends.get_backends() backend_versions = dict( (name, backend.version_info()) for name, backend in backend_list) return { 'versions': { 'SERVER': version.SERVER_VERSION, 'PROTOCOL': version.PROTOCOL_VERSION, }, 'backends': backend_versions, }
def _do_status(status, docker): """ Call the 'status' callback on all registered backends. :param status: 'start', 'stop' or similar :param docker: :return: """ for backend in get_backends(): cb = None if hasattr(backend, status): cb = getattr(backend, status) try: if cb and hasattr(cb, '__call__'): logger.debug('Calling backend {!r}:{!s}'.format(backend, status)) cb(docker.info) else: if hasattr(backend, '__call__'): # backend has a default __call__ function for all statuses logger.debug('Calling backend {!r} ({!r})'.format(backend, status)) backend(status, docker.info) except Exception: logger.exception('Backend {!r} failed status()'.format(backend))
def get_backends(): """ Return a list of dictionaries describing the available backends. """ return backends.get_backends()