Skip to content

Commit b833646

Browse files
author
Kirill
committed
Added sudo password checker
1 parent ccfc461 commit b833646

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Utilities/installer.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@
22
from sys import exit as sys_exit
33
from subprocess import call
44
from subprocess import check_output
5+
from subprocess import CalledProcessError
6+
wrong_pass_count = 0
57

68

9+
def passInput(args):
10+
sudo_pass = getpass.getpass()
11+
install_command = "sudo make install"
12+
try:
13+
install_proc = check_output("echo {} | sudo -S {}".format(sudo_pass, install_command), shell=True, cwd=args[1])
14+
except CalledProcessError:
15+
print("\nWrong password\nRun updater again")
16+
sys_exit(1)
17+
18+
719
def check_make_status():
820
make_check_proc = check_output(["make", "--version"])
921
if (make_check_proc.decode('utf-8')).count("GNU Make") == 1:
@@ -24,12 +36,7 @@ def make_action(*args):
2436
elif len(args) == 2 and args[0] == "install":
2537

2638
print("make install")
27-
# TODO: add wrong pass checker
28-
sudo_pass = getpass.getpass()
29-
install_command = "sudo make install"
30-
install_proc = check_output("echo {} | sudo -S {}".format(sudo_pass, install_command), shell=True, cwd=args[1])
31-
if install_proc.decode('utf-8').count("Sorry, try again.") >= 1:
32-
pass
39+
passInput(args)
3340

3441
else:
3542
print("args error")

0 commit comments

Comments
 (0)