From dfa636ac4c2456219677680ac4bf435f59a8bc9d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 1 Jul 2020 10:15:35 -0400 Subject: [PATCH] Coerce binary to text In subprocess, since we get binary, need to coerce to text. --- confluent_osdeploy/common/opt/confluent/bin/apiclient | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/confluent_osdeploy/common/opt/confluent/bin/apiclient b/confluent_osdeploy/common/opt/confluent/bin/apiclient index 7b69f64e..6907cb8c 100644 --- a/confluent_osdeploy/common/opt/confluent/bin/apiclient +++ b/confluent_osdeploy/common/opt/confluent/bin/apiclient @@ -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