2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-02-02 20:13:26 +00:00

Fix apikey strip for python2

Strip after any conversions, whether it is bytes or str.
This commit is contained in:
Jarrod Johnson 2020-07-01 11:29:31 -04:00
parent 85241a488a
commit 004e609635

View File

@ -14,9 +14,10 @@ def get_apikey(nodename, mgr):
return open('/etc/confluent/confluent.apikey').read().strip()
apikey = subprocess.check_output(['/opt/confluent/bin/clortho', nodename, mgr])
if not isinstance(apikey, str):
apikey = apikey.decode('utf8').strip()
apikey = apikey.decode('utf8')
with open('/etc/confluent/confluent.apikey', 'w+') as apiout:
apiout.write(apikey)
apikey = apikey.strip()
os.chmod('/etc/confluent/confluent.apikey', 0o600)
return apikey