Python github 模块,RateLimitExceededException() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用github.RateLimitExceededException()

项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def testRateLimitExceeded(self):
        g = github.Github()

        def exceed():
            for i in range(100):
                g.get_user("jacquev6")

        self.assertRaises(github.RateLimitExceededException, exceed)
项目:TutLab    作者:KingsMentor    | 项目源码 | 文件源码
def testRateLimitExceeded(self):
        g = github.Github()

        def exceed():
            for i in range(100):
                g.get_user("jacquev6")

        self.assertRaises(github.RateLimitExceededException, exceed)
项目:skill-for-github    作者:dkavanagh    | 项目源码 | 文件源码
def testRateLimitExceeded(self):
        g = github.Github()

        def exceed():
            for i in range(100):
                g.get_user("jacquev6")

        self.assertRaises(github.RateLimitExceededException, exceed)
项目:repo-classifier    作者:linkvt    | 项目源码 | 文件源码
def index(request: HttpRequest) -> HttpResponse:
    uploaded_file = request.FILES.get('file')
    url = request.POST['repo-url'] if 'repo-url' in request.POST else None
    mode = request.POST['mode'] if 'mode' in request.POST else None
    if mode and uploaded_file:
        data = uploaded_file.read()
        text = data.decode(uploaded_file.charset or 'utf-8')
    else:
        text = None

    output_lines = ''
    reports = None
    validation_output = None
    probabilities = []

    try:
        if mode == 'train':
            output_lines, reports = classifier.train(text) if text else ([], None)
        elif mode == 'classify':
            output_lines = classifier.classify(text) if text else None
        elif mode == 'classify-single-repo':
            probabilities = classifier.classify_single_repo(url.rstrip('/')) if url else []
        elif mode == 'validate':
            validation_output = classifier.validate(text) if text else None
    except RateLimitExceededException:
        output_lines = 'The available request limit was exceeded for the Github API please wait until refresh.'

    context = {
        'output': output_lines,
        'validation_output': validation_output,
        'single_repository': url,
        'probabilities': probabilities,
        'reports': reports,
    }

    return render(request, 'classification/index.html', context)
项目:pastamaker    作者:sileht    | 项目源码 | 文件源码
def event_handler(event_type, data):
    """Everything start here"""

    integration = github.GithubIntegration(config.INTEGRATION_ID,
                                           config.PRIVATE_KEY)
    token = integration.get_access_token(data["installation"]["id"]).token
    g = github.Github(token)
    try:
        user = g.get_user(data["repository"]["owner"]["login"])
        repo = user.get_repo(data["repository"]["name"])

        engine.PastaMakerEngine(g, user, repo).handle(event_type, data)
    except github.RateLimitExceededException:
        LOG.error("rate limit reached")
项目:hudl-bugbounty    作者:lewislabs    | 项目源码 | 文件源码
def testRateLimitExceeded(self):
        g = github.Github()

        def exceed():
            for i in range(100):
                g.get_user("jacquev6")

        self.assertRaises(github.RateLimitExceededException, exceed)
项目:infrared    作者:redhat-openstack    | 项目源码 | 文件源码
def get_github_organization_plugins(self, organization, no_forks=False):
        """
        Returns a dict with all plugins from a GitHub organization
        inspired from: https://gist.github.com/ralphbean/5733076
        :param organization: GitHub organization name
        :param no_forks: include / not include forks
        """
        plugins_dict = OrderedDict()

        try:
            gh = github.Github()
            all_repos = gh.get_organization(organization).get_repos()
        except github.RateLimitExceededException:
            raise IRException("Github API rate limit exceeded")

        for repo in all_repos:

            try:
                # Don't print the urls for repos that are forks.
                if no_forks and repo.fork:
                    continue

                spec_file = repo.get_contents('plugin.spec').decoded_content

                plugin = SpecValidator.validate_from_content(spec_file)
                plugin_name = plugin["subparsers"].keys()[0]
                plugin_src = repo.clone_url
                plugin_type = plugin["config"]["plugin_type"] \
                    if "config" in plugin \
                    else plugin["plugin_type"]
                plugin_desc = plugin["description"] \
                    if "description" in plugin \
                       and plugin["description"] is not None \
                    else "-"

                if plugin_type not in plugins_dict:
                    plugins_dict[plugin_type] = {}

                plugins_dict[plugin_type][plugin_name] = {
                    "src": plugin_src,
                    "desc": plugin_desc,
                }

            except github.RateLimitExceededException:
                raise IRException("Github API rate limit exceeded")
            except Exception:
                # skip repo failures
                continue

        return plugins_dict