【发布时间】:2017-10-25 09:22:04
【问题描述】:
我正在尝试设置一个非常简单的脚本来处理通过 vlc 在树莓派 3 模型 B 上播放培训视频。
我可以启动到 CLI 并正常运行程序,但是如果我将它添加到 rc.local,我会在第 60 行收到错误,EOFError: EOF when reading a line 谁能帮我解决这个问题?
第 60 行是"entry = input("\nVideo to play: ")",在这段摘录的底部,除此之外,代码几乎相同。
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
【问题讨论】:
-
该错误似乎与python脚本无关,而是与rc.local有关,请检查那里的语法。