Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions wahoomc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion wahoomc/file_directory_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions wahoomc/osm_maps_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down