MajordomeDecorators.py
1.62 KB
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
73
74
"""
These decorators should only by used for the majordome class (majordome/tasks.py)
"""
def acceptedStatus(status):
def deco(func):
def tag_decorator(self, *args, **kwargs):
for i in status:
if self.current_status == i:
return func(self, *args, **kwargs)
return -1
return tag_decorator
return deco
def executingSequenceExist(func):
def class_method(self, *args, **kwargs):
if self.executing_sequence is None:
return -1
return func(self, *args, **kwargs)
return class_method
def executable(func):
def class_method(self, *args, **kwargs):
ret = self.isExecutable()
if ret:
return ret
return func(self, *args, **kwargs)
return class_method
def weatherCheck(func):
def class_method(self, *args, **kwargs):
ret = self.isOutsideOk()
if ret:
return ret
return func(self, *args, **kwargs)
return class_method
def SameAlarmCheck(func):
def class_method(self, type, *args, **kwargs):
if type in self.alarm_list:
return -1
return func(self, type, *args, **kwargs)
return class_method
def devicesCheck(func):
def class_method(self, *args, **kwargs):
ret = self.isDevicesOk()
if ret:
return ret
return func(self, *args, **kwargs)
return class_method
def insideCheck(func):
def class_method(self, *args, **kwargs):
ret = self.isInsideOk()
if ret:
return ret
return func(self, *args, **kwargs)
return class_method