mirror of
https://github.com/Snigdha-OS/snigdhaos-welcome.git
synced 2025-09-20 22:14:56 +02:00
⚡️ perf(advance): formatted strings for cleaner log output
This commit is contained in:
@@ -227,37 +227,43 @@ class Main(Gtk.Window):
|
|||||||
|
|
||||||
|
|
||||||
def on_adv_install_clicked(self, widget):
|
def on_adv_install_clicked(self, widget):
|
||||||
|
"""
|
||||||
|
Handles the "Advanced Install" button click. Configures online installation settings
|
||||||
|
and launches the appropriate installer based on system state.
|
||||||
|
"""
|
||||||
|
# Check if the Pacman lockfile exists
|
||||||
if not os.path.exists(self.pacman_lockfile):
|
if not os.path.exists(self.pacman_lockfile):
|
||||||
|
# Update the button's style and label to reflect the enabled state
|
||||||
widget.set_name("button_adv_install_enabled")
|
widget.set_name("button_adv_install_enabled")
|
||||||
widget.get_child().set_markup(
|
widget.get_child().set_markup("<span size='large'>Online Installation</span>")
|
||||||
"<span size='large'>Online Installation</span>"
|
|
||||||
)
|
# Retrieve the selected background color from the theme
|
||||||
selected_bg_color = widget.get_style_context().lookup_color(
|
selected_bg_color = widget.get_style_context().lookup_color("theme_selected_bg_color")
|
||||||
"theme_selected_bg_color"
|
if selected_bg_color[0]: # If the color is successfully retrieved
|
||||||
)
|
# Convert the Gdk.Color to HEX format for custom CSS
|
||||||
if selected_bg_color[0] is True:
|
|
||||||
theme_bg_hex_color = self.convert_to_hex(selected_bg_color[1])
|
theme_bg_hex_color = self.convert_to_hex(selected_bg_color[1])
|
||||||
custom_css = css.replace("@theme_base_color_button", theme_bg_hex_color)
|
custom_css = css.replace("@theme_base_color_button", theme_bg_hex_color)
|
||||||
self.style_provider.load_from_data(custom_css, len(custom_css))
|
self.style_provider.load_from_data(custom_css, len(custom_css))
|
||||||
|
|
||||||
|
# Reset the style for the "Easy Install" button
|
||||||
self.button_easy_install.set_name("button_easy_install")
|
self.button_easy_install.set_name("button_easy_install")
|
||||||
|
|
||||||
|
# Configuration files for the advanced installation
|
||||||
settings_adv_file = "/etc/calamares/settings-advanced.conf"
|
settings_adv_file = "/etc/calamares/settings-advanced.conf"
|
||||||
system_update_file = "/etc/calamares/modules/packages-system-update.conf"
|
system_update_file = "/etc/calamares/modules/packages-system-update.conf"
|
||||||
app_cmd = [
|
|
||||||
"sudo",
|
# Copy the advanced settings configuration file
|
||||||
"cp",
|
app_cmd = ["sudo", "cp", settings_adv_file, "/etc/calamares/settings.conf"]
|
||||||
settings_adv_file,
|
|
||||||
"/etc/calamares/settings.conf",
|
|
||||||
]
|
|
||||||
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||||
app_cmd = [
|
|
||||||
"sudo",
|
# Copy the system update configuration for online installation
|
||||||
"cp",
|
app_cmd = ["sudo", "cp", system_update_file, "/etc/calamares/modules/packages.conf"]
|
||||||
system_update_file,
|
|
||||||
"/etc/calamares/modules/packages.conf",
|
|
||||||
]
|
|
||||||
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||||
|
|
||||||
|
# Check for EFI bootloader support
|
||||||
efi_file_check = self.file_check("/sys/firmware/efi/fw_platform_size")
|
efi_file_check = self.file_check("/sys/firmware/efi/fw_platform_size")
|
||||||
if efi_file_check is True:
|
if efi_file_check:
|
||||||
|
# If EFI is supported, display the bootloader selection dialog
|
||||||
md = MessageDialogBootloader(
|
md = MessageDialogBootloader(
|
||||||
title="Choose Bootloader",
|
title="Choose Bootloader",
|
||||||
install_method="Online Installation",
|
install_method="Online Installation",
|
||||||
@@ -267,23 +273,24 @@ class Main(Gtk.Window):
|
|||||||
)
|
)
|
||||||
md.show_all()
|
md.show_all()
|
||||||
else:
|
else:
|
||||||
|
# Launch the Calamares installer directly if not an EFI system
|
||||||
subprocess.Popen([self.calamares_polkit, "-d"], shell=False)
|
subprocess.Popen([self.calamares_polkit, "-d"], shell=False)
|
||||||
else:
|
else:
|
||||||
print(
|
# Handle the case where a Pacman lockfile exists
|
||||||
"[ERROR]: Pacman lockfile found %s, is another pacman process running ?"
|
print(f"[ERROR]: Pacman lockfile found {self.pacman_lockfile}, is another pacman process running?")
|
||||||
% self.pacman_lockfile
|
|
||||||
)
|
# Display a warning dialog about the lockfile
|
||||||
md = Gtk.MessageDialog(
|
md = Gtk.MessageDialog(
|
||||||
parent=self,
|
parent=self,
|
||||||
flags=0,
|
flags=0,
|
||||||
message_type=Gtk.MessageType.WARNING,
|
message_type=Gtk.MessageType.WARNING,
|
||||||
buttons=Gtk.ButtonsType.OK,
|
buttons=Gtk.ButtonsType.OK,
|
||||||
text="Pacman lockfile found %s, is another pacman process running ?"
|
text=f"Pacman lockfile found {self.pacman_lockfile}, is another pacman process running?",
|
||||||
% self.pacman_lockfile,
|
|
||||||
title="Warning",
|
title="Warning",
|
||||||
)
|
)
|
||||||
md.run()
|
md.run()
|
||||||
md.destroy()
|
md.destroy()
|
||||||
|
|
||||||
def on_gp_clicked(self, widget):
|
def on_gp_clicked(self, widget):
|
||||||
app_cmd = ["/usr/bin/gparted"]
|
app_cmd = ["/usr/bin/gparted"]
|
||||||
pacman_cmd = [
|
pacman_cmd = [
|
||||||
|
Reference in New Issue
Block a user