import os
import sys

def abspath(*x):
    return os.path.join(os.path.abspath(os.path.dirname(__file__)), *x)

static_path = abspath('../../static/')
print(static_path)
templates_path = abspath('../templates/')

DEBUG = True

#
# Custom config. Override in config.py
#

GITHUB_CLIENT_ID = None
GITHUB_CLIENT_SECRET = None


# Mongo config
MONGODB_HOST = 'localhost'
MONGODB_PORT = 27017

# PRIVATE_LINKS = {
#     "url": {
#         "token": "self granted tocken",
#         "password": "password. OPTIONAL",
#         "repos": [{"owner": "repo owner",
#                    "repo": "repo name"}]
#     }
# }
PRIVATE_LINKS = False

if 'GITHUB_SCRUMBOARD' in os.environ:
    if os.environ['GITHUB_SCRUMBOARD'] == "production":
        try:
            from config.production import *
        except ImportError:
            sys.stderr.write("Error: Can't find the file 'config/production.py'")
            sys.exit(1)

    elif os.environ['GITHUB_SCRUMBOARD'] == "test":
        try:
            from config.test import *
        except ImportError:
            sys.stderr.write("Error: Can't find the file 'config/test.py'")
            sys.exit(1)
    else:
        sys.stderr.write("Error: I dont understand what you want :'('")
        sys.exit(1)

else:
    try:
        from config.local import *
    except ImportError:
        sys.stderr.write("Error: Can't find the file 'config/local.py'")
        sys.exit(1)

if not GITHUB_CLIENT_ID:
    raise NotImplementedError("config.GITHUB_CLIENT_ID cant be None")

if not GITHUB_CLIENT_SECRET:
    raise NotImplementedError("config.GITHUB_CLIENT_SECRET cant be None")
