# Path: isserviceup/api/auth.py
# def oauth_callback():
# 
# Path: isserviceup/api/status.py
# @mod.route('', methods=['GET'])
# @authenticated(blocking=False)
# def status(user):
#     type = request.args.get('type')
#     favorite_services = []
# 
#     services = SERVICES.values()
# 
#     if user:
#         favorite_services = get_favorite_services(str(user.id))
# 
#     if type == 'favorite':
#         services = favorite_services
#         for service in services:
#             service.star = True
#     else:
#         favorite_services = {x.name: True for x in favorite_services}
# 
#     values = get_services_status(managers.rclient, services)
# 
#     data = []
#     for i, service in enumerate(services):
#         status = values[i] if values[i] else Status.unavailable
#         star = True if type == 'favorite' else (service.name in favorite_services)
#         s = {
#             'name': service.name,
#             'icon_url': service.icon_url,
#             'status_url': service.status_url,
#             'status': status.name,
#             'star': star,
#             'id': service.id,
#         }
#         data.append(s)
# 
#     return jsonify({
#         'data': {
#             'services': data,
#         }
#     })
# 
# Path: isserviceup/api/user.py
# def get_user(user):
# def edit_user(user):
# def logout(user):
# def star(user):
# 
# Path: isserviceup/config/config.py
# def s2l(x):
# def ensure_private_ssh_key():
# def get_status_description():
# DEBUG = config('DEBUG', cast=bool, default=False)
# FRONTEND_URL = config('FRONTEND_URL', default='http://localhost:8000/')
# REDIS_URL = config('REDIS_URL', default='redis://redis:devpassword@redis')
# MONGO_URL = config('MONGO_URL', default='mongodb://mongo/isserviceup')
# STATUS_UPDATE_INTERVAL = config('STATUS_UPDATE_INTERVAL', cast=int, default=30)
# SERVE_STATIC_FILES = config('SERVE_STATIC_FILES', cast=bool, default=True)
# SENTRY_DSN = config('SENTRY_DSN', default=None)
# CELERY_EAGER = config('CELERY_EAGER', cast=bool, default=False)
# CELERY_BROKER = config('CELERY_BROKER', default=REDIS_URL)
# CELERY_BACKEND = config('CELERY_BACKEND', default=REDIS_URL)
# GITHUB_CLIENT_ID = config('GITHUB_CLIENT_ID', default=None)
# GITHUB_CLIENT_SECRET = config('GITHUB_CLIENT_SECRET', default=None)
# SLACK_WEB_HOOK_URL = config('SLACK_WEB_HOOK_URL', default=None)
# NOTIFIERS = [
#     # Slack(SLACK_WEB_HOOK_URL)
# ]
# NOTIFY_ON_STARTUP = config('NOTIFY_ON_STARTUP', default=False, cast=bool)
# CACHET_NOTIFIER = config('CACHET_NOTIFIER', default=False, cast=bool)
# SERVICES = config('SERVICES', cast=s2l, default=None)
# PRIVATE_SSH_KEY = config('PRIVATE_SSH_KEY', default='')
#             PRIVATE_SSH_KEY = ''
# 
# Path: isserviceup/helpers/exceptions.py
# class ApiException(Exception):
#     def __init__(self, message, status_code=400, **kwargs):
# def format_exception(message, code=None, extra=None):
# def handle_exception(error):
# 
# Path: isserviceup/helpers/exceptions.py
# class ApiException(Exception):
#     def __init__(self, message, status_code=400, **kwargs):
#         super(ApiException, self).__init__()
#         self.message = message
#         self.status_code = status_code
#         self.extra = kwargs


import logging
import traceback
from flask import Flask, jsonify
from flask_cors import CORS
from raven.contrib.flask import Sentry
from isserviceup.api import auth as auth_bp
from isserviceup.api import status as status_bp
from isserviceup.api import user as user_bp
from isserviceup.config import config
from isserviceup.helpers import exceptions
from isserviceup.helpers.exceptions import ApiException



static_url_path = '' if config.SERVE_STATIC_FILES else None
static_folder = '../frontend/dist' if config.SERVE_STATIC_FILES else None
app = Flask(__name__, static_url_path=static_url_path, static_folder=static_folder)
app.config.from_object(config)

# Path: isserviceup/api/auth.py
# def oauth_callback():
# 
# Path: isserviceup/api/status.py
# @mod.route('', methods=['GET'])
# @authenticated(blocking=False)
# def status(user):
#     type = request.args.get('type')
#     favorite_services = []
# 
#     services = SERVICES.values()
# 
#     if user:
#         favorite_services = get_favorite_services(str(user.id))
# 
#     if type == 'favorite':
#         services = favorite_services
#         for service in services:
#             service.star = True
#     else:
#         favorite_services = {x.name: True for x in favorite_services}
# 
#     values = get_services_status(managers.rclient, services)
# 
#     data = []
#     for i, service in enumerate(services):
#         status = values[i] if values[i] else Status.unavailable
#         star = True if type == 'favorite' else (service.name in favorite_services)
#         s = {
#             'name': service.name,
#             'icon_url': service.icon_url,
#             'status_url': service.status_url,
#             'status': status.name,
#             'star': star,
#             'id': service.id,
#         }
#         data.append(s)
# 
#     return jsonify({
#         'data': {
#             'services': data,
#         }
#     })
# 
# Path: isserviceup/api/user.py
# def get_user(user):
# def edit_user(user):
# def logout(user):
# def star(user):
# 
# Path: isserviceup/config/config.py
# def s2l(x):
# def ensure_private_ssh_key():
# def get_status_description():
# DEBUG = config('DEBUG', cast=bool, default=False)
# FRONTEND_URL = config('FRONTEND_URL', default='http://localhost:8000/')
# REDIS_URL = config('REDIS_URL', default='redis://redis:devpassword@redis')
# MONGO_URL = config('MONGO_URL', default='mongodb://mongo/isserviceup')
# STATUS_UPDATE_INTERVAL = config('STATUS_UPDATE_INTERVAL', cast=int, default=30)
# SERVE_STATIC_FILES = config('SERVE_STATIC_FILES', cast=bool, default=True)
# SENTRY_DSN = config('SENTRY_DSN', default=None)
# CELERY_EAGER = config('CELERY_EAGER', cast=bool, default=False)
# CELERY_BROKER = config('CELERY_BROKER', default=REDIS_URL)
# CELERY_BACKEND = config('CELERY_BACKEND', default=REDIS_URL)
# GITHUB_CLIENT_ID = config('GITHUB_CLIENT_ID', default=None)
# GITHUB_CLIENT_SECRET = config('GITHUB_CLIENT_SECRET', default=None)
# SLACK_WEB_HOOK_URL = config('SLACK_WEB_HOOK_URL', default=None)
# NOTIFIERS = [
#     # Slack(SLACK_WEB_HOOK_URL)
# ]
# NOTIFY_ON_STARTUP = config('NOTIFY_ON_STARTUP', default=False, cast=bool)
# CACHET_NOTIFIER = config('CACHET_NOTIFIER', default=False, cast=bool)
# SERVICES = config('SERVICES', cast=s2l, default=None)
# PRIVATE_SSH_KEY = config('PRIVATE_SSH_KEY', default='')
#             PRIVATE_SSH_KEY = ''
# 
# Path: isserviceup/helpers/exceptions.py
# class ApiException(Exception):
#     def __init__(self, message, status_code=400, **kwargs):
# def format_exception(message, code=None, extra=None):
# def handle_exception(error):
# 
# Path: isserviceup/helpers/exceptions.py
# class ApiException(Exception):
#     def __init__(self, message, status_code=400, **kwargs):
#         super(ApiException, self).__init__()
#         self.message = message
#         self.status_code = status_code
#         self.extra = kwargs


# Path: isserviceup/app.py
import logging
import traceback
from flask import Flask, jsonify
from flask_cors import CORS
from raven.contrib.flask import Sentry
from isserviceup.api import auth as auth_bp
from isserviceup.api import status as status_bp
from isserviceup.api import user as user_bp
from isserviceup.config import config
from isserviceup.helpers import exceptions
from isserviceup.helpers.exceptions import ApiException




static_url_path = '' if config.SERVE_STATIC_FILES else None
static_folder = '../frontend/dist' if config.SERVE_STATIC_FILES else None
app = Flask(__name__, static_url_path=static_url_path, static_folder=static_folder)
app.config.from_object(config)

app.debug = config.DEBUG