# Path: dockci/server.py
# CONFIG = Config()
# 
# DB = WrappedSQLAlchemy()
# 
# OAUTH_APPS = {}
# 
# Path: dockci/util.py
# def ext_url_for(endpoint, **values):
#     """ Use ``external_url`` from config to build a full URL """
#     from dockci.server import CONFIG
# 
#     if not CONFIG.external_url:
#         return None
# 
#     ext_url = urlparse(CONFIG.external_url)
#     method = values.pop('_method', None)
#     return current_app.url_map.bind(
#         ext_url.netloc,
#         script_name=ext_url.path,
#         url_scheme=values.pop('_scheme', ext_url.scheme),
#     ).build(
#         endpoint,
#         values,
#         method=method,
#         force_external=True,
#     )


import logging
import re
import py.error  # pylint:disable=import-error
import sqlalchemy
from urllib.parse import quote_plus, urlparse, urlunparse
from uuid import uuid4
from flask import url_for
from .base import RepoFsMixin
from .db_types import RegexType
from dockci.server import CONFIG, DB, OAUTH_APPS
from dockci.util import ext_url_for
        from .job import Job
        from .job import Job
        from .job import Job
        """
        secret = uuid4().hex
        self.github_secret = secret
        endpoint = '%s/hooks' % self.github_api_repo_endpoint
        result = OAUTH_APPS['github'].post(endpoint, {
            'name': 'web',
            'events': ['push'],
            'active': True,
            'config': {
                'url': self.job_new_url_ext,
                'secret': secret,
                'content_type': 'json',
                'insecure_ssl': '0',
            },
        }, format='json')

        if result.status == 201:
            try:
                self.github_hook_id = result.data['id']

            except KeyError:
                pass

            DB.session.add(self)
            DB.session.commit()

        return result

    def delete_github_webhook(self, save=True):
        """ Utility to delete the associated GitHub web hook """

# Path: dockci/server.py
# CONFIG = Config()
# 
# DB = WrappedSQLAlchemy()
# 
# OAUTH_APPS = {}
# 
# Path: dockci/util.py
# def ext_url_for(endpoint, **values):
#     """ Use ``external_url`` from config to build a full URL """
#     from dockci.server import CONFIG
# 
#     if not CONFIG.external_url:
#         return None
# 
#     ext_url = urlparse(CONFIG.external_url)
#     method = values.pop('_method', None)
#     return current_app.url_map.bind(
#         ext_url.netloc,
#         script_name=ext_url.path,
#         url_scheme=values.pop('_scheme', ext_url.scheme),
#     ).build(
#         endpoint,
#         values,
#         method=method,
#         force_external=True,
#     )


# Path: dockci/models/project.py
import logging
import re
import py.error  # pylint:disable=import-error
import sqlalchemy
from urllib.parse import quote_plus, urlparse, urlunparse
from uuid import uuid4
from flask import url_for
from .base import RepoFsMixin
from .db_types import RegexType
from dockci.server import CONFIG, DB, OAUTH_APPS
from dockci.util import ext_url_for
        from .job import Job
        from .job import Job
        from .job import Job

        """
        secret = uuid4().hex
        self.github_secret = secret
        endpoint = '%s/hooks' % self.github_api_repo_endpoint
        result = OAUTH_APPS['github'].post(endpoint, {
            'name': 'web',
            'events': ['push'],
            'active': True,
            'config': {
                'url': self.job_new_url_ext,
                'secret': secret,
                'content_type': 'json',
                'insecure_ssl': '0',
            },
        }, format='json')

        if result.status == 201:
            try:
                self.github_hook_id = result.data['id']

            except KeyError:
                pass

            DB.session.add(self)
            DB.session.commit()

        return result

    def delete_github_webhook(self, save=True):
        """ Utility to delete the associated GitHub web hook """

        result = OAUTH_APPS['github'].delete(