Skip to content

Commit 2b4fa99

Browse files
Merge pull request #21 from felipealfonsog/development
Updates - new futures
2 parents ce72596 + b6b2ddf commit 2b4fa99

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/upd8all_updater.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import getpass
55
import subprocess
66
import select
7-
import pty
87
import json
98

109
# Function to print the welcome message
@@ -20,7 +19,7 @@ def print_welcome_message():
2019
""")
2120

2221
# 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):
2423
proc = subprocess.Popen(
2524
["sudo", "-S", *command.split()],
2625
stdin=subprocess.PIPE,
@@ -30,7 +29,11 @@ def execute_command_with_sudo(command):
3029
)
3130

3231
# 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()
3437
if proc.returncode != 0:
3538
print(f"Error executing command with sudo: {command}")
3639
sys.exit(1)
@@ -40,7 +43,7 @@ def update_pacman():
4043
print("\nUpdating Pacman packages...")
4144
print("-------------------------------------")
4245
command = "pacman -Syu --noconfirm"
43-
execute_command_with_sudo(command)
46+
execute_command_with_sudo(command, sudo_password)
4447

4548
# Function to update AUR packages with Yay
4649
def update_yay():

src/upd8all_updater_unstable.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import getpass
55
import subprocess
66
import select
7-
import pty
87
import json
98

109
# Function to print the welcome message
@@ -20,7 +19,7 @@ def print_welcome_message():
2019
""")
2120

2221
# 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):
2423
proc = subprocess.Popen(
2524
["sudo", "-S", *command.split()],
2625
stdin=subprocess.PIPE,
@@ -30,7 +29,11 @@ def execute_command_with_sudo(command):
3029
)
3130

3231
# 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()
3437
if proc.returncode != 0:
3538
print(f"Error executing command with sudo: {command}")
3639
sys.exit(1)
@@ -40,7 +43,7 @@ def update_pacman():
4043
print("\nUpdating Pacman packages...")
4144
print("-------------------------------------")
4245
command = "pacman -Syu --noconfirm"
43-
execute_command_with_sudo(command)
46+
execute_command_with_sudo(command, sudo_password)
4447

4548
# Function to update AUR packages with Yay
4649
def update_yay():

0 commit comments

Comments
 (0)