【问题标题】:Automating submit50 using bash script使用 bash 脚本自动提交 50
【发布时间】:2023-01-07 23:15:55
【问题描述】:

因此,在完成 CS50P 课程的大部分内容后,我注意到我可以通过 submit50 提交作业。然而,这非常耗时(每次提交可能需要 6 - 8 分钟才能连接,可能是因为我没有使用代码空间)而且我有超过一半的课程价值提交,所以我认为写一个很酷的自动提交的脚本。我花了半天时间写了这个小脚本,我真的希望它能工作!!!

#!/bin/bash

cd /home/pilks/cs50/python

for d in ./*;
do cd $d && for d2 in ./*;
do cd $d2 && yes yes | submit50 cs50/problems/2022/python/$d2 --log-level info;
cd ..
done
cd ..
done

它“有效”,因为它连接并且似乎对“你确定吗?”说“是”问题。但随后由于某些未知原因上传失败。使用 --log-level info 提供此日志:


Connecting...
Authenticating...
Verifying...
(INFO) git clone --bare --single-branch ssh://git@ssh.github.com:443/me50/[user].git --branch cs50/problems/2022/python/./einstein
(INFO) git clone --bare --single-branch ssh://git@ssh.github.com:443/me50/[user].git
Preparing...
(INFO) git config --bool core.bare false
(INFO) git config --path core.worktree /tmp/tmp7lbn0lum
(INFO) git checkout --force cs50/problems/2022/python/./einstein .gitattributes
(INFO) git config user.email [user]@users.noreply.github.com
(INFO) git config user.name [user]
(INFO) git symbolic-ref HEAD refs/heads/cs50/problems/2022/python/./einstein
(INFO) git add -f einstein.py
Files that will be submitted:
./einstein.py
Keeping in mind the course's policy on academic honesty, are you sure you want to submit these files (yes/no)? Uploading...
(INFO) git commit -m 'automated commit by submit50 [lang=en_GB:en]' --allow-empty
Sorry, something's wrong, please try again. If the problem persists, please 
visit our status page https://cs50.statuspage.io for more information.
Submission cancelled.
Connecting...

...然后继续尝试上传下一个文件。

看起来它在 git commit 上失败了,但理论上我的脚本正在做与手动输入详细信息完全相同的事情,特别是在 git 方面,它已经提前设置为自动工作。

我已经手动完成了,它工作得很好。作为参考,这是我手动执行时的日志并且它有效:

$ submit50 cs50/problems/2022/python/einstein --log-level info
Connecting...
Authenticating...
Verifying...
(INFO) git clone --bare --single-branch ssh://git@ssh.github.com:443/me50/pilks7 .git --branch cs50/problems/2022/python/einstein
Preparing...
(INFO) git config --bool core.bare false
(INFO) git config --path core.worktree /tmp/tmpobm69p4d
(INFO) git checkout --force cs50/problems/2022/python/einstein .gitattributes
(INFO) git config user.email pilks7@users.noreply.github.com
(INFO) git config user.name pilks7
(INFO) git symbolic-ref HEAD refs/heads/cs50/problems/2022/python/einstein
(INFO) git add -f einstein.py
Files that will be submitted:
./einstein.py
Keeping in mind the course's policy on academic honesty, are you sure you want to submit these files (yes/no)? yes
Uploading...
(INFO) git commit -m 'automated commit by submit50 [lang=en_GB:en]' --allow-empty
(INFO) git push origin cs50/problems/2022/python/einstein
(INFO) git rev-parse HEAD
Go to https://submit.cs50.io/users/pilks7/cs50/problems/2022/python/einstein to see your results.

有没有可能之间的区别 cs50/problems/2022/python/einsteincs50/problems/2022/python/./einstein 导致问题?毕竟,它不会失败

Invalid slug: cs50/problems/2022/python/./0_funcs_and_vars/einstein/einstein.py.
 Did you mean something else?
Submission cancelled.

【问题讨论】:

    标签: bash cs50


    【解决方案1】:

    好的,这里的答案很明显......

    我从 shell 脚本的 ./* 中删除了前导 ./。现在是这样写的:

    #!/bin/bash
    
    cd /home/pilks/cs50/python
    
    for d in *;
    do cd $d && for d2 in *;
    do cd $d2 && yes yes | submit50 cs50/problems/2022/python/$d2 --log-level info;
    cd ..
    done
    cd ..
    done
    

    并且似乎(希望)现在可以正常工作。

    【讨论】:

      猜你喜欢
      • 2012-01-18
      • 1970-01-01
      • 2016-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多