-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest.py
83 lines (72 loc) · 2.57 KB
/
test.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
73
74
75
76
77
78
79
80
81
82
83
# Initiliazing the idle loader/spinner class
import time
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
BADFAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
BG_ERR_TXT = '\033[41m' # For critical errors and crashes
BG_HEAD_TXT = '\033[100m'
BG_ENDL_TXT = '\033[46m'
BG_CRIT_TXT = '\033[45m'
BG_HIGH_TXT = '\033[41m'
BG_MED_TXT = '\033[43m'
BG_LOW_TXT = '\033[44m'
BG_INFO_TXT = '\033[42m'
BG_SCAN_TXT_START = '\x1b[6;30;42m'
BG_SCAN_TXT_END = '\x1b[0m'
class Spinner:
busy = False
delay = 0.005 # 0.05
@staticmethod
def spinning_cursor():
while 1:
#for cursor in '|/-\\/': yield cursor #←↑↓→
#for cursor in '←↑↓→': yield cursor
#for cursor in '....scanning...please..wait....': yield cursor
for cursor in ' ': yield cursor
def __init__(self, delay=None):
self.spinner_generator = self.spinning_cursor()
if delay and float(delay): self.delay = delay
self.disabled = False
def spinner_task(self):
inc = 0
try:
while self.busy:
if not self.disabled:
x = bcolors.BG_SCAN_TXT_START+next(self.spinner_generator)+bcolors.BG_SCAN_TXT_END
inc = inc + 1
print(x,end='')
if inc>random.uniform(0,terminal_size()): #30 init
print(end="\r")
bcolors.BG_SCAN_TXT_START = '\x1b[6;30;'+str(round(random.uniform(40,47)))+'m'
inc = 0
sys.stdout.flush()
time.sleep(self.delay)
if not self.disabled:
sys.stdout.flush()
except (KeyboardInterrupt, SystemExit):
print("\n\t"+ bcolors.BG_ERR_TXT+"Xploitfree received a series of Ctrl+C hits. Quitting..." +bcolors.ENDC)
sys.exit(1)
def start(self):
self.busy = True
try:
threading.Thread(target=self.spinner_task).start()
except Exception as e:
print("\n")
def stop(self):
try:
self.busy = False
time.sleep(self.delay)
except (KeyboardInterrupt, SystemExit):
print("\n\t"+ bcolors.BG_ERR_TXT+"Xploitfree received a series of Ctrl+C hits. Quitting..." +bcolors.ENDC)
sys.exit(1)
# End ofloader/spinner class
# Instantiating the spinner/loader class
spinner = Spinner()
spinner.start()
spinner.stop()