Esempio n. 1
0
def test():
    import github

    from pastamaker import gh_pr
    from pastamaker import utils

    utils.setup_logging()
    config.log()
    gh_pr.monkeypatch_github()

    parts = sys.argv[1].split("/")

    LOG.info("Getting repo %s ..." % sys.argv[1])

    integration = github.GithubIntegration(config.INTEGRATION_ID,
                                           config.PRIVATE_KEY)

    installation_id = utils.get_installation_id(integration, parts[3])
    token = integration.get_access_token(installation_id).token
    g = github.Github(token)
    user = g.get_user(parts[3])
    repo = user.get_repo(parts[4])
    LOG.info("Protecting repo %s branch %s ..." % (sys.argv[1], sys.argv[2]))
    policy = get_branch_policy(repo, sys.argv[2])
    protect_if_needed(repo, sys.argv[2], policy)
Esempio n. 2
0
def test():
    from pastamaker import gh_pr
    from pastamaker import utils

    utils.setup_logging()
    config.log()
    gh_pr.monkeypatch_github()

    parts = sys.argv[1].split("/")
    LOG.info("Getting repo %s ..." % sys.argv[1])

    if True:
        # With access_token got from oauth
        token = sys.argv[2]

        g = github.Github(token)
        user = g.get_user(parts[3])
        repo = user.get_repo(parts[4])
        pull = repo.get_pull(int(parts[6]))
        update_branch(pull, token)
    else:
        # With access_token got from integration
        integration = github.GithubIntegration(config.INTEGRATION_ID,
                                               config.PRIVATE_KEY)

        installation_id = utils.get_installation_id(integration, parts[3])
        token = integration.get_access_token(installation_id).token
        update_branch(pull, "x-access-token:%s" % token)
Esempio n. 3
0
def main():
    utils.setup_logging()
    gh_pr.monkeypatch_github()
    if config.FLUSH_REDIS_ON_STARTUP:
        utils.get_redis().flushall()
    with rq.Connection(utils.get_redis()):
        worker = rq.worker.HerokuWorker([rq.Queue('default')],
                                        exception_handlers=[error_handler])
        worker.work()
Esempio n. 4
0
def main():
    utils.setup_logging()
    config.log()
    gh_pr.monkeypatch_github()
    if config.FLUSH_REDIS_ON_STARTUP:
        utils.get_redis().flushall()
    with rq.Connection(utils.get_redis()):
        worker = rq.Worker(['default'])
        worker.work()
Esempio n. 5
0
# -*- encoding: utf-8 -*-
#
# Copyright © 2017 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


from pastamaker import config
from pastamaker import gh_pr
from pastamaker import utils
from pastamaker import web

config.log()
utils.setup_logging()
gh_pr.monkeypatch_github()
application = web.app