demotomohiro / remocolab

remocolab is a Python module to allow remote access to Google Colaboratory using SSH or TurboVNC.
MIT License
316 stars 229 forks source link

Using the "rich" module to make program output prettier #81

Open ochen1 opened 3 years ago

ochen1 commented 3 years ago

rich is a Python module I have grown very fond of. It gives immediate beauty to any Python project, and even goes as far as making the exceptions beautiful.

It comes with support for all types of terminals and stdouts, making printing colors and different fonts a breeze. This includes the old terminal we are all used to, and Jupyter notebook output cells. It's syntax is simple, beautiful, and easy to use. Here is a sample:

from rich.console import Console
console = Console()
console.log("This is a [bold]log[/bold]. Time and line numbers will be shown.")
console.print("remocolab installed [green bold]successfully[/]! :tada:")

image

With all of this simplicity, there is still a lot of control over the program's output.

The package size is under 50MB, so it shouldn't impact the lightweightedness of this program much.

Can I implement this into remocolab? I think it would make the output of the program much more attractive.

😍

EDIT: rich installed in under 2s with pip on my system.

ochen1 commented 3 years ago

Another primary reason why I want to use rich is that its (beautiful 😍) progress bars offer support on Deepnote (and all Jupyter notebooks, I presume). Deepnote doesn't support ipywidgets. rich uses low-level APIs (ie. stdin, stdout).

demotomohiro commented 3 years ago

I don't think remocolab need to print text with colors. It just prints key fingerprint of host, passwords and ssh command.