小编ADT*_*ank的帖子

Raspberry Pi自动登录没有etc/inittab

我想将我的Raspberry Pi设置为在特定用户中自动登录.我搜索了这个,我发现的解决方案是关于编辑/ etc/inittab文件.我的问题是现在我没有那个文件,它似乎在我的Raspbian版本中丢失了.还有另一种方法吗?

raspberry-pi raspbian

8
推荐指数
2
解决办法
2万
查看次数

如何使用def函数进行无限循环?

我编写了一个程序,每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)

python function infinite-loop

0
推荐指数
2
解决办法
810
查看次数

标签 统计

function ×1

infinite-loop ×1

python ×1

raspberry-pi ×1

raspbian ×1