1
python脚本仅为自刷新的npyscreen(curses)脚本每1分钟显示一次状态。用户点击ctrl-c后,应该注销。登录到Raspbian +在python脚本结束时运行python脚本+注销
python脚本仅为自刷新的npyscreen(curses)脚本每1分钟显示一次状态。用户点击ctrl-c后,应该注销。登录到Raspbian +在python脚本结束时运行python脚本+注销
import os
import subprocess
def logoff():
ppid = os.environ['PPID']
subprocess.call(["kill", "-HUP", ppid])
你必须抓住KeyboardInterrupt
例外:
def main():
try:
display_status()
except KeyboardInterrupt:
logoff()
def display_status():
pass # your code goes here
if __name__ == '__main__':
main()
你如何登录?直接在Pi或通过_ssh_? – Finwood