8000 尝试解决 "Process completed with exit code 1" by hermitong · Pull Request #2 · malinkang/toggl2notion · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

尝试解决 "Process completed with exit code 1" #2

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

Open
wants to merge 246 commits into
base: main
Choose a base branch
from

Conversation

hermitong
Copy link

大佬好!第一次用git pull,也不知道是否使用正确,初学代码,技术不过关,还请谅解。

  • 遇到的问题:
    因为总是在运行Action时,程序卡在toggl.py那一步。日志记录显示:

Run python -u scripts/toggl.py
Traceback (most recent call last):
File "/home/runner/work/toggl2notion/toggl2notion/scripts/toggl.py", line 130, in
insert_to_notion()
File "/home/runner/work/toggl2notion/toggl2notion/scripts/toggl.py", line 55, in insert_to_notion
time_entries.sort(key=lambda x: x["start"], reverse=False)
AttributeError: 'str' object has no attribute 'sort'
Error: Process completed with exit code 1.

  • 试过的方法(均无效):

    • 更改Notion_Page和Notion_ID
    • 删除项目重新folk
    • 自己在创建并替换原有Notion_ID
  • 最终解决方案:更改时间设定,从90天改为89天

    • 检查过程:
      def insert_to_notion():

      ...省略之前的代码...

      response = requests.get(
      "https://api.track.toggl.com/api/v9/me/time_entries", params=params, auth=auth
      )
      time_entries = response.json()

      添加类型检查

      if not isinstance(time_entries, list):
      print("time_entries 不是一个列表, 实际类型:", type(time_entries))
      print("time_entries 内容:", time_entries)
      return # 可以选择在这里返回或处理错误

      time_entries.sort(key=lambda x: x["start"], reverse=False)

    • 确定问题情形
      此时运行时显示:
      Run python -u scripts/toggl.py
      time_entries 不是一个列表, 实际类型: <class 'str'>
      time_entries 内容: start_date must not be earlier than 2024-02-09

因此确定时由于时间问题导致。在更改get_time_entries和insert_to_notion中的时间为89天后,程序开始成功运行。

  • 请教
    因为我是初学python,水平不够,所以不清楚是否这样的更改在后续使用者层面,除了统计的数据少1天以外,有没有其他影响。另外,我猜测一定有其他的更新更好方法,但是因为怕占用您宝贵时间,所以抛砖引玉,希望能有一点点帮助。

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.

2 participants
0