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/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: diff --git a/wahoomc/osm_maps_functions.py b/wahoomc/osm_maps_functions.py index 94128805..a5621a96 100644 --- a/wahoomc/osm_maps_functions.py +++ b/wahoomc/osm_maps_functions.py @@ -28,6 +28,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 +41,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