Refactor formatting in update.py for improved readability
This commit is contained in:
@@ -31,7 +31,9 @@ def help_message():
|
|||||||
" --full-speed, -F Upgrade packages and use all available cores for compilation. (Default: 8 cores)",
|
" --full-speed, -F Upgrade packages and use all available cores for compilation. (Default: 8 cores)",
|
||||||
)
|
)
|
||||||
printfe("green", " --skip-check, -s Skip checking for dotfiles updates.")
|
printfe("green", " --skip-check, -s Skip checking for dotfiles updates.")
|
||||||
printfe("green", " --system, -S Update system packages (flatpak, brew, apt, etc.)")
|
printfe(
|
||||||
|
"green", " --system, -S Update system packages (flatpak, brew, apt, etc.)"
|
||||||
|
)
|
||||||
printfe("green", " --help, -h Display this help message.")
|
printfe("green", " --help, -h Display this help message.")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@@ -246,10 +248,10 @@ def get_sudo_password_from_1password(username, hostname):
|
|||||||
def get_distro():
|
def get_distro():
|
||||||
"""Detect the Linux distribution."""
|
"""Detect the Linux distribution."""
|
||||||
try:
|
try:
|
||||||
with open('/etc/os-release', 'r') as f:
|
with open("/etc/os-release", "r") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith('ID='):
|
if line.startswith("ID="):
|
||||||
return line.split('=', 1)[1].strip().strip('"').lower()
|
return line.split("=", 1)[1].strip().strip('"').lower()
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -296,7 +298,9 @@ def update_system_packages(sudo_password):
|
|||||||
full_cmd = sudo_cmd + cmd
|
full_cmd = sudo_cmd + cmd
|
||||||
printfe("cyan", f"Running: {' '.join(full_cmd)}")
|
printfe("cyan", f"Running: {' '.join(full_cmd)}")
|
||||||
if sudo_password:
|
if sudo_password:
|
||||||
result = subprocess.run(full_cmd, input=sudo_password + "\n", text=True, check=False)
|
result = subprocess.run(
|
||||||
|
full_cmd, input=sudo_password + "\n", text=True, check=False
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
result = subprocess.run(full_cmd, check=False)
|
result = subprocess.run(full_cmd, check=False)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user