Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/awscli/customizations/datapipeline/listrunsformatter.py
1567 views
1
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
14
from awscli.formatter import FullyBufferedFormatter
15
16
17
class ListRunsFormatter(FullyBufferedFormatter):
18
TITLE_ROW_FORMAT_STRING = " %-50.50s %-19.19s %-23.23s"
19
FIRST_ROW_FORMAT_STRING = "%4d. %-50.50s %-19.19s %-23.23s"
20
SECOND_ROW_FORMAT_STRING = " %-50.50s %-19.19s %-19.19s"
21
22
def _format_response(self, command_name, response, stream):
23
self._print_headers(stream)
24
for i, obj in enumerate(response):
25
self._print_row(i, obj, stream)
26
27
def _print_headers(self, stream):
28
stream.write(self.TITLE_ROW_FORMAT_STRING % (
29
"Name", "Scheduled Start", "Status"))
30
stream.write('\n')
31
second_row = (self.SECOND_ROW_FORMAT_STRING % (
32
"ID", "Started", "Ended"))
33
stream.write(second_row)
34
stream.write('\n')
35
stream.write('-' * len(second_row))
36
stream.write('\n')
37
38
def _print_row(self, index, obj, stream):
39
logical_name = obj['@componentParent']
40
object_id = obj['@id']
41
scheduled_start_date = obj.get('@scheduledStartTime', '')
42
status = obj.get('@status', '')
43
start_date = obj.get('@actualStartTime', '')
44
end_date = obj.get('@actualEndTime', '')
45
first_row = self.FIRST_ROW_FORMAT_STRING % (
46
index + 1, logical_name, scheduled_start_date, status)
47
second_row = self.SECOND_ROW_FORMAT_STRING % (
48
object_id, start_date, end_date)
49
stream.write(first_row)
50
stream.write('\n')
51
stream.write(second_row)
52
stream.write('\n\n')
53
54