Skip to content

Commit 7a7d716

Browse files
committed
Better string mapping of execution profiles object keys
1 parent 1829303 commit 7a7d716

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

cassandra/cluster.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2375,6 +2375,11 @@ def _create_response_future(self, query, parameters, trace, custom_payload,
23752375
load_balancer=load_balancing_policy, start_time=start_time, speculative_execution_plan=spec_exec_plan,
23762376
host=host)
23772377

2378+
def _execution_profile_to_string(self, name):
2379+
if name is EXEC_PROFILE_DEFAULT:
2380+
return 'EXEC_PROFILE_DEFAULT'
2381+
return '"%s"' % (name,)
2382+
23782383
def get_execution_profile(self, name):
23792384
"""
23802385
Returns the execution profile associated with the provided ``name``.
@@ -2385,7 +2390,9 @@ def get_execution_profile(self, name):
23852390
try:
23862391
return profiles[name]
23872392
except KeyError:
2388-
raise ValueError("Invalid execution_profile: '%s'; valid profiles are %s" % (name, profiles.keys()))
2393+
eps = [self._execution_profile_to_string(ep) for ep in profiles.keys()]
2394+
raise ValueError("Invalid execution_profile: %s; valid profiles are: %s." % (
2395+
self._execution_profile_to_string(name), ', '.join(eps)))
23892396

23902397
def _maybe_get_execution_profile(self, ep):
23912398
return ep if isinstance(ep, ExecutionProfile) else self.get_execution_profile(ep)

0 commit comments

Comments
 (0)