0

Anyone having any idea about using the PyGithub module. Facing problem while instantiating the git object. The problem is same for any URL which I have tried.

from github import Github
g= Github("None", "None", "https://github.com/OpenSCAP")
#g = Github()
g.get_user().name       #getting exception right here.
print( g.get_user().name)
for repo in g.get_user().get_repos():
    print (repo.name)

Below is the traceback.

    pydev debugger
Traceback (most recent call last):
  File "C:\EasyEclipse-for-Python-1.3.1\plugins\org.python.pydev.debug_1.3.13\pysrc\pydevd.py", line 803, in <module>
    debugger.run(setup['file'], None, None)
  File "C:\EasyEclipse-for-Python-1.3.1\plugins\org.python.pydev.debug_1.3.13\pysrc\pydevd.py", line 655, in run
    execfile(file, globals, locals) #execute the script
  File "C:\MyDrive\SecureShield\GitHub\src\mygit.py", line 5, in <module>
    g.get_user().name
  File "C:\Python27\Lib\site-packages\github\AuthenticatedUser.py", line 221, in name
    self._completeIfNotSet(self._name)
  File "C:\Python27\Lib\site-packages\github\GithubObject.py", line 248, in _completeIfNotSet
    self._completeIfNeeded()
  File "C:\Python27\Lib\site-packages\github\GithubObject.py", line 252, in _completeIfNeeded
    self.__complete()
  File "C:\Python27\Lib\site-packages\github\GithubObject.py", line 257, in __complete
    self._url.value
  File "C:\Python27\Lib\site-packages\github\Requester.py", line 172, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, cnx))
  File "C:\Python27\Lib\site-packages\github\Requester.py", line 180, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.GithubException

Struggling for so many days. Only first call itself (creating the instance for Github object) I am stuck. Rest I know, might be easy.

And when I changed the URL from "https://github.com/OpenSCAP" to "http://github.com/OpenSCAP", getting the below traceback. completely clueless about the problem.

    pydev debugger
None
Repository(full_name=None)
Traceback (most recent call last):
  File "C:\EasyEclipse-for-Python-1.3.1\plugins\org.python.pydev.debug_1.3.13\pysrc\pydevd.py", line 803, in <module>
    debugger.run(setup['file'], None, None)
  File "C:\EasyEclipse-for-Python-1.3.1\plugins\org.python.pydev.debug_1.3.13\pysrc\pydevd.py", line 655, in run
    execfile(file, globals, locals) #execute the script
  File "C:\MyDrive\SecureShield\GitHub\src\mygit.py", line 9, in <module>
    print (repo.name)
  File "C:\Python27\Lib\site-packages\github\Repository.py", line 435, in name
    self._completeIfNotSet(self._name)
  File "C:\Python27\Lib\site-packages\github\GithubObject.py", line 248, in _completeIfNotSet
    self._completeIfNeeded()
  File "C:\Python27\Lib\site-packages\github\GithubObject.py", line 252, in _completeIfNeeded
    self.__complete()
  File "C:\Python27\Lib\site-packages\github\GithubObject.py", line 257, in __complete
    self._url.value
  File "C:\Python27\Lib\site-packages\github\Requester.py", line 172, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, cnx))
  File "C:\Python27\Lib\site-packages\github\Requester.py", line 213, in requestJson
    return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode)
  File "C:\Python27\Lib\site-packages\github\Requester.py", line 243, in __requestEncode
    url = self.__makeAbsoluteUrl(url)
  File "C:\Python27\Lib\site-packages\github\Requester.py", line 304, in __makeAbsoluteUrl
    if url.startswith("/"):
AttributeError: 'NoneType' object has no attribute 'startswith'
Exception AttributeError: "'NoneType' object has no attribute 'print_exc'" in <function _remove at 0x022C64B0> ignored
Hemant Yadav
  • 307
  • 1
  • 4
  • 19

1 Answers1

1

It should be like:

from github import Github
g = Github("ClaudiuCreanga", "private_token")
repo = g.get_repo("ClaudiuCreanga/magento2-store-locator-stockists-extension")
Claudiu Creanga
  • 8,031
  • 10
  • 71
  • 110