4
4
This module is used for setting alerts on blocks.
5
5
"""
6
6
7
- from __future__ import absolute_import , print_function
8
-
9
7
from genie_python .genie_api_setup import (
10
8
__api ,
11
9
helparglist ,
25
23
26
24
27
25
@usercommand
28
- @helparglist ("block, lowlimit, highlimit, [delay_in, delay_out]" )
26
+ @helparglist ("block, lowlimit, highlimit, [set_enable, delay_in, delay_out]" )
29
27
@log_command_and_handle_exception
30
- def set_range (block , lowlimit , highlimit , set_enable = True , delay_in = None , delay_out = None ):
28
+ def set_range (
29
+ block : str ,
30
+ lowlimit : float ,
31
+ highlimit : float ,
32
+ set_enable : bool = True ,
33
+ delay_in : float | None = None ,
34
+ delay_out : float | None = None ,
35
+ ) -> None :
31
36
"""
32
37
Sets alert range on block.
33
38
@@ -36,8 +41,10 @@ def set_range(block, lowlimit, highlimit, set_enable=True, delay_in=None, delay_
36
41
lowlimit (float): low limit
37
42
highlimit (float): high limit
38
43
set_enable (bool): (optional setting True will enable alerts on the block. Defaults to True.
39
- delay_in (float): (optional) delay /s before triggering in range. If not specified the delay remains unchanged.
40
- delay_out (float): (optional) delay /s before triggering out of range. If not specified the delay remains unchanged.
44
+ delay_in (float): (optional) delay /s before triggering in range. If not specified the delay
45
+ remains unchanged.
46
+ delay_out (float): (optional) delay /s before triggering out of range.
47
+ If not specified the delay remains unchanged.
41
48
42
49
"""
43
50
if not __api .block_exists (block ):
@@ -56,7 +63,7 @@ def set_range(block, lowlimit, highlimit, set_enable=True, delay_in=None, delay_
56
63
@usercommand
57
64
@helparglist ("block [, is_enabled]" )
58
65
@log_command_and_handle_exception
59
- def enable (block , set_enabled = True ):
66
+ def enable (block : str , set_enabled : bool = True ) -> None :
60
67
"""
61
68
Enable alerts on a block.
62
69
@@ -73,7 +80,7 @@ def enable(block, set_enabled=True):
73
80
@usercommand
74
81
@helparglist ("message" )
75
82
@log_command_and_handle_exception
76
- def send (message ) :
83
+ def send (message : str ) -> None :
77
84
"""
78
85
Send a message to all alert recipients.
79
86
@@ -87,7 +94,7 @@ def send(message):
87
94
## no log decorator so mobile numbers not sent to log file
88
95
@usercommand
89
96
@helparglist ("numbers" )
90
- def set_sms (numbers ) :
97
+ def set_sms (numbers : list [ str ] | str ) -> None :
91
98
"""
92
99
Set SMS text numbers for alerts on blocks.
93
100
@@ -107,7 +114,7 @@ def set_sms(numbers):
107
114
## no log decorator so email addresses not sent to log file
108
115
@usercommand
109
116
@helparglist ("emails" )
110
- def set_email (emails ) :
117
+ def set_email (emails : list [ str ] | str ) -> None :
111
118
"""
112
119
Set email addresses for alerts on blocks.
113
120
@@ -124,7 +131,7 @@ def set_email(emails):
124
131
print ("Unable to set alert email addresses: {}" .format (e ))
125
132
126
133
127
- def _print_block (block , only_if_enabled = False ):
134
+ def _print_block (block : str , only_if_enabled : bool = False ) -> None :
128
135
enabled = (
129
136
__api .get_pv_value (_ALERT_ENABLE .format (block ), to_string = True , is_local = True ) == "YES"
130
137
)
@@ -157,7 +164,7 @@ def _print_block(block, only_if_enabled=False):
157
164
@usercommand
158
165
@helparglist ("[block, all]" )
159
166
@log_command_and_handle_exception
160
- def status (block = None , all = False ):
167
+ def status (block : str | None = None , all : bool = False ) -> None :
161
168
"""
162
169
Prints the emails and mobiles used for alerts and the current status of specified block.
163
170
Args:
@@ -177,12 +184,14 @@ def status(block=None, all=False):
177
184
178
185
179
186
# used as part of tests, returns a dictionary of details
180
- def _dump (block ) :
187
+ def _dump (block : str ) -> dict [ str , str ] :
181
188
if not __api .block_exists (block ):
182
189
raise Exception ('No block with the name "{}" exists' .format (block ))
183
190
res = {}
184
- res ["emails" ] = __api .get_pv_value (_ALERT_EMAILS , to_string = True , is_local = True ).split (";" )
185
- res ["mobiles" ] = __api .get_pv_value (_ALERT_MOBILES , to_string = True , is_local = True ).split (";" )
191
+ res ["emails" ] = str (__api .get_pv_value (_ALERT_EMAILS , to_string = True , is_local = True )).split (";" )
192
+ res ["mobiles" ] = str (__api .get_pv_value (_ALERT_MOBILES , to_string = True , is_local = True )).split (
193
+ ";"
194
+ )
186
195
res ["enabled" ] = __api .get_pv_value (_ALERT_ENABLE .format (block ), to_string = False , is_local = True )
187
196
res ["lowlimit" ] = __api .get_pv_value (_ALERT_LOW .format (block ), to_string = False , is_local = True )
188
197
res ["highlimit" ] = __api .get_pv_value (_ALERT_HIGH .format (block ), to_string = False , is_local = True )
0 commit comments