Skip to content

Commit

Permalink
Continued work fixing deps install
Browse files Browse the repository at this point in the history
- return install_deps func if no command to run
- add error message box for GUI
- exit on error if AppImageLauncher installed
- add missing space
- auto-remove AppImageLauncher if installed
- fix appimagelauncher removal command
- fix clobbered variable
- ask user confirmation before removing AppImageLauncher
- add secondary text to continue question
- fix title and text for GUI question
- add note about system reboot in log
- use CLI continue question for removing appimagelauncher if not tk
- add explanation to cli_question
- use minimal set of arch deps
- remove --overwrite from pacman command for arch
- Revert "remove --overwrite from pacman command for arch"
- This reverts commit 8cd077c.
- return False for appimage wine version check if fuse not yet installed
- Revert "return False for appimage wine version check if fuse not yet installed"
- This reverts commit aefb28c.
- use glob instead of rglob for listing appimages
- escape '*' in pacman command
- force non-sh pkexec for arch dep installs
- Revert "escape '*' in pacman command"
- This reverts commit ab2ec57.
- skip extra check for fuse package
- fix variable definition
- Revert "force non-sh pkexec for arch dep installs"
- This reverts commit 470d198.
- put quotes around command
- use normal str instead of raw for '*'
- double-escape asterisk
- add error message for fedora and arch dep handling
- clean up suggested dep install command
- clean swap pkexec out for sudo
- add detail text to GUI logos_error
- log package status for debugging
- add detail for general logos_error
- simplify hasattr checks
- build showerror parameters according to passed values
- fix parent param
- auto-add command to clipboard in GUI
- destroy error window on exit
- fix typo
- various pep8 fixes
- add debugging info to query_packages
- add more debug output
- move "break" statement
- add some audio/video pkgs
- update arch package list
- remove extra debug logging
- update fedora packages
- use rpm command for dnf workaround
  • Loading branch information
n8marti authored and thw26 committed Aug 23, 2024
1 parent 8fc670d commit 4d17504
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 57 deletions.
6 changes: 3 additions & 3 deletions control.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import network
import system
import tui_curses
import tui_app
# import tui_app
import utils
# import wine

Expand Down Expand Up @@ -252,7 +252,7 @@ def remove_all_index_files(app=None):
logging.error(f"Error removing {file_to_remove}: {e}")

msg.logos_msg("======= Removing all LogosBible index files done! =======")
if app and hasattr(app, 'status_evt'):
if hasattr(app, 'status_evt'):
app.root.event_generate(app.status_evt)
sys.exit(0)

Expand Down Expand Up @@ -291,7 +291,7 @@ def set_winetricks():
"1: Use local winetricks.",
"2: Download winetricks from the Internet"
]
winetricks_choice = tui_curses.menu(options, title, question_text)
winetricks_choice = tui_curses.menu(options, title, question_text) # noqa: E501

logging.debug(f"winetricks_choice: {winetricks_choice}")
if winetricks_choice.startswith("1"):
Expand Down
33 changes: 27 additions & 6 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from tkinter import BooleanVar
from tkinter import font
from tkinter import IntVar
from tkinter import messagebox
from tkinter import simpledialog
from tkinter import StringVar
from tkinter.ttk import Button
Expand Down Expand Up @@ -335,11 +336,6 @@ def hide_tooltip(self, event=None):
self.tooltip_visible = False


def input_prompt(root, title, prompt):
# Prompt for the password
input = simpledialog.askstring(title, prompt, show='*', parent=root)
return input

class PromptGui(Frame):
def __init__(self, root, title="", prompt="", **kwargs):
super(PromptGui, self).__init__(root, **kwargs)
Expand All @@ -350,5 +346,30 @@ def __init__(self, root, title="", prompt="", **kwargs):
self.options['prompt'] = prompt

def draw_prompt(self):
store_button = Button(self.root, text="Store Password", command=lambda: input_prompt(self.root, self.options))
store_button = Button(
self.root,
text="Store Password",
command=lambda: input_prompt(self.root, self.options)
)
store_button.pack(pady=20)


def show_error(message, title="Fatal Error", detail=None, app=None, parent=None): # noqa: E501
kwargs = {'message': message}
if parent and hasattr(app, parent):
kwargs['parent'] = app.__dict__.get(parent)
if detail:
kwargs['detail'] = detail
messagebox.showerror(title, **kwargs)
if hasattr(app, 'root'):
app.root.destroy()


def ask_question(question, secondary):
return messagebox.askquestion(question, secondary)


def input_prompt(root, title, prompt):
# Prompt for the password
input = simpledialog.askstring(title, prompt, show='*', parent=root)
return input
7 changes: 4 additions & 3 deletions gui_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,12 +688,13 @@ def configure_app_button(self, evt=None):

def run_installer(self, evt=None):
classname = "LogosLinuxInstaller"
self.new_win = Toplevel()
InstallerWindow(self.new_win, self.root, class_=classname)
self.installer_win = Toplevel()
InstallerWindow(self.installer_win, self.root, class_=classname)
self.root.icon = config.LOGOS_ICON_URL

def run_logos(self, evt=None):
#TODO: Add reference to App here so the status message is sent to the GUI? See msg.status and wine.run_logos
# TODO: Add reference to App here so the status message is sent to the
# GUI? See msg.status and wine.run_logos
t = Thread(target=wine.run_logos)
t.start()

Expand Down
12 changes: 12 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import msg
import network
import os
import shutil
import sys
import system
import tui_app
Expand Down Expand Up @@ -388,6 +389,17 @@ def main():
logging.info(f"{config.LLI_TITLE}, {config.LLI_CURRENT_VERSION} by {config.LLI_AUTHOR}.") # noqa: E501
logging.debug(f"Installer log file: {config.LOGOS_LOG}")

# Check for AppImageLauncher
if shutil.which('AppImageLauncher'):
question_text = "Remove AppImageLauncher?"
secondary = (
"LogosLinuxInstaller is not compatible with AppImageLauncher.\n"
"Remove AppImageLauncher now? A reboot will be required."
)
no_text = "User declined to remove AppImageLauncher."
msg.logos_continue_question(question_text, no_text, secondary)
system.remove_appimagelauncher()

network.check_for_updates()

# Check if app is installed.
Expand Down
49 changes: 36 additions & 13 deletions msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from pathlib import Path

import config
from gui import ask_question
from gui import show_error

logging.console_log = []

Expand Down Expand Up @@ -142,17 +144,25 @@ def logos_warn(message):
logos_msg(message)


def logos_error(message, secondary=None):
def logos_error(message, secondary=None, detail=None, app=None, parent=None):
if detail is None:
message = f"{message}\n{detail}"
logging.critical(message)
WIKI_LINK = "https://github.com/FaithLife-Community/LogosLinuxInstaller/wiki" # noqa: E501
TELEGRAM_LINK = "https://t.me/linux_logos"
MATRIX_LINK = "https://matrix.to/#/#logosbible:matrix.org"
help_message = f"If you need help, please consult:\n{WIKI_LINK}\n{TELEGRAM_LINK}\n{MATRIX_LINK}" # noqa: E501
if config.DIALOG == 'curses' and secondary != "info":
logging.critical(message)
if config.DIALOG == 'tk':
show_error(
message,
detail=f"{detail}\n{help_message}",
app=app,
parent=parent
)
elif config.DIALOG == 'curses' and secondary != "info":
status(message)
status(help_message)
elif secondary != "info":
logging.critical(message)
logos_msg(message)
else:
logos_msg(message)
Expand All @@ -163,13 +173,17 @@ def logos_error(message, secondary=None):
except FileNotFoundError: # no pid file when testing functions
pass
os.kill(os.getpgid(os.getpid()), signal.SIGKILL)

if hasattr(app, 'destroy'):
app.destroy()
sys.exit(1)


def cli_question(QUESTION_TEXT):
def cli_question(question_text, secondary):
while True:
try:
yn = input(f"{QUESTION_TEXT} [Y/n]: ")
cli_msg(secondary)
yn = input(f"{question_text} [Y/n]: ")
except KeyboardInterrupt:
print()
logos_error("Cancelled with Ctrl+C")
Expand All @@ -182,9 +196,14 @@ def cli_question(QUESTION_TEXT):
logos_msg("Type Y[es] or N[o].")


def cli_continue_question(QUESTION_TEXT, NO_TEXT, SECONDARY):
if not cli_question(QUESTION_TEXT):
logos_error(NO_TEXT, SECONDARY)
def cli_continue_question(question_text, no_text, secondary):
if not cli_question(question_text, secondary):
logos_error(no_text)


def gui_continue_question(question_text, no_text, secondary):
if ask_question(question_text, secondary) == 'no':
logos_error(no_text)


def cli_acknowledge_question(QUESTION_TEXT, NO_TEXT):
Expand All @@ -204,11 +223,15 @@ def cli_ask_filepath(question_text):
return answer.strip('"').strip("'")


def logos_continue_question(QUESTION_TEXT, NO_TEXT, SECONDARY):
if config.DIALOG == 'curses':
def logos_continue_question(question_text, no_text, secondary, app=None):
if config.DIALOG == 'tk':
gui_continue_question(question_text, no_text, secondary)
elif app is None:
cli_continue_question(question_text, no_text, secondary)
elif config.DIALOG == 'curses':
pass
else:
cli_continue_question(QUESTION_TEXT, NO_TEXT, SECONDARY)
logos_error(f"Unhandled question: {question_text}")


def logos_acknowledge_question(QUESTION_TEXT, NO_TEXT):
Expand Down Expand Up @@ -249,7 +272,7 @@ def status(text, app=None):
app.root.event_generate('<<UpdateStatus>>')
elif config.DIALOG == 'curses':
app.status_q.put(f"{timestamp} {text}")
app.report_waiting(f"{app.status_q.get()}", dialog=config.use_python_dialog)
app.report_waiting(f"{app.status_q.get()}", dialog=config.use_python_dialog) # noqa: E501
logging.info(f"{text}")
else:
'''Prints message to stdout regardless of log level.'''
Expand Down
Loading

0 comments on commit 4d17504

Please sign in to comment.