Skip to content

Commit 682eb35

Browse files
committed
Update query_with_count return value so the second tuple item (count) is
always an integer. Update affected code.
1 parent b1cbac6 commit 682eb35

File tree

7 files changed

+8
-9
lines changed

7 files changed

+8
-9
lines changed

st2client/st2client/commands/action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ def run_and_print(self, args, **kwargs):
10831083
attributes=args.attr, widths=args.width,
10841084
attribute_transform_functions=self.attribute_transform_functions)
10851085

1086-
if args.last and count and int(count) > args.last:
1086+
if args.last and count and count > args.last:
10871087
table.SingleRowTable.note_box(self.resource_name, args.last)
10881088

10891089

st2client/st2client/commands/rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def run_and_print(self, args, **kwargs):
9595
self.print_output(instances, table.MultiColumnTable,
9696
attributes=args.attr, widths=args.width)
9797

98-
if args.last and count and int(count) > args.last:
98+
if args.last and count and count > args.last:
9999
table.SingleRowTable.note_box(self.resource_name, args.last)
100100

101101

st2client/st2client/commands/rule_enforcement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@ def run_and_print(self, args, **kwargs):
122122
else:
123123
self.print_output(instances, table.MultiColumnTable,
124124
attributes=args.attr, widths=args.width)
125-
if args.last and count and int(count) > args.last:
125+
if args.last and count and count > args.last:
126126
table.SingleRowTable.note_box(self.resource_name, args.last)

st2client/st2client/commands/trace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def run_and_print(self, args, **kwargs):
176176
self.print_trace_details(trace=instances[0], args=args)
177177

178178
if not args.json and not args.yaml:
179-
if args.last and count and int(count) > args.last:
179+
if args.last and count and count > args.last:
180180
table.SingleRowTable.note_box(self.resource_name, 1)
181181
else:
182182
if args.json or args.yaml:
@@ -189,7 +189,7 @@ def run_and_print(self, args, **kwargs):
189189
attributes=args.attr, widths=args.width,
190190
attribute_transform_functions=self.attribute_transform_functions)
191191

192-
if args.last and count and int(count) > args.last:
192+
if args.last and count and count > args.last:
193193
table.SingleRowTable.note_box(self.resource_name, args.last)
194194

195195

st2client/st2client/commands/triggerinstance.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ def run(self, args, **kwargs):
121121
return self.manager.query_with_count(limit=args.last, **kwargs)
122122

123123
def run_and_print(self, args, **kwargs):
124-
125124
instances, count = self.run(args, **kwargs)
126125
if args.json or args.yaml:
127126
self.print_output(reversed(instances), table.MultiColumnTable,
@@ -132,7 +131,7 @@ def run_and_print(self, args, **kwargs):
132131
self.print_output(reversed(instances), table.MultiColumnTable,
133132
attributes=args.attr, widths=args.width,
134133
attribute_transform_functions=self.attribute_transform_functions)
135-
if args.last and count and int(count) > args.last:
134+
if args.last and count and count > args.last:
136135
table.SingleRowTable.note_box(self.resource_name, args.last)
137136

138137

st2client/st2client/models/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def query(self, **kwargs):
285285
def query_with_count(self, **kwargs):
286286
instances, response = self._query_details(**kwargs)
287287
if response and 'X-Total-Count' in response.headers:
288-
return (instances, response.headers['X-Total-Count'])
288+
return (instances, int(response.headers['X-Total-Count']))
289289
else:
290290
return (instances, None)
291291

st2client/tests/unit/test_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_resource_query_with_count(self):
114114
actual = [resource.serialize() for resource in resources]
115115
expected = json.loads(json.dumps([base.RESOURCES[0]]))
116116
self.assertEqual(actual, expected)
117-
self.assertEqual(count, '50')
117+
self.assertEqual(count, 50)
118118

119119
@mock.patch.object(
120120
httpclient.HTTPClient, 'get',

0 commit comments

Comments
 (0)