-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.py
executable file
·72 lines (57 loc) · 1.84 KB
/
install.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
#!/usr/bin/python3
import os
import time
def banner() -> None:
"""
banner
"""
print(" installing password generator ".center(50, "#"))
def clear() -> None:
"""
detects the operating system and cleans the terminal
"""
os.system("clear")
def move_binaries(destine_path: str, usr_bin_path: str) -> None:
"""
copies the files and pastes them into the /usr/bin path so you can run it as a system command
"""
print("[*] prepare files on computer: %s " % os.environ["HOSTNAME"])
print("-> copying modules to /usr/bin")
os.system("sudo cp -r %s/modules %s" % (destine_path, usr_bin_path))
time.sleep(2.1)
os.system("mv %s/gen.py genpy && cp genpy %s" %
(destine_path, usr_bin_path))
def download_dependencies(file_path: str) -> None:
"""
iterate over the requirements.txt file and run the pip command to install the dependencies. If there were more than one dependency, it would be installed from 0 to ... number of packages
"""
list_dependences = [i for i in open(file_path).readlines()]
for i in list_dependences:
try:
print("installing %s" % i)
os.system("pip3 install %s" % i)
except KeyboardInterrupt as _:
clear()
print("canceling installation")
exit(1)
else:
clear()
print("[*] Good instalations")
time.sleep(2.1)
clear()
banner()
move_binaries(os.environ["PWD"], "/usr/bin")
def main() -> None:
"""
calls the functions and executes everything
"""
PWD: str = os.environ["PWD"] + "/requirements.txt"
clear()
banner()
download_dependencies(PWD)
print("""
Installation complete, to verify if it was installed correctly run the command: genpy --version
""")
exit(0)
if __name__ == "__main__":
main()