1
Pibrella의 버튼을 누르면 10 초마다 전자 메일을 보내는 스크립트를 작성하고 있습니다. 버튼을 다시 누르면 멈추고 싶습니다.Pibrella + RPI 스레딩 중지
예를 들어 처음 누르면 10 초마다 이메일이 전송됩니다. 그런 다음 두 번째로 스레드를 중지합니다.
여기 내 현재 코드입니다. 누군가 내가 잘못하고있는 부분을 말해 줄 수 있습니까?
import pibrella, signal
import threading
import time
import smtplib
server = smtplib.SMTP("smtp.gmail.com",587)
server.ehlo()
server.starttls()
server.ehlo()
server.login("[email protected]", "EmailPassword")
isPressed = 0
def pressed(pin):
global isPressed
if isPressed == 0:
isPressed = 1
sendMail()
else:
pibrella.light.off()
t.cancel()
isPressed = 0
def sendMail():
pibrella.light.pulse()
server.sendmail("[email protected]", "[email protected]", "Hello World")
t.start()
t = threading.Timer(10, sendMail).start()
pibrella.button.pressed(pressed)
pibrella.pause()
server.close()
지금보고있는 오류는 아래에 게시됩니다. 전자 메일이 실제로 전송되고 있음에 유의하십시오. (내 Github에서에서) 이메일을 보내기위한
이Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pibrella.py", line 262, in handle_callback
callback(self)
File "sendText.py", line 27, in pressed
sendMail()
File "sendText.py", line 36, in sendMail
t.start()
AttributeError: 'NoneType' object has no attribute 'start'
Exception in thread Thread-14:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 760, in run
self.function(*self.args, **self.kwargs)
File "sendText.py", line 36, in sendMail
t.start()
AttributeError: 'NoneType' object has no attribute 'start'
당신이 당신의 현재 코드가 수행하고 당신이 그것을 실패 생각하는 이유 사항을 알려주십시오 수 있습니까? –
오류 메시지와 함께 업데이트되었습니다. – user130622