From ba008e7c106fea6dd6a2ff1606cc11818f30ba2b Mon Sep 17 00:00:00 2001 From: F4ria Date: Sat, 23 Sep 2023 19:41:39 +0800 Subject: [PATCH 1/3] fix: keep interface upgraded, retrieved gpx data maybe failed --- run_page/keep_sync.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/run_page/keep_sync.py b/run_page/keep_sync.py index 617e26b478c..2fd26d01d81 100755 --- a/run_page/keep_sync.py +++ b/run_page/keep_sync.py @@ -85,23 +85,26 @@ def parse_raw_data_to_nametuple( ): raw_data_url = run_data.get("rawDataURL") r = session.get(raw_data_url) - # string strart with `H4sIAAAAAAAA` --> decode and unzip - run_points_data = decode_runmap_data(r.text) - run_points_data_gpx = run_points_data - if TRANS_GCJ02_TO_WGS84: - run_points_data = [ - list(eviltransform.gcj2wgs(p["latitude"], p["longitude"])) - for p in run_points_data - ] - for i, p in enumerate(run_points_data_gpx): - p["latitude"] = run_points_data[i][0] - p["longitude"] = run_points_data[i][1] + if r.status_code == 200: + # string strart with `H4sIAAAAAAAA` --> decode and unzip + run_points_data = decode_runmap_data(r.text) + run_points_data_gpx = run_points_data + if TRANS_GCJ02_TO_WGS84: + run_points_data = [ + list(eviltransform.gcj2wgs(p["latitude"], p["longitude"])) + for p in run_points_data + ] + for i, p in enumerate(run_points_data_gpx): + p["latitude"] = run_points_data[i][0] + p["longitude"] = run_points_data[i][1] + else: + run_points_data = [[p["latitude"], p["longitude"]] for p in run_points_data] + if with_download_gpx: + if str(keep_id) not in old_gpx_ids: + gpx_data = parse_points_to_gpx(run_points_data_gpx, start_time) + download_keep_gpx(gpx_data, str(keep_id)) else: - run_points_data = [[p["latitude"], p["longitude"]] for p in run_points_data] - if with_download_gpx: - if str(keep_id) not in old_gpx_ids: - gpx_data = parse_points_to_gpx(run_points_data_gpx, start_time) - download_keep_gpx(gpx_data, str(keep_id)) + print(f"ID {keep_id} retrieved gpx data failed") heart_rate = None if run_data["heartRate"]: heart_rate = run_data["heartRate"].get("averageHeartRate", None) From 16c6405868615876f3c6b895b3c9e73664d17e25 Mon Sep 17 00:00:00 2001 From: F4ria Date: Sat, 23 Sep 2023 19:45:55 +0800 Subject: [PATCH 2/3] fix: lint --- run_page/keep_sync.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run_page/keep_sync.py b/run_page/keep_sync.py index 2fd26d01d81..76104f9e7e6 100755 --- a/run_page/keep_sync.py +++ b/run_page/keep_sync.py @@ -98,7 +98,9 @@ def parse_raw_data_to_nametuple( p["latitude"] = run_points_data[i][0] p["longitude"] = run_points_data[i][1] else: - run_points_data = [[p["latitude"], p["longitude"]] for p in run_points_data] + run_points_data = [ + [p["latitude"], p["longitude"]] for p in run_points_data + ] if with_download_gpx: if str(keep_id) not in old_gpx_ids: gpx_data = parse_points_to_gpx(run_points_data_gpx, start_time) From 3c281b35798925dc6d25100f9f5415430ea12359 Mon Sep 17 00:00:00 2001 From: F4ria Date: Sat, 23 Sep 2023 21:57:16 +0800 Subject: [PATCH 3/3] style: reformat code --- run_page/keep_sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_page/keep_sync.py b/run_page/keep_sync.py index 76104f9e7e6..c632d0ae42c 100755 --- a/run_page/keep_sync.py +++ b/run_page/keep_sync.py @@ -85,7 +85,7 @@ def parse_raw_data_to_nametuple( ): raw_data_url = run_data.get("rawDataURL") r = session.get(raw_data_url) - if r.status_code == 200: + if r.ok: # string strart with `H4sIAAAAAAAA` --> decode and unzip run_points_data = decode_runmap_data(r.text) run_points_data_gpx = run_points_data