-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathRinger.py
65 lines (52 loc) · 2.04 KB
/
Ringer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from subprocess import call
from datetime import datetime
from time import sleep
import picamera
import os
from send_email_attachment import sendmail
from tweet import tweet
from shutil import copyfile
# from constants import _const
class Ringer(object):
def __init__(self):
try:
self.camera = picamera.PiCamera()
self.camera.resolution = (1024, 768)
except:
print('Something went horribly wrong. I lost my camera and can''t start it again without rebooting. So I will now reboot within 5 seconds.')
sleep(5)
# os.system('sudo shutdown -r now')
def __del__(self):
self.camera.close()
def respond(self):
datetimestamp = datetime.now().isoformat()
newfile = '/home/pi/camera/images/visitor%s.jpg' % datetimestamp
self.camera.capture(newfile)
self.camera.close()
# and copy the new image to the most recent snapshot to show on our inhouse-answering-devices
MOSTRECENTSNAPSHOT = '/home/pi/camera/images/mostrecent.jpg'
copyfile(newfile, MOSTRECENTSNAPSHOT)
class FamilyOrFriend(Ringer):
def respond(self):
super(FamilyOrFriend, self).respond() # Works fine
mp3sound = "sounds/beep-01.mp3" # Works fine
call(["omxplayer",mp3sound, "-o", "local"]) # Works fine
sendmail() # Works fine.
tweet() # Works fine.
# Todo2 make this work, Ekiga.net (and Twinkle) and the phone-app of linphone
os.system("./call.sh") # does not work. Fails to connect to the phone
class Salesman(Ringer):
def respond(self):
super(Salesman, self).respond()
print("bugger off!!")
sleep(1)
class Deliverer(Ringer):
def respond(self):
super(Deliverer, self).respond()
mp3sound = "sounds/beep-03.mp3"
call(["omxplayer",mp3sound, "-o", "local"])
class HansOrGrietje(Ringer):
def respond(self):
super(HansOrGrietje, self).respond()
mp3sound = "sounds/knibbelknabbelknuisje.amr"
call(["omxplayer",mp3sound, "-o", "local"])