Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix codoon and Upload tcx_to_garmin #662

Merged
merged 12 commits into from
Apr 24, 2024
Merged

Conversation

Vensent
Copy link
Contributor

@Vensent Vensent commented Apr 19, 2024

  1. Fix the tcx format in codoon_sync.py
  2. Add tcx_sync_garmin.py
  3. Add oppo_sync.py, while currently not work.

Closes #645

Vensent added 2 commits April 20, 2024 01:21
also modify some format problem when uploading the tcx file export from
codoon.
Copy link

vercel bot commented Apr 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
running-page ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 22, 2024 4:25pm

@yihong0618
Copy link
Owner

nice pr will take a look tonight

@yihong0618 yihong0618 requested a review from ben-29 April 20, 2024 04:54
Copy link
Owner

@yihong0618 yihong0618 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice code

activity_creator = ET.Element(
"Creator",
{
"xsi:type": "Device_t"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能取个更有表示点的名字么?

Copy link
Contributor Author

@Vensent Vensent Apr 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能取个更有表示点的名字么?

我打开佳明的tcx这部分长这样:

<Creator xsi:type="Device_t">
  <Name>Forerunner 945</Name>
  <UnitId>********</UnitId>
  <ProductID>****</ProductID>
  <Version>
    <VersionMajor>13</VersionMajor>
    <VersionMinor>0</VersionMinor>
    <BuildMajor>0</BuildMajor>
    <BuildMinor>0</BuildMinor>
  </Version>
</Creator>

应该不能改成其他的样子了。

- name: Run sync Oppo heytap script, note currently this script is not worked
if: env.RUN_TYPE == 'oppo'
run: |
python run_page/oppo_sync.py ${{ secrets.OPPO_ID }} ${{ secrets.OPPO_CLIENT_SECRET }} ${{ secrets.OPPO_CLIENT_REFRESH_TOKEN }} --with-tcx
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not support gpx right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not support gpx right?

代码可以先放上来,现在内部消息是这个oppo heytap健康的数据暂时还没有完全对外开放,不过在计划中了。我的代码是--with-tcx、--with-gpx都可以的。需要更新一下说明不?

xmlstr = minidom.parseString(ET.tostring(training_center_database)).toprettyxml(indent=" ", encoding="UTF-8")
with open(TCX_FOLDER + "/" + fit_id + ".tcx", "w") as f:
f.write(str(xmlstr.decode("UTF-8")))
f.close()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not need close here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not need close here

python里面写文件的流最后不用关么?因为我平时用java多一点,写完流必须要关。。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got reference here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with statements handle the close automatically

Copy link
Collaborator

@ben-29 ben-29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the lint using black to pass the CI

xmlstr = minidom.parseString(ET.tostring(training_center_database)).toprettyxml(indent=" ", encoding="UTF-8")
with open(TCX_FOLDER + "/" + fit_id + ".tcx", "w") as f:
f.write(str(xmlstr.decode("UTF-8")))
f.close()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with statements handle the close automatically

author_lang.text = "en"
author.append(author_lang)
author_part = ET.Element("PartNumber")
author_part.text = "006-D2449-00"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract this string to a variable and leave a comment specifying which Garmin device it is for.

@Vensent
Copy link
Contributor Author

Vensent commented Apr 22, 2024

Let me check it locally before submitting PR again.

@Vensent Vensent closed this Apr 22, 2024
@yihong0618 yihong0618 reopened this Apr 22, 2024
@yihong0618
Copy link
Owner

Let me check it locally before submitting PR again.

just continue commit is Ok~~

@Vensent
Copy link
Contributor Author

Vensent commented Apr 22, 2024

Please review again. Thx @yihong0618 @ben-29

"""
file_names = os.listdir(TCX_FOLDER)
tcx = TCXReader()
tcx_files = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the TCX_FOLDER is empty?



if __name__ == "__main__":
if not os.path.exists(TCX_FOLDER):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ben-29 Please have a look at here. If TCX_FOLDER does not exit, we'll create first.


dict(sorted(tcx_files_dict.items()))

return tcx_files_dict.values()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the TCX_FOLDER is empty, we'll get an empty result. And it's OK. @ben-29

@ben-29
Copy link
Collaborator

ben-29 commented Apr 23, 2024

LGTM

Copy link
Owner

@yihong0618 yihong0618 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job

@yihong0618 yihong0618 merged commit c91c325 into yihong0618:master Apr 24, 2024
6 checks passed
chensoul added a commit to chensoul/running_page that referenced this pull request Apr 26, 2024
* yihong0618-master: (33 commits)
  Fix codoon and Upload tcx_to_garmin (yihong0618#662)
  Update README-CN.md (yihong0618#663)
  add keep2strava (yihong0618#653)
  Add data to 'running page runners' table (yihong0618#656)
  style: use Tailwind CSS (yihong0618#655)
  feat: fill country (yihong0618#654)
  docs: add runner (yihong0618#651)
  doc: add new runner
  docs: update README (yihong0618#650)
  docs: add a comment in `src/utils/consts.ts` to remind about security considerations regarding the `MAPBOX_TOKEN` (yihong0618#644)
  fix: no package manager
  fix: tachyons-sass import error (yihong0618#639)
  Update README.md (yihong0618#638)
  Add proxy config, add keep config, change npm registry, use yarn (yihong0618#634)
  chore: fix typo (yihong0618#633)
  chore: Update package manager and ignore requirements-dev.txt (yihong0618#632)
  add run.drink.cafe (yihong0618#628)
  feat: coros sync (yihong0618#623)
  Fix README typo (yihong0618#624)
  fix: ts type error (yihong0618#622)
  ...
ben-29 added a commit to ben-29/workouts_page that referenced this pull request May 26, 2024
* refs/heads/upstream: (71 commits)
  Add laqieer's running page to README (yihong0618#672)
  chore: add raycast extension support (yihong0618#670)
  add </details> (yihong0618#669)
  fix the deprecation warning (yihong0618#668)
  Fix codoon and Upload tcx_to_garmin (yihong0618#662)
  Update README-CN.md (yihong0618#663)
  add keep2strava (yihong0618#653)
  Add data to 'running page runners' table (yihong0618#656)
  style: use Tailwind CSS (yihong0618#655)
  feat: fill country (yihong0618#654)
  docs: add runner (yihong0618#651)
  doc: add new runner
  docs: update README (yihong0618#650)
  docs: add a comment in `src/utils/consts.ts` to remind about security considerations regarding the `MAPBOX_TOKEN` (yihong0618#644)
  fix: no package manager
  fix: tachyons-sass import error (yihong0618#639)
  Update README.md (yihong0618#638)
  Add proxy config, add keep config, change npm registry, use yarn (yihong0618#634)
  chore: fix typo (yihong0618#633)
  chore: Update package manager and ignore requirements-dev.txt (yihong0618#632)
  ...

# Conflicts:
#	run_page/gpxtrackposter/track.py
#	run_page/keep_sync.py
Kugin pushed a commit to Kugin/running_page that referenced this pull request Sep 13, 2024
* add oppo_sync and tcx_to_garmin.py

also modify some format problem when uploading the tcx file export from
codoon.

* 修改readme.md

* 修复CI遇到的问题,已经根据评审修改相关的代码

* 解决运行时参数少了的异常

* Optimise the lap details in tcx file.

* type: 修改漏掉的文件

scope:

subject:

* 完善代码逻辑

* 修改代码漏洞

* 修改oppo的请求接口地址

* 解决编译问题

* 解决咕咚tcx生成异常问题,同时解决当前存在的CI问题

* 使用black完成代码format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

使用--with-tcx参数获取咕咚数据,导出来的TCX文件导入Garmin还是会提示报错无法导入
3 participants