Skip to content

Commit

Permalink
Merge branch 'master' into v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yihong0618 committed Sep 18, 2023
2 parents 97f62b6 + 59ff75a commit fda1841
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
7 changes: 3 additions & 4 deletions run_page/gpx_to_strava_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import gpxpy as mod_gpxpy
from config import GPX_FOLDER
from strava_sync import run_strava_sync
from stravalib.exc import RateLimitTimeout, ActivityUploadFailed

from utils import make_strava_client, get_strava_last_time, upload_file_to_strava
from stravalib.exc import ActivityUploadFailed, RateLimitTimeout
from utils import get_strava_last_time, make_strava_client, upload_file_to_strava


def get_to_generate_files(last_time):
Expand All @@ -20,7 +19,7 @@ def get_to_generate_files(last_time):
for f in file_names:
if f.endswith(".gpx"):
file_path = os.path.join(GPX_FOLDER, f)
with open(file_path, "r") as r:
with open(file_path, "r", encoding="utf-8", errors="ignore") as r:
try:
gpx = mod_gpxpy.parse(r)
except Exception as e:
Expand Down
21 changes: 10 additions & 11 deletions run_page/gpxtrackposter/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@
import lxml
import polyline
import s2sphere as s2
from rich import print
from tcxreader.tcxreader import TCXReader
from polyline_processor import filter_out

from .exceptions import TrackLoadError
from .utils import parse_datetime_to_local

from fit_tool.fit_file import FitFile
from fit_tool.profile.messages.software_message import SoftwareMessage
from fit_tool.profile.messages.record_message import RecordMessage
from fit_tool.profile.messages.session_message import SessionMessage
from fit_tool.profile.messages.activity_message import ActivityMessage
from fit_tool.profile.messages.device_info_message import DeviceInfoMessage
from fit_tool.profile.messages.file_id_message import FileIdMessage
from fit_tool.profile.messages.record_message import RecordMessage
from fit_tool.profile.messages.session_message import SessionMessage
from fit_tool.profile.messages.software_message import SoftwareMessage
from fit_tool.profile.profile_type import Sport
from polyline_processor import filter_out
from rich import print
from tcxreader.tcxreader import TCXReader

from .exceptions import TrackLoadError
from .utils import parse_datetime_to_local

start_point = namedtuple("start_point", "lat lon")
run_map = namedtuple("polyline", "summary_polyline")
Expand Down Expand Up @@ -61,7 +60,7 @@ def load_gpx(self, file_name):
# (for example, treadmill runs pulled via garmin-connect-export)
if os.path.getsize(file_name) == 0:
raise TrackLoadError("Empty GPX file")
with open(file_name, "r") as file:
with open(file_name, "r", encoding="utf-8", errors="ignore") as file:
self._load_gpx_data(mod_gpxpy.parse(file))
except Exception as e:
print(
Expand Down

0 comments on commit fda1841

Please sign in to comment.