Blame view

src/majordome/MajordomeDecorators.py 1.61 KB
678838ed   Jeremy   Weather ans insid...
1
2
3
4
'''
    These decorators should only by used for the majordome class (majordome/tasks.py)
'''

ce470283   Jeremy   Plc simulator fin...
5
6
7
8
9
10
11
12
13
14
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

678838ed   Jeremy   Weather ans insid...
15
16
17
18
19
20
21
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

ce470283   Jeremy   Plc simulator fin...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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)
678838ed   Jeremy   Weather ans insid...
36
37
38
39
40
41
42
43
    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
ce470283   Jeremy   Plc simulator fin...
44
45
46
47
48
49
50

def devicesCheck(func):
    def class_method(self, *args, **kwargs):
        ret = self.isDevicesOk()
        if ret:
            return ret
        return func(self, *args, **kwargs)
678838ed   Jeremy   Weather ans insid...
51
    return class_method
ce470283   Jeremy   Plc simulator fin...
52
53
54
55
56
57
58

def insideCheck(func):
    def class_method(self, *args, **kwargs):
        ret = self.isInsideOk()
        if ret:
            return ret
        return func(self, *args, **kwargs)
678838ed   Jeremy   Weather ans insid...
59
    return class_method