2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-23 01:53:28 +00:00

Coerce binary to text

In subprocess, since we get binary, need to
coerce to text.
This commit is contained in:
Jarrod Johnson 2020-07-01 10:15:35 -04:00
parent e863edfe3f
commit dfa636ac4c

View File

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