-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalarm_dummy.py
executable file
·73 lines (59 loc) · 1.48 KB
/
alarm_dummy.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
66
67
68
69
70
71
72
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import Pyro4
import time
class alarm(object):
def __init__(self):
self._set = False
self._playing = False
self._snoozing = False
self._counter = 0
self._time = None
def reset(self):
self.__init__()
@Pyro4.expose
@property
def set(self):
return self._set
@Pyro4.expose
@property
def playing(self):
return self._playing
@Pyro4.expose
@property
def snoozing(self):
return self._snoozing
@Pyro4.expose
@property
def counter(self):
return self._counter
@Pyro4.expose
@property
def time(self):
return self._time
def snooze(self):
self._snooze = True
self._counter += 1
def play(self):
self._playing = True
def stop(self):
self._playing = False
self._snoozing = False
self._counter = 0
def set_time(self, settime):
self._set = True
self._time = [int(i) for i in settime.split(':')]
print 'waking at %s:%s'%(self.time[0],self.time[1])
def check_alarm(self):
if self._set:
return self.time == [time.localtime().tm_hour,time.localtime().tm_min]
else:
return False
daemon = Pyro4.Daemon(host='muffin')
ns = Pyro4.locateNS()
uri = daemon.register(alarm())
ns.register("alarm", uri)
print("server object uri:", uri)
print("attributes server running.")
daemon.requestLoop()