Skip to content

Commit bf7ad4f

Browse files
Lorak-mmkfruch
authored andcommitted
Fix python2 incompatibilities in scylla/cloud.py
1 parent 8bbc05a commit bf7ad4f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cassandra/scylla/cloud.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def file_or_memory(path=None, data=None):
3434
# so we use temporary file to load the key
3535
if data:
3636
with tempfile.NamedTemporaryFile(mode="wb") as f:
37-
d = base64.decodebytes(bytes(data, encoding='utf-8'))
37+
d = base64.b64decode(data)
3838
f.write(d)
3939
if not d.endswith(b"\n"):
4040
f.write(b"\n")
@@ -102,11 +102,11 @@ def get_server(self, data_center):
102102

103103
def create_ssl_context(self):
104104
ssl_context = ssl.SSLContext(protocol=ssl.PROTOCOL_SSLv23)
105-
ssl_context.verify_mode = ssl.VerifyMode.CERT_NONE if self.skip_tls_verify else ssl.VerifyMode.CERT_REQUIRED
105+
ssl_context.verify_mode = ssl.CERT_NONE if self.skip_tls_verify else ssl.CERT_REQUIRED
106106
for data_center in self.data_centers.values():
107107
with file_or_memory(path=data_center.get('certificateAuthorityPath'),
108108
data=data_center.get('certificateAuthorityData')) as cafile:
109-
ssl_context.load_verify_locations(cadata=open(cafile).read())
109+
ssl_context.load_verify_locations(cadata=six.text_type(open(cafile).read()))
110110
with file_or_memory(path=self.auth_info.get('clientCertificatePath'),
111111
data=self.auth_info.get('clientCertificateData')) as certfile, \
112112
file_or_memory(path=self.auth_info.get('clientKeyPath'), data=self.auth_info.get('clientKeyData')) as keyfile:

0 commit comments

Comments
 (0)