2

I would like to print all users in my organization in GitHub using PyGitHub.

The below snippet works, however it returns a PaginatedList:

python3 -c 'import os; from github import Github;g = Github(os.environ["TOKEN"]); 
repo = g.get_repo("ORG/REPO"); 
organization = repo.organization;  
members = organization.get_members(); print(members);'

However, when I want to print the PaginatedList I'm getting an error:

python3 -c 'import os; from github import Github;g = Github(os.environ["TOKEN"]);
repo = g.get_repo("ORG/REPO"); organization = repo.organization;  
members = organization.get_members(); print(members); [print(m) for m in members];'

And the error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 1, in <listcomp>
  File "/usr/local/lib/python3.10/dist-packages/PyGithub-1.55-py3.10.egg/github/PaginatedList.py", line 56, in __iter__
    newElements = self._grow()
  File "/usr/local/lib/python3.10/dist-packages/PyGithub-1.55-py3.10.egg/github/PaginatedList.py", line 67, in _grow
    newElements = self._fetchNextPage()
  File "/usr/local/lib/python3.10/dist-packages/PyGithub-1.55-py3.10.egg/github/PaginatedList.py", line 199, in _fetchNextPage
    headers, data = self.__requester.requestJsonAndCheck(
  File "/usr/local/lib/python3.10/dist-packages/PyGithub-1.55-py3.10.egg/github/Requester.py", line 353, in requestJsonAndCheck
    return self.__check(
  File "/usr/local/lib/python3.10/dist-packages/PyGithub-1.55-py3.10.egg/github/Requester.py", line 378, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest"}

I know I can do:

python3 -c 'import os; from github import Github;
g = Github(os.environ["TOKEN"]); organization = g.get_organization("ORG");  
members = organization.get_members(); 
[print(member) for member in members]; '

But that's not the point, I need it the way I showed (which does not work).

eftshift0
  • 26,375
  • 3
  • 36
  • 60
mazix
  • 2,540
  • 8
  • 39
  • 56
  • How fresh that token is? I ran into a lot of 404-s when I renamed a repo, but the really funny things started only after I reused its old name for a new repo. I remember well because it happened this Monday. – tevemadar Feb 22 '23 at 10:44
  • @tevemadar It's quite old but even with the new token the effect is the same – mazix Feb 22 '23 at 11:05

0 Answers0