From c130daa5b1c275e0a2c10e8cdae85b4f63b092c4 Mon Sep 17 00:00:00 2001 From: sinan Date: Wed, 3 Sep 2025 01:04:39 +0300 Subject: [PATCH 1/3] Fixes the crash when the folder doesn't exist --- wahoomc/file_directory_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wahoomc/file_directory_functions.py b/wahoomc/file_directory_functions.py index 29fae38a..9eb8ff00 100644 --- a/wahoomc/file_directory_functions.py +++ b/wahoomc/file_directory_functions.py @@ -135,7 +135,7 @@ def delete_everything_in_folder(folder): """ delete all files and directories of given folder """ - files_and_folders = list(os.listdir(folder)) # [f for f in os.listdir(folder)] + files_and_folders = list(os.listdir(folder)) if os.path.exists(folder) else [] # [f for f in os.listdir(folder)] for file in files_and_folders: try: From f9cc63032ac01d60336e1f7a4cfe24b6e4c4b91f Mon Sep 17 00:00:00 2001 From: sinan Date: Wed, 3 Sep 2025 14:36:12 +0300 Subject: [PATCH 2/3] Added SUBPROCESS_ENCODING option. Some countries have unsupported characters by utf-8 that cause UnicodeDecodeError --- wahoomc/constants.py | 3 +++ wahoomc/osm_maps_functions.py | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/wahoomc/constants.py b/wahoomc/constants.py index d958331d..c95e5d86 100644 --- a/wahoomc/constants.py +++ b/wahoomc/constants.py @@ -20,6 +20,9 @@ OSMOSIS_WIN_FILE_PATH = os.path.join( USER_TOOLING_WIN_DIR, 'Osmosis', 'bin', 'osmosis.bat') +# Note: some countries have unsupported characters by utf-8 that cause UnicodeDecodeError +SUBPROCESS_ENCODING = "UTF-8" # Turkey: cp857 + # Python Package - wahooMapsCreator directory WAHOO_MC_DIR = os.path.dirname(__file__) RESOURCES_DIR = os.path.join(WAHOO_MC_DIR, 'resources') diff --git a/wahoomc/osm_maps_functions.py b/wahoomc/osm_maps_functions.py index 94128805..81bc668d 100644 --- a/wahoomc/osm_maps_functions.py +++ b/wahoomc/osm_maps_functions.py @@ -14,6 +14,8 @@ import shutil import logging +from scripts.VersionStamp.vssutil import constants + # import custom python packages from wahoomc.file_directory_functions import read_json_file_country_config, create_empty_directories, write_json_file_generic from wahoomc.constants_functions import translate_tags_to_keep, \ @@ -28,6 +30,7 @@ from wahoomc.constants import VERSION from wahoomc.constants import OSMOSIS_WIN_FILE_PATH from wahoomc.constants import USER_DL_DIR +from wahoomc.constants import SUBPROCESS_ENCODING from wahoomc.timings import Timings @@ -40,11 +43,11 @@ def run_subprocess_and_log_output(cmd, error_message, cwd=""): """ if not cwd: process = subprocess.run( - cmd, capture_output=True, text=True, encoding="utf-8", check=False) + cmd, capture_output=True, text=True, encoding=SUBPROCESS_ENCODING, check=False) else: process = subprocess.run( # pylint: disable=consider-using-with - cmd, capture_output=True, cwd=cwd, text=True, encoding="utf-8", check=False) + cmd, capture_output=True, cwd=cwd, text=True, encoding=SUBPROCESS_ENCODING, check=False) if error_message and process.returncode != 0: # 0 means success From 1bd09cf5ddf6fbf98a77cb644df44fd9feff7d86 Mon Sep 17 00:00:00 2001 From: sinan Date: Wed, 3 Sep 2025 15:01:43 +0300 Subject: [PATCH 3/3] removed IDE's auto imported 'constants' function, sorry for that --- wahoomc/osm_maps_functions.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/wahoomc/osm_maps_functions.py b/wahoomc/osm_maps_functions.py index 81bc668d..a5621a96 100644 --- a/wahoomc/osm_maps_functions.py +++ b/wahoomc/osm_maps_functions.py @@ -14,8 +14,6 @@ import shutil import logging -from scripts.VersionStamp.vssutil import constants - # import custom python packages from wahoomc.file_directory_functions import read_json_file_country_config, create_empty_directories, write_json_file_generic from wahoomc.constants_functions import translate_tags_to_keep, \