Copyright 2016 Peter Dahlberg Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. from bottle import route, template, request, post, Bottle, HTTPError, auth_basic from pprint import pformat from itertools import islice from functools import wraps import logging import sys log = logging.getLogger(__name__) app = Bottle() def _auth_basic(fn): @wraps(fn) def wrapper(*args, **kwargs): authfn = app.config.get("auth_basic_fn") if authfn: return auth_basic(authfn)(fn)(*args, **kwargs) else: return fn(*args, **kwargs) return wrapper def set_schedulers(**name_scheduler_mapping): app.config["deploy.schedulers"] = name_scheduler_mapping def set_runners(**name_runner_mapping): app.config["deploy.runners"] = name_runner_mapping def set_auth_basic_fn(fn): app.config["auth_basic_fn"] = fn def _get_runner(name): try: runners = app.config["deploy.runners"] except KeyError as e: sys.exit("you have to call set_runners first") return runners[name] @app.route('/') def status(): tpl = """
{{pformat(bs.payload, width=120)}}