mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Retrieve rate limiting information
This commit is contained in:
@@ -6,10 +6,14 @@ import Gist
|
||||
import PaginatedList
|
||||
from GithubObject import LazyCompletion, ImmediateCompletion
|
||||
|
||||
class Github:
|
||||
class Github( object ):
|
||||
def __init__( self, login, password ):
|
||||
self.__requester = Requester( login, password )
|
||||
|
||||
@property
|
||||
def rate_limiting( self ):
|
||||
return self.__requester.rate_limiting
|
||||
|
||||
def get_user( self, login = None ):
|
||||
if login is None:
|
||||
attributes = {
|
||||
|
||||
@@ -9,6 +9,7 @@ class UnknownGithubObject( Exception ):
|
||||
class Requester:
|
||||
def __init__( self, login, password ):
|
||||
self.__authorizationHeader = "Basic " + base64.b64encode( login + ":" + password ).replace( '\n', '' )
|
||||
self.rate_limiting = ( 5000, 5000 )
|
||||
|
||||
def request( self, verb, url, parameters, input ):
|
||||
assert verb in [ "HEAD", "GET", "POST", "PATCH", "PUT", "DELETE" ]
|
||||
@@ -30,6 +31,8 @@ class Requester:
|
||||
|
||||
cnx.close()
|
||||
|
||||
self.rate_limiting = ( int( headers[ "x-ratelimit-remaining" ] ), int( headers[ "x-ratelimit-limit" ] ) )
|
||||
|
||||
# print verb, url, parameters, input, "==>", status, str( headers )[ :30 ], str( output )[ :30 ]
|
||||
return status, headers, output
|
||||
|
||||
|
||||
Reference in New Issue
Block a user