当前位置: 首页>>代码示例>>Python>>正文


Python github.UnknownObjectException方法代码示例

本文整理汇总了Python中github.UnknownObjectException方法的典型用法代码示例。如果您正苦于以下问题:Python github.UnknownObjectException方法的具体用法?Python github.UnknownObjectException怎么用?Python github.UnknownObjectException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github的用法示例。


在下文中一共展示了github.UnknownObjectException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update_index_does_not_exist

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def test_update_index_does_not_exist(self):
        """
        self.gh().get_user().get_repo().update_file.side_effect = UnknownObjectException(status=404, data="foo")

        runner = CliRunner()
        result = runner.invoke(update, ["--name", "testrepo", "--token", "token"])
        self.assertEqual(result.exit_code, 0)

        self.gh.assert_called_with("token")

        self.gh().get_user().get_repo.assert_called_with(name="testrepo")
        self.gh().get_user().get_repo().get_labels.assert_called_once_with()
        self.gh().get_user().get_repo().create_file.assert_called_once_with(
            branch='gh-pages',
            content='some foo',
            message='initial',
            path='/index.html'
        )
        """ 
开发者ID:jayfk,项目名称:statuspage,代码行数:21,代码来源:tests.py

示例2: test_close_pull_request

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def test_close_pull_request(self):

        pr = Mock()
        pr.head.ref = "bla"
        self.repo.get_pull.return_value = pr
        with self.assertRaises(AssertionError):
            self.provider.close_pull_request(self.repo, self.repo, pr, "comment", prefix="pyup-")

        pr.head.ref = "pyup-bla"
        self.provider.close_pull_request(self.repo, self.repo, pr, "comment", prefix="pyup-")
        self.assertEqual(self.repo.get_git_ref().delete.call_count, 1)

        self.repo.get_pull.side_effect = UnknownObjectException(data="", status=1)
        data = self.provider.close_pull_request(self.repo, self.repo, Mock(), "comment",
                                                prefix="pyup-")
        self.assertEqual(data, False) 
开发者ID:pyupio,项目名称:pyup,代码行数:18,代码来源:test_github.py

示例3: check_user

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def check_user(user: str, line_idx: int):
    if user[0] != "@":
        raise ValueError(
            f"User '{user}' at line {line_idx} of CODEOWNERS "
            f"doesn't start with '@' "
        )
    user = user[1:]
    user = user.lower()  # in github, user names are case insensitive
    if user in WRITE_ACCESS_LIST:
        return None
    try:
        CLIENT.get_user(user)
    except github.UnknownObjectException:
        raise KeyError(
            f"User '{user}' line {line_idx} does not exist. Did you make a typo?"
        )
    return user 
开发者ID:tensorflow,项目名称:addons,代码行数:19,代码来源:notify_codeowners.py

示例4: fork_repo

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def fork_repo(gh, *, org, package_name, source_org):
    repo_full_name = f'{org.login}/{package_name}-feedstock'
    forked_repo = gh.get_repo(repo_full_name)
    print(f'Checking to see if {repo_full_name} exists on Github')
    try:
        # Check that the repo actually exists
        # Printing the name or any property of the repo issues this check
        print(f'{forked_repo.full_name} already exists, not forking it again.')
        return forked_repo
    except UnknownObjectException:
        print(f'{repo_full_name} does not exists on Github, will fork')
        pass

    # Else, now try to fork it from the origin
    feedstock_repo = gh.get_repo(f'{source_org}/{package_name}-feedstock')
    try:
        org.create_fork(feedstock_repo)
    except UnknownObjectException as e:
        if e.status == 404:
            raise RuntimeError(f'Repository not found: {e.data["message"]}')
        else:
            raise e 
开发者ID:Archiconda,项目名称:build-tools,代码行数:24,代码来源:fork_conda_forge.py

示例5: translate_github_exception

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def translate_github_exception(func):
    """
    Decorator to catch GitHub-specific exceptions and raise them as GitClientError exceptions.
    """

    @functools.wraps(func)
    def _wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except UnknownObjectException as e:
            logger.exception('GitHub API 404 Exception')
            raise NotFoundError(str(e))
        except GithubException as e:
            logger.exception('GitHub API Exception')
            raise GitClientError(str(e))

    return _wrapper 
开发者ID:grantmcconnaughey,项目名称:Lintly,代码行数:19,代码来源:github.py

示例6: test_commit_sha_of_tag

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def test_commit_sha_of_tag():
    r = _repo()
    r._repo.get_git_ref = Mock()
    r._repo.get_git_ref.return_value.object.type = "commit"
    r._repo.get_git_ref.return_value.object.sha = "c"
    assert r._commit_sha_of_tag("v1.2.3") == "c"
    r._repo.get_git_ref.assert_called_with("tags/v1.2.3")
    r._repo.get_git_ref.return_value.object.type = "tag"
    r._repo.get_git_tag = Mock()
    r._repo.get_git_tag.return_value.object.sha = "t"
    assert r._commit_sha_of_tag("v2.3.4") == "t"
    r._repo.get_git_tag.assert_called_with("c")
    r._repo.get_git_ref.return_value.object = None
    assert r._commit_sha_of_tag("v3.4.5") is None
    r._repo.get_git_ref.side_effect = UnknownObjectException(404, "???")
    assert r._commit_sha_of_tag("v4.5.6") is None 
开发者ID:JuliaRegistries,项目名称:TagBot,代码行数:18,代码来源:test_repo.py

示例7: create_pseudorelease_tag

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def create_pseudorelease_tag(reposlug, branch):
  access_token = os.environ.get("GITHUB_ACCESS_TOKEN")
  if access_token is None:
    raise RuntimeError("GITHUB_ACCESS_TOKEN missing from environment")

  # TODO(josh): get title out of the script so that it can be reusable
  hub = github.Github(access_token)
  repo = hub.get_repo(reposlug)
  branchobj = repo.get_branch(branch)
  logger.info("Creating tag pseudo-%s -> %s", branch, branchobj.commit.sha)
  refname = "tags/pseudo-" + branch
  try:
    existing_ref = repo.get_git_ref(refname)
    logger.info("Updating existing ref for %s", refname)
    existing_ref.edit(branchobj.commit.sha, force=True)
    return
  except github.UnknownObjectException:
    pass

  logger.info("Creating ref %s", refname)
  refname = "refs/" + refname
  repo.create_git_ref(refname, branchobj.commit.sha) 
开发者ID:cheshirekow,项目名称:cmake_format,代码行数:24,代码来源:github.py

示例8: get_list

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def get_list(
        project: "ogr_github.GithubProject", status: PRStatus = PRStatus.open
    ) -> List["PullRequest"]:
        prs = project.github_repo.get_pulls(
            # Github API has no status 'merged', just 'closed'/'opened'/'all'
            state=status.name if status != PRStatus.merged else "closed",
            sort="updated",
            direction="desc",
        )

        if status == PRStatus.merged:
            prs = list(prs)  # Github PaginatedList into list()
            for pr in prs:
                if not pr.is_merged():  # parse merged PRs
                    prs.remove(pr)
        try:
            return [GithubPullRequest(pr, project) for pr in prs]
        except UnknownObjectException:
            return [] 
开发者ID:packit-service,项目名称:ogr,代码行数:21,代码来源:pull_request.py

示例9: project_create

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def project_create(self, repo: str, namespace: str = None) -> "GithubProject":
        if namespace:
            try:
                owner = self.github.get_organization(namespace)
            except UnknownObjectException:
                raise GithubAPIException(f"Group {namespace} not found.")
        else:
            owner = self.github.get_user()

        new_repo = owner.create_repo(name=repo)
        return GithubProject(
            repo=repo,
            namespace=namespace or owner.login,
            service=self,
            github_repo=new_repo,
        ) 
开发者ID:packit-service,项目名称:ogr,代码行数:18,代码来源:service.py

示例10: test_project_create

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def test_project_create(self):
        """
        Remove https://github.com/$USERNAME/repo_created_for_test repository before regeneration

        """
        name_of_the_repo = "repo_created_for_test"
        project = self.service.get_project(
            repo=name_of_the_repo, namespace=self.service.user.get_username()
        )
        with self.assertRaises(UnknownObjectException):
            project.github_repo

        new_project = self.service.project_create(name_of_the_repo)
        assert new_project.repo == name_of_the_repo
        assert new_project.github_repo

        project = self.service.get_project(
            repo=name_of_the_repo, namespace=self.service.user.get_username()
        )
        assert project.github_repo 
开发者ID:packit-service,项目名称:ogr,代码行数:22,代码来源:test_github.py

示例11: ensure_label_present

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def ensure_label_present(repo, name, color, current_labels, description=''):
    present_labels = []

    for label in current_labels:
        present_labels.append(label.name)

    if name not in present_labels:
        logger.info(f"adding '{name}' label to {repo.name}")

        try:
            repo.create_label(name, color, description)

        except UnknownObjectException as e:
            logger.error(e)

            repo.create_issue(f"can't create '{name}' label")
            logger.info('issue created!')
    else:
        logger.debug(f"label '{name}' was present") 
开发者ID:thoth-station,项目名称:core,代码行数:21,代码来源:common.py

示例12: should_parse

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def should_parse(repo, state, is_gist=False):
    owner_login = repo.owner.login if is_gist else repo.repository.owner.login
    if owner_login in state.bad_users:
        print(bcolors.FAIL + "Failed check: Ignore User" + bcolors.ENDC)
        return False
    if not is_gist and repo.repository.name in state.bad_repos:
        print(bcolors.FAIL + "Failed check: Ignore Repo" + bcolors.ENDC)
        return False
    if not is_gist and repo.name in state.bad_files:
        print(bcolors.FAIL + "Failed check: Ignore File" + bcolors.ENDC)
        return False

    # Fuzzy Hash Comparison
    try:
        if not is_gist:
            # Temporary fix for PyGithub until fixed upstream (PyGithub#1178)
            repo._url.value = repo._url.value.replace(
                repo._path.value,
                urllib.parse.quote(repo._path.value))

        candidate_sig = ssdeep.hash(repo.decoded_content)
        for sig in state.bad_signatures:
            similarity = ssdeep.compare(candidate_sig, sig)
            if similarity > SIMILARITY_THRESHOLD:
                print(
                    bcolors.FAIL +
                    "Failed check: Ignore Fuzzy Signature on Contents "
                    "({}% Similarity)".format(similarity) +
                    bcolors.ENDC)
                return False
    except github.UnknownObjectException:
        print(
            bcolors.FAIL +
            "API Error: File no longer exists on github.com" +
            bcolors.ENDC)
        return False
    return True 
开发者ID:BishopFox,项目名称:GitGot,代码行数:39,代码来源:gitgot.py

示例13: run_remove_system

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def run_remove_system(name, token, org, system, prompt):
    """
    Removes a system from the repo.
    """
    repo = get_repo(token=token, org=org, name=name)
    try:
        label = repo.get_label(name=system.strip())
        label.delete()
        click.secho("Successfully deleted {}".format(system), fg="green")
        if prompt and click.confirm("Run update to re-generate the page?"):
            run_update(name=name, token=token, org=org)
    except UnknownObjectException:
        click.secho("Unable to remove system {}, it does not exist.".format(system), fg="yellow") 
开发者ID:jayfk,项目名称:statuspage,代码行数:15,代码来源:statuspage.py

示例14: get_pr_by_number_or_id

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def get_pr_by_number_or_id(self, number_or_id):
    number_or_id = int(number_or_id)
    try:
      return self.get_pr_by_number(number_or_id)
    except UnknownObjectException:
      return self.get_pr_by_id(number_or_id) 
开发者ID:yasyf,项目名称:shamer,代码行数:8,代码来源:githubbot.py

示例15: get_default_branch

# 需要导入模块: import github [as 别名]
# 或者: from github import UnknownObjectException [as 别名]
def get_default_branch(self, repo):
        try:
            return repo.default_branch
        except UnknownObjectException:
            # we can't use repo.name here because the repo object is lazy!
            # If we try to access one of the properties that is not completed,
            # we'll run into the next exception.
            logger.error("Repo does not exist", exc_info=True)
            raise RepoDoesNotExistError() 
开发者ID:pyupio,项目名称:pyup,代码行数:11,代码来源:github.py


注:本文中的github.UnknownObjectException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。