Fix py39 base64 has no attribute encodestring

Change-Id: Ida5ba5d2ef0b90b46a226451c8c10c910e5d4112
This commit is contained in:
zhurong 2022-03-08 05:36:16 +00:00
parent d6635aecd6
commit c22568073a
1 changed files with 3 additions and 7 deletions

View File

@ -100,13 +100,9 @@ class GitHubAuth(object):
# This will prompt the user if either name or pass is missing.
authstring = '%s:%s' % (self.username, self.password)
basic_auth = ''
try:
basic_auth = base64.encodestring(authstring)
except TypeError:
# Python 3
basic_auth = base64.encodestring(bytes(authstring, 'utf-8'))
basic_auth = basic_auth.decode('utf-8')
basic_auth = base64.encodebytes(bytes(authstring, 'utf-8'))
basic_auth = basic_auth.decode('utf-8')
basic_auth = basic_auth.strip()
header['Authorization'] = 'Basic %s' % basic_auth