コード例 #1
0
    def add_hook(self, save=True):

        if self.user_settings:
            connect = GitHubClient(external_account=self.external_account)
            secret = utils.make_hook_secret()
            hook = connect.add_hook(
                self.user,
                self.repo,
                'web',
                {
                    'url':
                    urlparse.urljoin(
                        hook_domain,
                        os.path.join(self.owner.api_url, 'github', 'hook/')),
                    'content_type':
                    github_settings.HOOK_CONTENT_TYPE,
                    'secret':
                    secret,
                },
                events=github_settings.HOOK_EVENTS,
            )

            if hook:
                self.hook_id = hook.id
                self.hook_secret = secret
                if save:
                    self.save()
コード例 #2
0
def add_hook_to_old_node_settings(document, account):
    connect = GitHubClient(external_account=account)
    secret = make_hook_secret()
    hook = None
    try:
        hook = connect.add_hook(
            document['user'], document['repo'],
            'web',
            {
                'url': urlparse.urljoin(
                    HOOK_DOMAIN,
                    os.path.join(
                        Node.load(document['owner']).api_url, 'github', 'hook/'
                    )
                ),
                'content_type': github_settings.HOOK_CONTENT_TYPE,
                'secret': secret,
            },
            events=github_settings.HOOK_EVENTS,
        )
    except ApiError:
        pass
    if hook:
        database['addongithubnodesettings'].find_and_modify(
            {'_id': document['_id']},
            {
                '$set': {
                    'hook_id': hook.id,
                    'hook_secret': secret
                }
            }
        )
コード例 #3
0
ファイル: model.py プロジェクト: DataConservancy/osf.io
    def add_hook(self, save=True):

        if self.user_settings:
            connect = GitHubClient(external_account=self.external_account)
            secret = utils.make_hook_secret()
            hook = connect.add_hook(
                self.user, self.repo,
                'web',
                {
                    'url': urlparse.urljoin(
                        hook_domain,
                        os.path.join(
                            self.owner.api_url, 'github', 'hook/'
                        )
                    ),
                    'content_type': github_settings.HOOK_CONTENT_TYPE,
                    'secret': secret,
                },
                events=github_settings.HOOK_EVENTS,
            )

            if hook:
                self.hook_id = hook.id
                self.hook_secret = secret
                if save:
                    self.save()
コード例 #4
0
def add_hook_to_old_node_settings(document, account):
    connect = GitHubClient(external_account=account)
    secret = make_hook_secret()
    hook = None
    try:
        hook = connect.add_hook(
            document['user'],
            document['repo'],
            'web',
            {
                'url':
                urlparse.urljoin(
                    HOOK_DOMAIN,
                    os.path.join(
                        Node.load(document['owner']).api_url, 'github',
                        'hook/')),
                'content_type':
                github_settings.HOOK_CONTENT_TYPE,
                'secret':
                secret,
            },
            events=github_settings.HOOK_EVENTS,
        )
    except ApiError:
        pass
    if hook:
        database['addongithubnodesettings'].find_and_modify(
            {'_id': document['_id']},
            {'$set': {
                'hook_id': hook.id,
                'hook_secret': secret
            }})