Blame view

src/majordome/MajordomeDecorators.py 1.62 KB
af5d8b11   Etienne Pallier   Nouveau shell pyr...
1
"""
678838ed   Jeremy   Weather ans insid...
2
    These decorators should only by used for the majordome class (majordome/tasks.py)
af5d8b11   Etienne Pallier   Nouveau shell pyr...
3
4
"""

678838ed   Jeremy   Weather ans insid...
5

ce470283   Jeremy   Plc simulator fin...
6
7
8
9
def acceptedStatus(status):
    def deco(func):
        def tag_decorator(self, *args, **kwargs):
            for i in status:
af5d8b11   Etienne Pallier   Nouveau shell pyr...
10
                if self.current_status == i:
ce470283   Jeremy   Plc simulator fin...
11
12
                    return func(self, *args, **kwargs)
            return -1
af5d8b11   Etienne Pallier   Nouveau shell pyr...
13

ce470283   Jeremy   Plc simulator fin...
14
        return tag_decorator
af5d8b11   Etienne Pallier   Nouveau shell pyr...
15

ce470283   Jeremy   Plc simulator fin...
16
17
    return deco

af5d8b11   Etienne Pallier   Nouveau shell pyr...
18

678838ed   Jeremy   Weather ans insid...
19
20
21
22
23
def executingSequenceExist(func):
    def class_method(self, *args, **kwargs):
        if self.executing_sequence is None:
            return -1
        return func(self, *args, **kwargs)
af5d8b11   Etienne Pallier   Nouveau shell pyr...
24

678838ed   Jeremy   Weather ans insid...
25
26
    return class_method

af5d8b11   Etienne Pallier   Nouveau shell pyr...
27

ce470283   Jeremy   Plc simulator fin...
28
29
30
31
32
33
def executable(func):
    def class_method(self, *args, **kwargs):
        ret = self.isExecutable()
        if ret:
            return ret
        return func(self, *args, **kwargs)
af5d8b11   Etienne Pallier   Nouveau shell pyr...
34

ce470283   Jeremy   Plc simulator fin...
35
36
    return class_method

af5d8b11   Etienne Pallier   Nouveau shell pyr...
37

ce470283   Jeremy   Plc simulator fin...
38
39
40
41
42
43
def weatherCheck(func):
    def class_method(self, *args, **kwargs):
        ret = self.isOutsideOk()
        if ret:
            return ret
        return func(self, *args, **kwargs)
af5d8b11   Etienne Pallier   Nouveau shell pyr...
44

678838ed   Jeremy   Weather ans insid...
45
46
    return class_method

af5d8b11   Etienne Pallier   Nouveau shell pyr...
47

678838ed   Jeremy   Weather ans insid...
48
49
50
51
52
def SameAlarmCheck(func):
    def class_method(self, type, *args, **kwargs):
        if type in self.alarm_list:
            return -1
        return func(self, type, *args, **kwargs)
af5d8b11   Etienne Pallier   Nouveau shell pyr...
53

678838ed   Jeremy   Weather ans insid...
54
    return class_method
ce470283   Jeremy   Plc simulator fin...
55

af5d8b11   Etienne Pallier   Nouveau shell pyr...
56

ce470283   Jeremy   Plc simulator fin...
57
58
59
60
61
62
def devicesCheck(func):
    def class_method(self, *args, **kwargs):
        ret = self.isDevicesOk()
        if ret:
            return ret
        return func(self, *args, **kwargs)
af5d8b11   Etienne Pallier   Nouveau shell pyr...
63

678838ed   Jeremy   Weather ans insid...
64
    return class_method
ce470283   Jeremy   Plc simulator fin...
65

af5d8b11   Etienne Pallier   Nouveau shell pyr...
66

ce470283   Jeremy   Plc simulator fin...
67
68
69
70
71
72
def insideCheck(func):
    def class_method(self, *args, **kwargs):
        ret = self.isInsideOk()
        if ret:
            return ret
        return func(self, *args, **kwargs)
af5d8b11   Etienne Pallier   Nouveau shell pyr...
73
74

    return class_method