forked from malkemit/namizun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.py
118 lines (102 loc) · 4.33 KB
/
menu.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import config
import display
from time import sleep
from monitor import get_size
from threading import Thread
from monitor import monitor
def running_setter():
display.banner()
print(f"\n{display.cornsilk}Do you want uploader to be activated?")
selection = input(f"\n{display.green}y{display.cornsilk}/{display.red}n{display.cornsilk}?\n")
if selection.lower() == 'y':
config.set_parameter('running', True)
return main_menu()
elif selection.lower() == 'n':
config.set_parameter('running', False)
return main_menu()
else:
return running_setter()
def speed_setter():
display.banner()
print(f"\n{display.cornsilk}Choose upload speed? (max = 5, min = 1)\n"
f"{display.red}Warning: The higher the speed, the higher the CPU consumption{display.cornsilk}\n")
selection = int(input(f"\n{display.cyan}1{display.cornsilk} to {display.cyan}5{display.cornsilk}?"))
if selection in range(1, 6):
config.set_parameter('speed', selection)
return main_menu()
else:
return speed_setter()
def coefficient_setter():
display.banner()
print(f"\n{display.cornsilk}What is your limit coefficient?"
f"(max = {display.cyan}12{display.cornsilk}, min = {display.cyan}3{display.cornsilk})\n")
selection = int(input(f"\n{display.cyan}3{display.cornsilk} to {display.cyan}12{display.cornsilk}?"))
if selection in range(3, 13):
config.set_parameter('coefficient', selection)
return main_menu()
else:
return coefficient_setter()
def total_upload_before_reboot_setter():
display.banner()
print(f"\n{display.cornsilk}How much did you upload before the last reboot?"
f"(max = {display.cyan}50000{display.cornsilk}GB)\n")
selection = int(input("\nJust enter GB amount?"))
if selection <= 50000:
config.set_parameter('total_upload_before_reboot', selection * 1024 * 1024 * 1024)
return main_menu()
else:
return total_upload_before_reboot_setter()
def total_download_before_reboot_setter():
display.banner()
print(f"\n{display.cornsilk}How much did you download before the last reboot?"
f"(max = {display.cyan}5000{display.cornsilk}GB)\n")
selection = int(input("\nJust enter GB amount?"))
if selection <= 5000:
config.set_parameter('total_download_before_reboot', selection * 1024 * 1024 * 1024)
return main_menu()
else:
return total_download_before_reboot_setter()
def running_status():
if config.get_parameter('running'):
return display.green + "True"
else:
return display.red + "False"
def main_menu():
sleep(0.5)
config.set_parameter('in_submenu', False)
print(
f"\n{display.gold}--------------{display.magenta}Control menu{display.gold}-------------\n\n{display.cornsilk}"
f"[1] - Uploader Running : {running_status() + display.cornsilk}\n"
f"[2] - Speed : {display.cyan + str(config.get_parameter('speed')) + display.cornsilk}\n"
f"[3] - Coefficient : {display.cyan + str(config.get_parameter('coefficient')) + display.cornsilk}\n"
f"[4] - Total Upload Before Reboot : "
f"{display.cyan + str(get_size(config.get_parameter('total_upload_before_reboot'))) + display.cornsilk}\n"
f"[5] - Total Download Before Reboot : "
f"{display.cyan + str(get_size(config.get_parameter('total_download_before_reboot'))) + display.cornsilk}\n\n"
f"[0] - Exit\n\n"
f"ENTER YOUR SELECTION: \n\n")
display.description()
display.line_jumper(-9)
user_choice = int(input())
if user_choice == 1:
config.set_parameter('in_submenu', True)
return running_setter()
elif user_choice == 2:
config.set_parameter('in_submenu', True)
return speed_setter()
elif user_choice == 3:
config.set_parameter('in_submenu', True)
return coefficient_setter()
elif user_choice == 4:
config.set_parameter('in_submenu', True)
return total_upload_before_reboot_setter()
elif user_choice == 5:
config.set_parameter('in_submenu', True)
return total_download_before_reboot_setter()
elif user_choice == 0:
config.set_parameter('in_submenu', None)
return display.reset + exit()
else:
return main_menu()
Thread(target=monitor).start()
Thread(target=main_menu).start()