from prepare import borg_info_raw, readable_csize, csize, archive_num, last_archive_time, df_avail_readable, df_avail_bytes from rich import print, box from rich.console import Group from rich.padding import Padding from rich.panel import Panel from rich.progress import Progress, BarColumn from rich.style import Style # actually print the thing emphasis = Style(color='#d89961', bold=True) if borg_info_raw.returncode == 0: online = Padding('[#82bfe0 bold]◉[/#82bfe0 bold] Host online', (0, 2)) else: online = Padding('[#34454f bold]◌[/#34454f bold] Host offline', (0, 2)) # it's hacky, but should work as expected used = Progress( '[progress.description]{task.description}', # space used f'[{emphasis}]{readable_csize}[/{emphasis}]', BarColumn(complete_style=emphasis, finished_style="#d34141"), # space available f'[{emphasis}]{df_avail_readable}[/{emphasis}]', '[progress.percentage]{task.percentage:>3.0f}%' ) used.add_task('Used:', completed=csize, total=df_avail_bytes) disk_usage = Panel(used, box=box.SQUARE, border_style=emphasis) avail_backups = Panel(f"Available: [{emphasis}]{archive_num}[/{emphasis}] backups. Last backup from: [{emphasis}]{last_archive_time}[/{emphasis}]", box=box.SQUARE, border_style=emphasis) output_group = Group( online, disk_usage, avail_backups ) print(Panel.fit( output_group, box=box.DOUBLE, border_style=emphasis ))