-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.py
72 lines (58 loc) · 3.72 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
This module contains utility functions for the CheggBot.
"""
import logging
import random
from os import system
from time import sleep
from colorama import Fore
from tqdm import trange
import yaml
logging.getLogger().setLevel(logging.INFO)
CONFIG = ''
with open("config.yaml", "r", encoding="utf-8") as yamlfile:
CONFIG = yaml.load(yamlfile, Loader=yaml.FullLoader)
def welcome_banner():
"""
Display a welcome banner.
"""
print(Fore.RED + """
▄████▄ ██░ ██ ▓█████ ▄████ ▄████ ▄▄▄ █ ██ ▄▄▄█████▓ ▒█████ ███▄ ▄███▓ ▄▄▄ ▄▄▄█████▓ ██▓ ▒█████ ███▄ █
▒██▀ ▀█ ▓██░ ██▒▓█ ▀ ██▒ ▀█▒ ██▒ ▀█▒ ▒████▄ ██ ▓██▒▓ ██▒ ▓▒▒██▒ ██▒▓██▒▀█▀ ██▒▒████▄ ▓ ██▒ ▓▒▓██▒▒██▒ ██▒ ██ ▀█ █
▒▓█ ▄ ▒██▀▀██░▒███ ▒██░▄▄▄░▒██░▄▄▄░ ▒██ ▀█▄ ▓██ ▒██░▒ ▓██░ ▒░▒██░ ██▒▓██ ▓██░▒██ ▀█▄ ▒ ▓██░ ▒░▒██▒▒██░ ██▒▓██ ▀█ ██▒
▒▓▓▄ ▄██▒░▓█ ░██ ▒▓█ ▄ ░▓█ ██▓░▓█ ██▓ ░██▄▄▄▄██ ▓▓█ ░██░░ ▓██▓ ░ ▒██ ██░▒██ ▒██ ░██▄▄▄▄██ ░ ▓██▓ ░ ░██░▒██ ██░▓██▒ ▐▌██▒
▒ ▓███▀ ░░▓█▒░██▓░▒████▒░▒▓███▀▒░▒▓███▀▒ ▓█ ▓██▒▒▒█████▓ ▒██▒ ░ ░ ████▓▒░▒██▒ ░██▒ ▓█ ▓██▒ ▒██▒ ░ ░██░░ ████▓▒░▒██░ ▓██░
░ ░▒ ▒ ░ ▒ ░▒░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ▒▒ ░░░▒░ ░ ░ ░ ░ ▒ ▒░ ░ ░ ░ ▒ ▒▒ ░ ░ ▒ ░░ ░ ░ ▒ ░ ░ ░
░ ▒ ▒ ░▒░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░░░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ▒ ░ ▒ ░░ ░ ░ ▒ ░ ░ ░
░ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░
Made with ❤️️ by """ + Fore.GREEN + "harrykp\n")
def log(message):
"""
Log a message.
"""
logging.info('%s..............', message)
def random_wait() -> None:
"""
Wait for a random amount of time.
"""
min_time, max_time = CONFIG.get('wait_time', [10, 20])
tym = random.randint(min_time, max_time)
log(f"Waiting for {tym} seconds")
for _ in trange(tym):
sleep(1)
def random_long_wait(min_time=5, max_time=10):
'''
Sleep the execution of scripts for x minutes where x is random value b/w [min_time,max_time]
'''
min_time, max_time = CONFIG.get('wait_after_queue_is_empty', [5, 10])
tym = random.randint(min_time, max_time) * 60
log(f"Waiting for {tym} seconds")
for _ in trange(tym):
sleep(1)
def clear_screen():
"""
Clear the screen.
"""
system('clear')