app.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:dashboard-duty 作者: jrasell 项目源码 文件源码
def index():

    try:
        api_key = os.environ['DASHBOARD_DUTY_KEY']
        service_key = os.environ['DASHBOARD_DUTY_SERVICE']
    except KeyError:
        logging.error('Missing Environment Variable(s)')
        exit(1)

    session = requests.Session()
    d_session = dashboard_duty.Core(session, api_key, service_key)

    service = d_session.service()
    incidents = d_session.incident(service['id'])

    if service['escalation_policy']['escalation_rules'][0]['targets'][0]['type'] == 'schedule_reference':
        service_id = service['escalation_policy']['escalation_rules'][0]['targets'][0]['id']
        oncall = d_session.oncall_schedule_policy(service_id)

    elif service['escalation_policy']['escalation_rules'][0]['targets'][0]['type'] == 'user_reference':
        username = service['escalation_policy']['escalation_rules'][0]['targets'][0]['summary']
        oncall = d_session.oncall_user_policy(username)
    else:
        logging.error('Unable to handle oncall policy for %s' % service_key)
        exit(1)

    return render_template('index.html', service=service, incidents=incidents, oncall=oncall)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号