-
Notifications
You must be signed in to change notification settings - Fork 124
尝试解决 "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
hermitong
wants to merge
246
commits into
malinkang:main
Choose a base branch
from
hermitong:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
大佬好!第一次用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.
试过的方法(均无效):
最终解决方案:更改时间设定,从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天以外,有没有其他影响。另外,我猜测一定有其他的更新更好方法,但是因为怕占用您宝贵时间,所以抛砖引玉,希望能有一点点帮助。