Created
July 20, 2022 12:00
-
-
Save omar2205/a9f134b8810664e89bc838e983facf7a to your computer and use it in GitHub Desktop.
python: update multiple lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, time, random | |
import os.path | |
clear = lambda: os.system('cls') | |
clear() | |
def print_logo(): | |
print(f''' | |
\t _____ | |
\t / /\\ | |
\t/____/ \\ | |
\t\\ \ / | |
\t \\____\/ | |
For unlimited internet in Egypt.\n\n\n | |
''' | |
) | |
# mock functions, use them to parse the actual test | |
def get_random(r1, r2): | |
return round(random.uniform(r1, r2), 2) | |
get_speed = lambda: f'↓ {get_random(29.5, 33.8)} Mbit/s - ↑ {get_random(2.2, 3.2)} Mbit/s' | |
get_ping = lambda: f'{random.randrange(70, 100)} ms' | |
get_test_url = lambda: f'http://example.com/{random.randrange(1000, 5000)}' | |
# Replace with the actual IP check | |
curr_ip = '1.1.1.1' | |
def check_ip(): | |
# replace with an actual test | |
if os.path.exists('C:\\a.txt'): | |
return True | |
return False | |
i = 0 | |
UP = '\x1B[3A' | |
CLR = '\x1B[0K' | |
print_logo() | |
while True: | |
ip_changed = check_ip() | |
if not ip_changed: | |
clear() | |
print('Please change your IP') | |
continue | |
speed = get_speed() | |
ping = get_ping() | |
res = get_test_url() | |
print(f'{UP}Speed {speed}{CLR}\nPing {ping}{CLR}\nRes {res}{CLR}') | |
i += 1 | |
time.sleep(1) | |
if i == 25: | |
break | |
print('Done') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment