def draw_banner_first_line(self, lines, data): status = data.get('HealthStatus', 'Unknown') refresh_time = data.get('RefreshedAt', None) if refresh_time is None: timestamp = '-' countdown = ' ( now )' else: timestamp = utils.get_local_time_as_string(refresh_time) delta = utils.get_delta_from_now_and_datetime(refresh_time) diff = 11 - delta.seconds if not self.refresh: countdown = '' elif self.frozen: countdown = ' (frozen +{})'.format(delta.seconds) elif diff < 0: countdown = ' ( now )' else: countdown = " ({} secs)".format(diff) env_name = data.get('EnvironmentName') pad_length = (term.width() - len(env_name) - len(timestamp) - len(countdown) - 1) if lines > 2: banner = io.bold(' {env_name}{status}{time}{cd} ') \ .format(env_name=env_name, status=status.center(pad_length), time=timestamp, cd=countdown, ) if not self.mono: banner = io.on_color(data.get('Color', 'Grey'), banner) term.echo_line(banner) lines -= 1 return lines
def draw(self, num_of_rows, table_data): self.width = term.width() if not self.visible: return self.set_data(table_data) self.visible_rows = num_of_rows if self.vertical_offset > self.get_max_offset(): self.vertical_offset = self.get_max_offset() self.first_column = min(self.screen.horizontal_offset + 1, len(self.columns) - 1) self.draw_header_row() self.draw_rows()
def draw_banner_info_lines(self, lines, data): if lines > 2: tier_type = self.env_data['Tier']['Name'] tier = '{}'.format(tier_type) try: platform_arn = self.env_data['PlatformArn'] platform_version = PlatformVersion(platform_arn) platform = ' {}/{}'.format(platform_version.platform_shorthand, platform_version.platform_version) except KeyError: solutionstack = SolutionStack( self.env_data['SolutionStackName']) platform = ' {}'.format(solutionstack.platform_shorthand) term.echo_line('{tier}{pad}{platform} '.format( tier=tier, platform=platform, pad=' ' * (term.width() - len(tier) - len(platform)))) lines -= 1 if lines > 3: # Get instance health count instance_counts = OrderedDict([ ('total', data.get('Total', 0)), ('ok', data.get('Ok', 0)), ('warning', data.get('Warning', 0)), ('degraded', data.get('Degraded', 0)), ('severe', data.get('Severe', 0)), ('info', data.get('Info', 0)), ('pending', data.get('Pending', 0)), ('unknown', data.get('Unknown', 0) + data.get('NoData', 0)), ]) column_size = max(len(k) for k in instance_counts) + 1 term.echo_line(''.join( (s.center(column_size) for s in instance_counts))) term.echo_line(''.join( (io.bold((str(v).center(column_size))) for k, v in six.iteritems(instance_counts)))) lines -= 2 return lines
def draw_banner_first_line(self, lines, data): if lines > 2: app_name = 'Application Name: {}'.format(self.poller.app_name) env_name = self.poller.env_name if env_name is None: env_name = 'No Environment Specified' pad_length = term.width() - len(env_name) banner = io.bold(' {env_name}{app_name} ') \ .format(env_name=env_name, app_name=app_name.center(pad_length), ) if not self.mono: banner = io.on_color(data.get('Color', 'Grey'), banner) term.echo_line(banner) lines -= 1 return lines
def draw_banner_first_line(self, lines, data): if lines > 2: app_name = 'Application Name: {}'.format(self.poller.app_name) env_name = self.poller.env_name if env_name is None: env_name = 'No Environment Specified' pad_length = term.width() - len(env_name) banner = io.bold(' {env_name}{app_name} ') \ .format(env_name=env_name, app_name=app_name.center(pad_length), ) if not self.mono: banner = io.on_color(data.get('Color', 'Grey'), banner) term.echo_line(banner) lines -= 1 return lines