-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.py
36 lines (25 loc) · 901 Bytes
/
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
import redis
from rq import Queue
from rpq.RpqQueue import RpqQueue
REDIS_OBJ = redis.Redis(host='localhost', port=6379, db=0)
JOB_QUEUE = Queue(connection=REDIS_OBJ)
PRIORITY_QUEUE = RpqQueue(REDIS_OBJ, 'urls')
REDIS_OBJ.flushall()
class Colors:
HEADER = '\033[35m'
BLUE = '\033[34m'
GREEN = '\033[32m'
YELLOW = '\033[33m'
RED = '\033[31m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def INFO(x, name="X"):
print(f"{Colors.BOLD}{Colors.HEADER}[INFO: {name}] {x}{Colors.ENDC}{Colors.ENDC}")
def DEBUG(x, name="X"):
# print(f"{Colors.BOLD}{Colors.GREEN}[DEBUG: {name}]{Colors.ENDC}{Colors.ENDC} {x}")
pass
def ERROR(x, name="X"):
print(f"{Colors.BOLD}{Colors.RED}[ERROR: {name}]{Colors.ENDC}{Colors.ENDC} {x}")
def WARN(x, name="X"):
print(f"{Colors.BOLD}{Colors.YELLOW}[WARNING: {name}]{Colors.ENDC}{Colors.ENDC} {x}")