Skip to content

Commit 2f17679

Browse files
committed
tsp_client: Extract duplicated failed-to-get-tree
Replace the previously duplicated string values with a reused constant. Apply the default VS Code python formatting to this amended file. Signed-off-by: Marco Miller <[email protected]>
1 parent c331ba4 commit 2f17679

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tsp/tsp_client.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@
4141
headers_form = {'content-type': 'application/x-www-form-urlencoded',
4242
'Accept': APPLICATION_JSON}
4343

44+
GET_TREE_FAILED = "failed to get tree: {0}"
4445

4546
# pylint: disable=consider-using-f-string
47+
48+
4649
class TspClient:
4750
'''
4851
Trace Server Protocol tsp_cli_client
@@ -240,7 +243,7 @@ def fetch_experiment_output(self, exp_uuid, output_id):
240243
return TspClientResponse(OutputDescriptor(json.loads(response.content.decode('utf-8'))),
241244
response.status_code, response.text)
242245
else: # pragma: no cover
243-
print("failed to get tree: {0}".format(response.status_code))
246+
print(GET_TREE_FAILED.format(response.status_code))
244247
return TspClientResponse(None, response.status_code, response.text)
245248

246249
def fetch_datatree(self, exp_uuid, output_id, parameters=None):
@@ -266,7 +269,7 @@ def fetch_datatree(self, exp_uuid, output_id, parameters=None):
266269
ModelType.DATA_TREE),
267270
response.status_code, response.text)
268271
else: # pragma: no cover
269-
print("failed to get tree: {0}".format(response.status_code))
272+
print(GET_TREE_FAILED.format(response.status_code))
270273
return TspClientResponse(None, response.status_code, response.text)
271274

272275
def fetch_timegraph_tree(self, exp_uuid, output_id, parameters=None):
@@ -292,7 +295,7 @@ def fetch_timegraph_tree(self, exp_uuid, output_id, parameters=None):
292295
ModelType.TIME_GRAPH_TREE),
293296
response.status_code, response.text)
294297
else: # pragma: no cover
295-
print("failed to get tree: {0}".format(response.status_code))
298+
print(GET_TREE_FAILED.format(response.status_code))
296299
return TspClientResponse(None, response.status_code, response.text)
297300

298301
def fetch_xy_tree(self, exp_uuid, output_id, parameters=None):
@@ -318,7 +321,7 @@ def fetch_xy_tree(self, exp_uuid, output_id, parameters=None):
318321
ModelType.XY_TREE),
319322
response.status_code, response.text)
320323
else: # pragma: no cover
321-
print("failed to get tree: {0}".format(response.status_code))
324+
print(GET_TREE_FAILED.format(response.status_code))
322325
return TspClientResponse(None, response.status_code, response.text)
323326

324327
def fetch_xy(self, exp_uuid, output_id, parameters):

0 commit comments

Comments
 (0)