mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-05-06 18:31:02 +03:00
[Minor] Slight Refactorings
This commit is contained in:
parent
26f06b7bf0
commit
5c14a7afc7
@ -338,8 +338,6 @@ class EDMCContextFilter(logging.Filter):
|
|||||||
# <https://stackoverflow.com/questions/2203424/python-how-to-retrieve-class-information-from-a-frame-object#2220759>
|
# <https://stackoverflow.com/questions/2203424/python-how-to-retrieve-class-information-from-a-frame-object#2220759>
|
||||||
try:
|
try:
|
||||||
frame_info = inspect.getframeinfo(frame)
|
frame_info = inspect.getframeinfo(frame)
|
||||||
# raise(IndexError) # TODO: Remove, only for testing
|
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
# Separate from the print below to guarantee we see at least this much.
|
# Separate from the print below to guarantee we see at least this much.
|
||||||
print('EDMCLogging:EDMCContextFilter:caller_attributes(): Failed in `inspect.getframinfo(frame)`')
|
print('EDMCLogging:EDMCContextFilter:caller_attributes(): Failed in `inspect.getframinfo(frame)`')
|
||||||
|
@ -38,17 +38,17 @@ from monitor import monitor
|
|||||||
from EDMCLogging import get_main_logger
|
from EDMCLogging import get_main_logger
|
||||||
|
|
||||||
|
|
||||||
def get_sys_report(config: config.AbstractConfig) -> str:
|
def get_sys_report(active_config: config.AbstractConfig) -> str:
|
||||||
"""Gather system information about Elite, the Host Computer, and EDMC."""
|
"""Gather system information about Elite, the Host Computer, and EDMC."""
|
||||||
# Calculate Requested Information
|
# Calculate Requested Information
|
||||||
plt = platform.uname()
|
plt = platform.uname()
|
||||||
locale.setlocale(locale.LC_ALL, "")
|
locale.setlocale(locale.LC_ALL, "")
|
||||||
lcl = locale.getlocale()
|
lcl = locale.getlocale()
|
||||||
monitor.currentdir = config.get_str(
|
monitor.currentdir = active_config.get_str(
|
||||||
"journaldir", default=config.default_journal_dir
|
"journaldir", default=active_config.default_journal_dir
|
||||||
)
|
)
|
||||||
if not monitor.currentdir:
|
if not monitor.currentdir:
|
||||||
monitor.currentdir = config.default_journal_dir
|
monitor.currentdir = active_config.default_journal_dir
|
||||||
try:
|
try:
|
||||||
logfile = monitor.journal_newest_filename(monitor.currentdir)
|
logfile = monitor.journal_newest_filename(monitor.currentdir)
|
||||||
if logfile is None:
|
if logfile is None:
|
||||||
@ -108,21 +108,21 @@ def copy_sys_report(root: tk.Tk, report: str) -> None:
|
|||||||
messagebox.showinfo("System Profiler", "System Report copied to Clipboard", parent=root)
|
messagebox.showinfo("System Profiler", "System Report copied to Clipboard", parent=root)
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main(active_config: config.AbstractConfig) -> None:
|
||||||
"""Entry Point for the System Profiler."""
|
"""Entry Point for the System Profiler."""
|
||||||
# Now Let's Begin
|
# Now Let's Begin
|
||||||
root: tk.Tk = tk.Tk()
|
root: tk.Tk = tk.Tk()
|
||||||
root.withdraw() # Hide the window initially to calculate the dimensions
|
root.withdraw() # Hide the window initially to calculate the dimensions
|
||||||
try:
|
try:
|
||||||
icon_image = tk.PhotoImage(
|
icon_image = tk.PhotoImage(
|
||||||
file=path.join(cur_config.respath_path, "io.edcd.EDMarketConnector.png")
|
file=path.join(active_config.respath_path, "io.edcd.EDMarketConnector.png")
|
||||||
)
|
)
|
||||||
|
|
||||||
root.iconphoto(True, icon_image)
|
root.iconphoto(True, icon_image)
|
||||||
except tk.TclError:
|
except tk.TclError:
|
||||||
root.iconbitmap(path.join(cur_config.respath_path, "EDMarketConnector.ico"))
|
root.iconbitmap(path.join(active_config.respath_path, "EDMarketConnector.ico"))
|
||||||
|
|
||||||
sys_report = get_sys_report(cur_config)
|
sys_report = get_sys_report(active_config)
|
||||||
|
|
||||||
# Set up styling
|
# Set up styling
|
||||||
style = ttk.Style(root)
|
style = ttk.Style(root)
|
||||||
@ -182,7 +182,8 @@ if __name__ == "__main__":
|
|||||||
# Args: Only work if not frozen
|
# Args: Only work if not frozen
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog=appname,
|
prog=appname,
|
||||||
description="Prints diagnostic and debugging information about the current EDMC configuration.",
|
description="Prints diagnostic and debugging information "
|
||||||
|
"about the current EDMC configuration.",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--out-console",
|
"--out-console",
|
||||||
@ -203,4 +204,4 @@ if __name__ == "__main__":
|
|||||||
print(sys_report)
|
print(sys_report)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
main()
|
main(cur_config)
|
||||||
|
@ -840,8 +840,7 @@ class AppWindow:
|
|||||||
r' if downgrading between major versions with significant changes.\r\n\r\n'
|
r' if downgrading between major versions with significant changes.\r\n\r\n'
|
||||||
'Do you want to open GitHub to download the latest release?'
|
'Do you want to open GitHub to download the latest release?'
|
||||||
)
|
)
|
||||||
update_msg = update_msg.replace('\\n', '\n')
|
update_msg = update_msg.replace('\\n', '\n').replace('\\r', '\r')
|
||||||
update_msg = update_msg.replace('\\r', '\r')
|
|
||||||
stable_popup = tk.messagebox.askyesno(title=title, message=update_msg)
|
stable_popup = tk.messagebox.askyesno(title=title, message=update_msg)
|
||||||
if stable_popup:
|
if stable_popup:
|
||||||
webbrowser.open("https://github.com/EDCD/eDMarketConnector/releases/latest")
|
webbrowser.open("https://github.com/EDCD/eDMarketConnector/releases/latest")
|
||||||
@ -2064,17 +2063,15 @@ def validate_providers():
|
|||||||
|
|
||||||
# LANG: Popup-text about Reset Providers
|
# LANG: Popup-text about Reset Providers
|
||||||
popup_text = tr.tl(r'One or more of your URL Providers were invalid, and have been reset:\r\n\r\n')
|
popup_text = tr.tl(r'One or more of your URL Providers were invalid, and have been reset:\r\n\r\n')
|
||||||
for provider in reset_providers:
|
for provider, (old_prov, new_prov) in reset_providers.items():
|
||||||
# LANG: Text About What Provider Was Reset
|
# LANG: Text About What Provider Was Reset
|
||||||
popup_text += tr.tl(r'{PROVIDER} was set to {OLDPROV}, and has been reset to {NEWPROV}\r\n')
|
popup_text += tr.tl(r'{PROVIDER} was set to {OLDPROV}, and has been reset to {NEWPROV}\r\n').format(
|
||||||
popup_text = popup_text.format(
|
|
||||||
PROVIDER=provider,
|
PROVIDER=provider,
|
||||||
OLDPROV=reset_providers[provider][0],
|
OLDPROV=old_prov,
|
||||||
NEWPROV=reset_providers[provider][1]
|
NEWPROV=new_prov
|
||||||
)
|
)
|
||||||
# And now we do need these to be actual \r\n
|
# And now we do need these to be actual \r\n
|
||||||
popup_text = popup_text.replace('\\n', '\n')
|
popup_text = popup_text.replace('\\n', '\n').replace('\\r', '\r')
|
||||||
popup_text = popup_text.replace('\\r', '\r')
|
|
||||||
|
|
||||||
tk.messagebox.showinfo(
|
tk.messagebox.showinfo(
|
||||||
# LANG: Popup window title for Reset Providers
|
# LANG: Popup window title for Reset Providers
|
||||||
@ -2246,8 +2243,7 @@ sys.path: {sys.path}'''
|
|||||||
detail = tr.tl( # LANG: EDMC Critical Error Details
|
detail = tr.tl( # LANG: EDMC Critical Error Details
|
||||||
r"Here's what EDMC Detected:\r\n\r\n{ERR}\r\n\r\nDo you want to file a Bug Report on GitHub?"
|
r"Here's what EDMC Detected:\r\n\r\n{ERR}\r\n\r\nDo you want to file a Bug Report on GitHub?"
|
||||||
).format(ERR=err)
|
).format(ERR=err)
|
||||||
detail = detail.replace('\\n', '\n')
|
detail = detail.replace('\\n', '\n').replace('\\r', '\r')
|
||||||
detail = detail.replace('\\r', '\r')
|
|
||||||
msg = tk.messagebox.askyesno(
|
msg = tk.messagebox.askyesno(
|
||||||
title=title, message=message, detail=detail, icon=tkinter.messagebox.ERROR, type=tkinter.messagebox.YESNO,
|
title=title, message=message, detail=detail, icon=tkinter.messagebox.ERROR, type=tkinter.messagebox.YESNO,
|
||||||
parent=root
|
parent=root
|
||||||
@ -2278,8 +2274,7 @@ sys.path: {sys.path}'''
|
|||||||
DISABLED='.disabled'
|
DISABLED='.disabled'
|
||||||
)
|
)
|
||||||
# And now we do need these to be actual \r\n
|
# And now we do need these to be actual \r\n
|
||||||
popup_text = popup_text.replace('\\n', '\n')
|
popup_text = popup_text.replace('\\n', '\n').replace('\\r', '\r')
|
||||||
popup_text = popup_text.replace('\\r', '\r')
|
|
||||||
|
|
||||||
tk.messagebox.showinfo(
|
tk.messagebox.showinfo(
|
||||||
# LANG: Popup window title for list of 'broken' plugins that failed to load
|
# LANG: Popup window title for list of 'broken' plugins that failed to load
|
||||||
@ -2309,8 +2304,7 @@ sys.path: {sys.path}'''
|
|||||||
DISABLED='.disabled'
|
DISABLED='.disabled'
|
||||||
)
|
)
|
||||||
# And now we do need these to be actual \r\n
|
# And now we do need these to be actual \r\n
|
||||||
popup_text = popup_text.replace('\\n', '\n')
|
popup_text = popup_text.replace('\\n', '\n').replace('\\r', '\r')
|
||||||
popup_text = popup_text.replace('\\r', '\r')
|
|
||||||
|
|
||||||
tk.messagebox.showinfo(
|
tk.messagebox.showinfo(
|
||||||
# LANG: Popup window title for list of 'enabled' plugins that don't work with Python 3.x
|
# LANG: Popup window title for list of 'enabled' plugins that don't work with Python 3.x
|
||||||
|
7
prefs.py
7
prefs.py
@ -829,7 +829,8 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
appearance_frame,
|
appearance_frame,
|
||||||
# LANG: Appearance - Help/hint text for UI scaling selection
|
# LANG: Appearance - Help/hint text for UI scaling selection
|
||||||
text=tr.tl('100 means Default{CR}Restart Required for{CR}changes to take effect!')
|
text=tr.tl('100 means Default{CR}Restart Required for{CR}changes to take effect!')
|
||||||
).grid(column=3, padx=self.PADX, pady=self.PADY, sticky=tk.E, row=cur_row)
|
) # E1111
|
||||||
|
self.ui_scaling_defaultis.grid(column=3, padx=self.PADX, pady=self.PADY, sticky=tk.E, row=cur_row)
|
||||||
|
|
||||||
# Transparency slider
|
# Transparency slider
|
||||||
ttk.Separator(appearance_frame, orient=tk.HORIZONTAL).grid(
|
ttk.Separator(appearance_frame, orient=tk.HORIZONTAL).grid(
|
||||||
@ -1310,10 +1311,10 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
self._destroy()
|
self._destroy()
|
||||||
# Send to the Post Config if we updated the update branch or need to restart
|
# Send to the Post Config if we updated the update branch or need to restart
|
||||||
post_flags = {
|
post_flags = {
|
||||||
'Update': True if self.curr_update_track != self.update_paths.get() else False,
|
'Update': self.curr_update_track != self.update_paths.get(), # Just needs bool not true if else false
|
||||||
'Track': self.update_paths.get(),
|
'Track': self.update_paths.get(),
|
||||||
'Parent': self,
|
'Parent': self,
|
||||||
'Restart_Req': True if self.req_restart else False
|
'Restart_Req': self.req_restart # Sipmle Bool Needed
|
||||||
}
|
}
|
||||||
if self.callback:
|
if self.callback:
|
||||||
self.callback(**post_flags)
|
self.callback(**post_flags)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user