from prepare import borg_info_raw, readable_csize, csize, archive_num, last_archive_time, df_avail_readable, df_avail_bytes from rich import box from rich.console import Console from rich.layout import Layout from rich.padding import Padding from rich.panel import Panel from rich.progress import Progress, BarColumn from rich.style import Style from config import config emphasis = Style(color='#d89961', bold=True) flomp = f'''[{emphasis}] .=--:: -***##- ::. ... +**##*: =##*. =*****: :******+::.. :##*: :******. =*************+====-::+*****+ .+**=:-==+++++****************: -***. .:--==+++++******+ =**+. .:-+#***- :***= ***** -***- -#***- .=+**=:. ***** .:-+++=-:. =#***= .:-=*+=-:. :#****. .:-=+++-::*****= .:-=+**** .:. ''' 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) if config['ascii_art']: console = Console(width=85, height=18) else: console = Console(width=70, height=8) layout = Layout() layout.split_row( Layout(flomp, name="left"), Layout(name="right") ) layout['right'].split_column( Layout(online, size=1), Layout(disk_usage, size=3), Layout(avail_backups, size=4) ) layout['left'].visible = config['ascii_art'] # actually print the thing console.print(Panel.fit( layout, box=box.DOUBLE, border_style=emphasis ))