mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2025-12-06 08:28:03 +01:00
Fix byte/string conversion for python 3
This commit is contained in:
@@ -271,7 +271,7 @@ def get_auth(args, encode=True):
|
|||||||
if encode == False:
|
if encode == False:
|
||||||
return auth
|
return auth
|
||||||
|
|
||||||
return base64.b64encode(auth)
|
return base64.b64encode(auth.encode('ascii'))
|
||||||
|
|
||||||
|
|
||||||
def get_github_api_host(args):
|
def get_github_api_host(args):
|
||||||
@@ -326,7 +326,7 @@ def retrieve_data(args, template, query_args=None, single_request=False):
|
|||||||
errors.append(template.format(status_code, r.reason))
|
errors.append(template.format(status_code, r.reason))
|
||||||
log_error(errors)
|
log_error(errors)
|
||||||
|
|
||||||
response = json.loads(r.read())
|
response = json.loads(r.read().decode('utf-8'))
|
||||||
if len(errors) == 0:
|
if len(errors) == 0:
|
||||||
if type(response) == list:
|
if type(response) == list:
|
||||||
data.extend(response)
|
data.extend(response)
|
||||||
@@ -382,7 +382,7 @@ def _construct_request(per_page, page, query_args, template, auth):
|
|||||||
|
|
||||||
request = Request(template + '?' + querystring)
|
request = Request(template + '?' + querystring)
|
||||||
if auth is not None:
|
if auth is not None:
|
||||||
request.add_header('Authorization', 'Basic ' + auth)
|
request.add_header('Authorization', 'Basic '.encode('ascii') + auth)
|
||||||
return request
|
return request
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user