check_inet.py
unknown
python
4 years ago
640 B
7
Indexable
import subprocess as sp
from os import system
from time import sleep
from time import strftime
from rich import print
zeit = f'{strftime("%H:%M")}'
while True:
sleep(2)
try:
t = sp.check_output('ping -n 1 google.de')
system('cls')
try:
print(f'[green]ONLINE[/green] since {zeit_offline}')
zeit = f'{strftime("%H:%M")}'
except Exception:
print(f'[green]ONLINE[/green] since {zeit}')
except Exception as e:
system('cls')
print(f'[red]OFFLINE[/red] since {zeit}') if e.returncode == 1 else print(e)
zeit_offline = f'{strftime("%H:%M")}'
Editor is loading...