File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 4
4
import getpass
5
5
import subprocess
6
6
import select
7
- import pty
8
7
import json
9
8
10
9
# Function to print the welcome message
@@ -20,7 +19,7 @@ def print_welcome_message():
20
19
""" )
21
20
22
21
# Function to execute a command with sudo as needed
23
- def execute_command_with_sudo (command ):
22
+ def execute_command_with_sudo (command , sudo_password ):
24
23
proc = subprocess .Popen (
25
24
["sudo" , "-S" , * command .split ()],
26
25
stdin = subprocess .PIPE ,
@@ -30,7 +29,11 @@ def execute_command_with_sudo(command):
30
29
)
31
30
32
31
# Send sudo password
33
- stdout , stderr = proc .communicate (input = sudo_password + '\n ' )
32
+ proc .stdin .write (sudo_password + '\n ' )
33
+ proc .stdin .flush ()
34
+
35
+ # Wait for the process to complete
36
+ proc .communicate ()
34
37
if proc .returncode != 0 :
35
38
print (f"Error executing command with sudo: { command } " )
36
39
sys .exit (1 )
@@ -40,7 +43,7 @@ def update_pacman():
40
43
print ("\n Updating Pacman packages..." )
41
44
print ("-------------------------------------" )
42
45
command = "pacman -Syu --noconfirm"
43
- execute_command_with_sudo (command )
46
+ execute_command_with_sudo (command , sudo_password )
44
47
45
48
# Function to update AUR packages with Yay
46
49
def update_yay ():
Original file line number Diff line number Diff line change 4
4
import getpass
5
5
import subprocess
6
6
import select
7
- import pty
8
7
import json
9
8
10
9
# Function to print the welcome message
@@ -20,7 +19,7 @@ def print_welcome_message():
20
19
""" )
21
20
22
21
# Function to execute a command with sudo as needed
23
- def execute_command_with_sudo (command ):
22
+ def execute_command_with_sudo (command , sudo_password ):
24
23
proc = subprocess .Popen (
25
24
["sudo" , "-S" , * command .split ()],
26
25
stdin = subprocess .PIPE ,
@@ -30,7 +29,11 @@ def execute_command_with_sudo(command):
30
29
)
31
30
32
31
# Send sudo password
33
- stdout , stderr = proc .communicate (input = sudo_password + '\n ' )
32
+ proc .stdin .write (sudo_password + '\n ' )
33
+ proc .stdin .flush ()
34
+
35
+ # Wait for the process to complete
36
+ proc .communicate ()
34
37
if proc .returncode != 0 :
35
38
print (f"Error executing command with sudo: { command } " )
36
39
sys .exit (1 )
@@ -40,7 +43,7 @@ def update_pacman():
40
43
print ("\n Updating Pacman packages..." )
41
44
print ("-------------------------------------" )
42
45
command = "pacman -Syu --noconfirm"
43
- execute_command_with_sudo (command )
46
+ execute_command_with_sudo (command , sudo_password )
44
47
45
48
# Function to update AUR packages with Yay
46
49
def update_yay ():
You can’t perform that action at this time.
0 commit comments