From fe327606aba90578ac5cdd11342efdaa2530bfc1 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Fri, 15 Dec 2023 11:51:53 -0500 Subject: [PATCH 1/5] [1801] Add Warning for FDevIDs --- EDMarketConnector.py | 31 +++++++++++++++++++++++++++++++ L10n/en.template | 6 ++++++ 2 files changed, 37 insertions(+) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 596f0423..66c9cb67 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -2318,6 +2318,35 @@ sys.path: {sys.path}''' ) config.set('plugins_not_py3_last', int(time())) + def check_fdev_ids(): + """Display message about missing FDEVID files""" + fdev_files = {'commodity.csv', 'rare_commodity.csv'} + for file in fdev_files: + file = pathlib.Path(config.respath_path / 'FDevIDs' / file) + if file.is_file(): + continue + # LANG: Popup-text about missing FDEVID Files + popup_text = _( + "FDevID Files not found! Some functionality regarding commodities " + r"may be disabled.\r\n\r\n Do you want to open the Wiki page on " + "how to set up submodules?" + ) + # And now we do need these to be actual \r\n + popup_text = popup_text.replace('\\n', '\n') + popup_text = popup_text.replace('\\r', '\r') + + openwikipage = tk.messagebox.askquestion( + # LANG: Popup window title for missing FDEVID files + _('FDevIDs: Missing Commodity Files'), + popup_text + ) + if openwikipage == "yes": + webbrowser.open( + "https://github.com/EDCD/EDMarketConnector/wiki/Running-from-source" + "#obtain-a-copy-of-the-application-source" + ) + break + # UI Transparency ui_transparency = config.get_int('ui_transparency') if ui_transparency == 0: @@ -2331,6 +2360,8 @@ sys.path: {sys.path}''' root.after(1, messagebox_not_py3) # Show warning popup for killswitches matching current version root.after(2, show_killswitch_poppup, root) + # Check for FDEV IDs + root.after(3, check_fdev_ids) # Start the main event loop root.mainloop() diff --git a/L10n/en.template b/L10n/en.template index f89873af..3aed0952 100644 --- a/L10n/en.template +++ b/L10n/en.template @@ -213,6 +213,12 @@ /* EDMarketConnector.py: Popup-text about 'active' plugins without Python 3.x support; In files: EDMarketConnector.py:2253:2259; */ "One or more of your enabled plugins do not yet have support for Python 3.x. Please see the list on the '{PLUGINS}' tab of '{FILE}' > '{SETTINGS}'. You should check if there is an updated version available, else alert the developer that they need to update the code for Python 3.x.\r\n\r\nYou can disable a plugin by renaming its folder to have '{DISABLED}' on the end of the name." = "One or more of your enabled plugins do not yet have support for Python 3.x. Please see the list on the '{PLUGINS}' tab of '{FILE}' > '{SETTINGS}'. You should check if there is an updated version available, else alert the developer that they need to update the code for Python 3.x.\r\n\r\nYou can disable a plugin by renaming its folder to have '{DISABLED}' on the end of the name."; +/* EDMarketConnector.py: Popup-text about missing FDEVID Files; In files: EDMarketConnector.py:2329; */ +"FDevID Files not found! Some functionality regarding commodities may be disabled.\r\n\r\n Do you want to open the Wiki page on how to set up submodules?" = "FDevID Files not found! Some functionality regarding commodities may be disabled.\r\n\r\n Do you want to open the Wiki page on how to set up submodules?"; + +/* EDMarketConnector.py: Popup window title for missing FDEVID files; In files: EDMarketConnector.py:2340; */ +"FDevIDs: Missing Commodity Files" = "FDevIDs: Missing Commodity Files"; + /* EDMarketConnector.py: Settings > Plugins tab; prefs.py: Label on Settings > Plugins tab; In files: EDMarketConnector.py:2263; prefs.py:986; */ "Plugins" = "Plugins"; From ad455f144d75d39af33235e0973bdcd33420bac1 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Fri, 15 Dec 2023 12:00:51 -0500 Subject: [PATCH 2/5] [1801] Clarify Varnames --- EDMarketConnector.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 66c9cb67..9eec3b1f 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -2319,11 +2319,11 @@ sys.path: {sys.path}''' config.set('plugins_not_py3_last', int(time())) def check_fdev_ids(): - """Display message about missing FDEVID files""" + """Display message about missing FDEVID files.""" fdev_files = {'commodity.csv', 'rare_commodity.csv'} for file in fdev_files: - file = pathlib.Path(config.respath_path / 'FDevIDs' / file) - if file.is_file(): + fdevid_file = pathlib.Path(config.respath_path / 'FDevIDs' / file) + if fdevid_file.is_file(): continue # LANG: Popup-text about missing FDEVID Files popup_text = _( From 25a46545ca4a092b8a44bec7d9eee725b583e51c Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Fri, 15 Dec 2023 12:11:23 -0500 Subject: [PATCH 3/5] [1801] Add missing file check to builder --- FDevIDs | 1 - build.py | 21 ++++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) delete mode 160000 FDevIDs diff --git a/FDevIDs b/FDevIDs deleted file mode 160000 index 069b09b1..00000000 --- a/FDevIDs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 069b09b1afbd2001248ad93b1481d6f6a309c6f5 diff --git a/build.py b/build.py index 6d7f865b..e1d37f49 100644 --- a/build.py +++ b/build.py @@ -177,13 +177,20 @@ def build() -> None: ], } - py2exe.freeze( - version_info=version_info, - windows=[windows_config], - console=[console_config], - data_files=data_files, - options=options, - ) + try: + py2exe.freeze( + version_info=version_info, + windows=[windows_config], + console=[console_config], + data_files=data_files, + options=options, + ) + except FileNotFoundError: + sys.exit( + "Build Failed due to Missing Files! Have you set up your submodules? \n" + "https://github.com/EDCD/EDMarketConnector/wiki/Running-from-source" + "#obtain-a-copy-of-the-application-source" + ) iss_template_path: str = "./resources/EDMC_Installer_Config_template.txt" iss_file_path: str = "./EDMC_Installer_Config.iss" From 62929366464f5368afe908efac9f21c1a6bbcb96 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Fri, 15 Dec 2023 13:21:00 -0500 Subject: [PATCH 4/5] [1801] Fix FDEVIDs --- FDevIDs | 1 + 1 file changed, 1 insertion(+) create mode 160000 FDevIDs diff --git a/FDevIDs b/FDevIDs new file mode 160000 index 00000000..069b09b1 --- /dev/null +++ b/FDevIDs @@ -0,0 +1 @@ +Subproject commit 069b09b1afbd2001248ad93b1481d6f6a309c6f5 From 17e740d3ee0b710d959865d1b1d0407c47b546d9 Mon Sep 17 00:00:00 2001 From: Phoebe Date: Sat, 16 Dec 2023 02:10:55 +0100 Subject: [PATCH 5/5] [1801] Check for files at output generation Adds a check to see if the FDevID files exist to the output file generation process. If they don't generate a warning log entry and continue without them. --- companion.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/companion.py b/companion.py index 520afff2..217370d5 100644 --- a/companion.py +++ b/companion.py @@ -1204,6 +1204,9 @@ def fixup(data: CAPIData) -> CAPIData: # noqa: C901, CCR001 # Can't be usefully if not commodity_map: # Lazily populate for f in ('commodity.csv', 'rare_commodity.csv'): + if not os.path.isfile(config.respath_path / 'FDevIDs/' / f): + logger.warning(f'FDevID file {f} not found! Generating output without these commodity name rewrites.') + continue with open(config.respath_path / 'FDevIDs' / f, 'r') as csvfile: reader = csv.DictReader(csvfile)