Retrieve rate limiting information

This commit is contained in:
Vincent Jacques
2012-05-21 13:15:34 +02:00
parent d5ba645d44
commit ca974699b0
7 changed files with 23 additions and 1 deletions
+5 -1
View File
@@ -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 = {
+3
View File
@@ -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