我尝试使用服务器上的PHP文件将一些变量传输到Python脚本中,而Python脚本将在我的Raspberry Pi上启动一个raspistill时间流逝。
到目前为止,我已经设法开始拍照了,但我现在想有一个按钮来消除时间流逝-我尝试了许多方法,包括.kill()和.terminate(),但都不能正常工作。
下面是我当前的python代码:
import sys, os, time, datetime
import subprocess
import signal
from time import sleep
tlfreq = int(sys.argv[1])
tltime = int(sys.argv[2])
dir = '/var/www/timelapse/' + sys.argv[3]
if not os.path.exists(dir):
os.makedirs(dir)
cmd = ('raspistill -t ' + str(tltime) + " -tl " + str(tlfreq) + " -o " + dir + "/photo_%04d.jpg")
pro = subprocess.Popen(cmd, stdout=subprocess.PIPE,
shell=True, preexec_fn=os.setsid)
print "Pictures are now being taken every" , tlfreq/1000 , "second/s for a total of", tltime/3600000 , "hours. These are being stored in", dir也许我需要一个"if variable =1则kill“命令,然后将变量发送到python。
任何帮助都将不胜感激!
非常感谢,丹
发布于 2014-04-22 22:21:30
您可以使用以下代码创建新的python脚本kill_raspystill.py
import os
os.system("pkill raspistill")并在按下按钮时调用该脚本。
发布于 2013-09-16 18:38:33
我建议使用信号库:http://docs.python.org/2/library/signal.html
https://stackoverflow.com/questions/18825899
复制相似问题