我想将我的Raspberry Pi设置为在特定用户中自动登录.我搜索了这个,我发现的解决方案是关于编辑/ etc/inittab文件.我的问题是现在我没有那个文件,它似乎在我的Raspbian版本中丢失了.还有另一种方法吗?
我编写了一个程序,每5秒检查一个日志文件以获取一个特定的单词.当它发现该字时会产生一些噪音并覆盖日志文件.我得到的问题是:
RuntimeError:调用Python对象时超出了最大递归深度.
有没有更好的方法来制作这个循环?
import time
import subprocess
global playalarm
def alarm():
if "No answer" in open("/var/log/hostmonitor.log").read():
print "Alarm!"
playalarm=subprocess.Popen(['omxplayer','/root/Alarm/alarm.mp3'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,close_fds=True)
log = open("/var/log/hostmonitor.log","w")
log.write("Checked")
log.close()
time.sleep(5)
playalarm.stdin.write('q')
alarm()
else:
print"Checked"
time.sleep(5)
alarm()
alarm()
Run Code Online (Sandbox Code Playgroud)