add optional ascii art
This commit is contained in:
parent
ec600fd1f6
commit
a0eb162f93
|
@ -1 +1,2 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
|
.vscode
|
|
@ -13,7 +13,9 @@ os.makedirs(config_dir, exist_ok=True)
|
||||||
# create an example config file if it doesn't already exist
|
# create an example config file if it doesn't already exist
|
||||||
if not os.path.exists(config_dir + '/config.toml'):
|
if not os.path.exists(config_dir + '/config.toml'):
|
||||||
with open(config_dir + '/config.toml', 'a+') as f:
|
with open(config_dir + '/config.toml', 'a+') as f:
|
||||||
f.write('''[repo]
|
f.write('''# Disable ascii art if you're using a screen reader or want smaller output
|
||||||
|
ascii_art = true
|
||||||
|
[repo]
|
||||||
# Example: `~/backups/backup.borg` or `ssh://agatha@some.place:22/~/backups/backup.borg`
|
# Example: `~/backups/backup.borg` or `ssh://agatha@some.place:22/~/backups/backup.borg`
|
||||||
path = ""
|
path = ""
|
||||||
# Leave empty if none
|
# Leave empty if none
|
||||||
|
|
53
main.py
53
main.py
|
@ -1,15 +1,34 @@
|
||||||
from prepare import borg_info_raw, readable_csize, csize, archive_num, last_archive_time, df_avail_readable, df_avail_bytes
|
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 import box
|
||||||
from rich.console import Group
|
from rich.console import Console
|
||||||
|
from rich.layout import Layout
|
||||||
from rich.padding import Padding
|
from rich.padding import Padding
|
||||||
from rich.panel import Panel
|
from rich.panel import Panel
|
||||||
from rich.progress import Progress, BarColumn
|
from rich.progress import Progress, BarColumn
|
||||||
from rich.style import Style
|
from rich.style import Style
|
||||||
|
from config import config
|
||||||
# actually print the thing
|
|
||||||
|
|
||||||
emphasis = Style(color='#d89961', bold=True)
|
emphasis = Style(color='#d89961', bold=True)
|
||||||
|
|
||||||
|
flomp = f'''[{emphasis}]
|
||||||
|
.=--::
|
||||||
|
-***##- ::. ...
|
||||||
|
+**##*: =##*. =*****:
|
||||||
|
:******+::.. :##*: :******.
|
||||||
|
=*************+====-::+*****+
|
||||||
|
.+**=:-==+++++****************:
|
||||||
|
-***. .:--==+++++******+
|
||||||
|
=**+. .:-+#***-
|
||||||
|
:***= *****
|
||||||
|
-***- -#***-
|
||||||
|
.=+**=:. *****
|
||||||
|
.:-+++=-:. =#***=
|
||||||
|
.:-=*+=-:. :#****.
|
||||||
|
.:-=+++-::*****=
|
||||||
|
.:-=+****
|
||||||
|
.:.
|
||||||
|
'''
|
||||||
|
|
||||||
if borg_info_raw.returncode == 0:
|
if borg_info_raw.returncode == 0:
|
||||||
online = Padding('[#82bfe0 bold]◉[/#82bfe0 bold] Host online', (0, 2))
|
online = Padding('[#82bfe0 bold]◉[/#82bfe0 bold] Host online', (0, 2))
|
||||||
else:
|
else:
|
||||||
|
@ -31,13 +50,27 @@ 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)
|
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(
|
if config['ascii_art']:
|
||||||
online,
|
console = Console(width=85, height=18)
|
||||||
disk_usage,
|
else:
|
||||||
avail_backups
|
console = Console(width=70, height=8)
|
||||||
|
|
||||||
|
layout = Layout()
|
||||||
|
layout.split_row(
|
||||||
|
Layout(flomp, name="left"),
|
||||||
|
Layout(name="right")
|
||||||
)
|
)
|
||||||
|
|
||||||
print(Panel.fit(
|
layout['right'].split_column(
|
||||||
output_group,
|
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
|
box=box.DOUBLE, border_style=emphasis
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in New Issue