raspbian python脚本在启动时出现EOF错误

时间:2017-05-24 21:03:14

标签: python linux

我正在尝试设置一个非常简单的脚本来处理在覆盆子pi 3模型B上通过vlc播放培训视频。

我可以启动到CLI并运行程序正常,但如果我将它添加到rc.local,我在第60行收到错误,EOFError:EOF读取一行时 任何人都可以帮我解决这个问题吗?

第60行是"entry = input("\nVideo to play: ")"朝向这个exerpt的底部,超过这一点,代码几乎相同。

import os,subprocess
entry = " "           #variable to hold input on the main menu
entry2 = " "          #variable to hold input on the VERVE menu
looping = False       #variable that decides if videos should loop
lastinput = " "       #variable holds last input on the main menu

while entry != "0":

    if entry == "1":
        lastinput = "Camco Chemical Safety Training"
    elif entry =="2":
        lastinput = "[ENG] Forklift Operator Safety Training"
    elif entry =="3":
        lastinput = "[ESP] Forklift Operator Safety Training"
    elif entry =="4":
        lastinput = "[ENG] The New Hazard Communication Mandate"
    elif entry =="5":
        lastinput = "[ESP] The New Hazard Communication Mandate"
    elif entry =="6":
        lastinput = "Forklift Training (1 of 2)"
    elif entry =="7":
        lastinput = "Forklift Training - Accidents (2 of 2)"

        #open main menu
    os.system("printf '\033c'") #These lines are what wipe out the text from the last screen
    if looping == True:
        print("VIDEOS ARE CURRENTLY LOOPING")
    print("Last video watched: " + lastinput)
    print("\n1. Camco Chemical Safety Training")
    print("2. [ENG] Forklift Operator Safety Training")
    print("3. [ESP] Forklift Operator Safety Training")
    print("4. [ENG] The New Hazard Communication Mandate")
    print("5. [ESP] The New Hazard Communication Mandate")
    print("6. Forklift Training (1 of 2)")
    print("7. Forklift Training - Accidents (2 of 2)")
    print("8. VERST DHL")

    print("\n9. TOGGLE VIDEO LOOP")
    print("0. Close Program")

    print("\nPress 0 at any time during a video to close it.")

    entry = input("\nVideo to play: ")
    if entry == "1":
        #open Camco Chemical Safety Training - if looping is off, play once, if it's on, play forever.
        if looping == False:
            subprocess.call(['vlc', "/home/pi/Desktop/Training/Camco_Training/Camco.mp4", '-Idummy --play-and-exit'])
        elif looping == True:
            subprocess.call(['vlc', "/home/pi/Desktop/Training/Camco_Training/Camco.mp4", '-Idummy --loop'])
        continue

1 个答案:

答案 0 :(得分:0)

佩德罗是对的,我能够通过改变我加载它的方式让它运行。它现在运行得很好,我从rc.local中删除它并将其添加到.bashrc

启动rpi到cli

sudo nano /home/pi/.bashrc

最后一行

echo Running at boot
sudo python3 /home/pi/filename.py