Debian Codegraph @

Nagstamon/qui/constants.py

raw
1 # Nagstamon - Nagios status monitor for your desktop
2 # Copyright (C) 2008-2026 Henri Wahl <[email protected]> et al.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17
18 # Constants for Qt
19
20 from collections import OrderedDict
21 from os import sep
22 from platform import system
23
24 from Nagstamon.config import (AppInfo,
25 RESOURCES)
26 from Nagstamon.qui.qt import (QIcon,
27 Qt)
28
29 # fixed shortened and lowered color names for cells, also used by statusbar label snippets
30 COLORS = OrderedDict([('DOWN', 'color_down_'),
31 ('UNREACHABLE', 'color_unreachable_'),
32 ('DISASTER', 'color_disaster_'),
33 ('CRITICAL', 'color_critical_'),
34 ('HIGH', 'color_high_'),
35 ('AVERAGE', 'color_average_'),
36 ('WARNING', 'color_warning_'),
37 ('INFORMATION', 'color_information_'),
38 ('UNKNOWN', 'color_unknown_')])
39
40 # states to be used in statusbar if the long version is used
41 COLOR_STATE_NAMES = {'DOWN': {True: 'DOWN', False: ''},
42 'UNREACHABLE': {True: 'UNREACHABLE', False: ''},
43 'DISASTER': {True: 'DISASTER', False: ''},
44 'CRITICAL': {True: 'CRITICAL', False: ''},
45 'HIGH': {True: 'HIGH', False: ''},
46 'AVERAGE': {True: 'AVERAGE', False: ''},
47 'WARNING': {True: 'WARNING', False: ''},
48 'INFORMATION': {True: 'INFORMATION', False: ''},
49 'UNKNOWN': {True: 'UNKNOWN', False: ''}}
50
51 # colors for server status label in ServerVBox
52 COLOR_STATUS_LABEL = {'critical': 'lightsalmon',
53 'error': 'orange',
54 'unknown': 'gray'}
55
56 # headers for tablewidgets
57 HEADERS = OrderedDict([('host', {'header': 'Host',
58 'column': 0}),
59 ('host_flags', {'header': '',
60 'column': 0}),
61 ('service', {'header': 'Service',
62 'column': 2}),
63 ('service_flags', {'header': '',
64 'column': 2}),
65 ('status', {'header': 'Status',
66 'column': 4}),
67 ('last_check', {'header': 'Last Check',
68 'column': 5}),
69 ('duration', {'header': 'Duration',
70 'column': 6}),
71 ('attempt', {'header': 'Attempt',
72 'column': 7}),
73 ('status_information', {'header': 'Status Information',
74 'column': 8}),
75 ('dummy_column', {'header': '',
76 'column': 8})])
77
78 # various headers-key-columns variations needed in different parts
79 HEADERS_HEADERS = list()
80 for item in HEADERS.values():
81 HEADERS_HEADERS.append(item['header'])
82
83 HEADERS_HEADERS_COLUMNS = dict()
84 for item in HEADERS.values():
85 HEADERS_HEADERS_COLUMNS[item['header']] = item['column']
86
87 HEADERS_HEADERS_KEYS = dict()
88 for item in HEADERS.keys():
89 HEADERS_HEADERS_KEYS[HEADERS[item]['header']] = item
90
91 HEADERS_KEYS_COLUMNS = dict()
92 for item in HEADERS.keys():
93 HEADERS_KEYS_COLUMNS[item] = HEADERS[item]['column']
94
95 HEADERS_KEYS_HEADERS = dict()
96 for item in HEADERS.keys():
97 HEADERS_KEYS_HEADERS[item] = HEADERS[item]['header']
98
99 # sorting order for tablewidgets
100 SORT_ORDER = {'descending': 1, 'ascending': 0, 0: Qt.SortOrder.DescendingOrder, 1: Qt.SortOrder.AscendingOrder}
101
102 # bend columns 1 and 3 to 0 and 2 to avoid sorting the extra flag icons of hosts and services
103 SORT_COLUMNS_INDEX = {0: 0,
104 1: 0,
105 2: 2,
106 3: 2,
107 4: 4,
108 5: 5,
109 6: 6,
110 7: 7,
111 8: 8,
112 9: 8}
113
114 # space used in LayoutBoxes
115 SPACE = 10
116
117 # Flags for statusbar - experiment with Qt.ToolTip for Windows because
118 # statusbar permanently seems to vanish at some users desktops
119 # see https://github.com/HenriWahl/Nagstamon/issues/222
120 WINDOW_FLAGS = Qt.WindowType.WindowStaysOnTopHint | Qt.WindowType.FramelessWindowHint | Qt.WindowType.Tool
121
122 # icon for dialogs
123 ICON = QIcon(f'{RESOURCES}{sep}nagstamon.ico')