Replace base64.encodestring with base64.encodebytes

Base64.encodestring has been deprecated since 3.1 and removed
in python 3.9,Replace it with base64.encodebytes from python3.1[1].

[1]https://docs.python.org/3.9/library/base64.html?highlight=deprecated#base64.encodebytes

Change-Id: If6c520c3176d67e579bf40977cd2938ed8d3bf87
This commit is contained in:
likui 2023-09-19 11:19:36 +08:00
parent b9b0d8314c
commit 36bfe99330
1 changed files with 3 additions and 3 deletions

View File

@ -86,7 +86,7 @@ def _get_token(git_url):
CREDENTIALS[git_url]['full_repo'] = full_repo_name
http = httplib2.Http()
auth = base64.encodestring(username + ':' + password)
auth = base64.encodebytes(username + ':' + password)
headers = {'Authorization': 'Basic ' + auth,
'Content-Type': 'application/json'}
# 'note' field has to be unique
@ -192,7 +192,7 @@ def create_webhook(trigger_uri):
for key in CREDENTIALS.keys():
user = CREDENTIALS[key]['user']
password = CREDENTIALS[key]['password']
auth = base64.encodestring(user + ':' + password)
auth = base64.encodebytes(user + ':' + password)
http = httplib2.Http()
# TODO(james_li): make this url configurable
github_url = ('https://api.github.com/repos/%s/hooks' %
@ -224,7 +224,7 @@ def add_ssh_keys(args):
CREDENTIALS[key]['pub_key'] is not None):
user = CREDENTIALS[key]['user']
password = CREDENTIALS[key]['password']
auth = base64.encodestring(user + ':' + password)
auth = base64.encodebytes(user + ':' + password)
http = httplib2.Http()
if args.user_key:
# TODO(james_li): make the url configurable