Path: blob/develop/awscli/customizations/datapipeline/listrunsformatter.py
1567 views
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.1213from awscli.formatter import FullyBufferedFormatter141516class ListRunsFormatter(FullyBufferedFormatter):17TITLE_ROW_FORMAT_STRING = " %-50.50s %-19.19s %-23.23s"18FIRST_ROW_FORMAT_STRING = "%4d. %-50.50s %-19.19s %-23.23s"19SECOND_ROW_FORMAT_STRING = " %-50.50s %-19.19s %-19.19s"2021def _format_response(self, command_name, response, stream):22self._print_headers(stream)23for i, obj in enumerate(response):24self._print_row(i, obj, stream)2526def _print_headers(self, stream):27stream.write(self.TITLE_ROW_FORMAT_STRING % (28"Name", "Scheduled Start", "Status"))29stream.write('\n')30second_row = (self.SECOND_ROW_FORMAT_STRING % (31"ID", "Started", "Ended"))32stream.write(second_row)33stream.write('\n')34stream.write('-' * len(second_row))35stream.write('\n')3637def _print_row(self, index, obj, stream):38logical_name = obj['@componentParent']39object_id = obj['@id']40scheduled_start_date = obj.get('@scheduledStartTime', '')41status = obj.get('@status', '')42start_date = obj.get('@actualStartTime', '')43end_date = obj.get('@actualEndTime', '')44first_row = self.FIRST_ROW_FORMAT_STRING % (45index + 1, logical_name, scheduled_start_date, status)46second_row = self.SECOND_ROW_FORMAT_STRING % (47object_id, start_date, end_date)48stream.write(first_row)49stream.write('\n')50stream.write(second_row)51stream.write('\n\n')525354