]>
git.ipfire.org Git - oddments/collecty.git/blob - src/collecty/colours.py
2 ###############################################################################
4 # collecty - A system statistics collection daemon for IPFire #
5 # Copyright (C) 2015 IPFire development team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 def _add(colour
, amount
):
24 Adds some value to colours
27 bytes
= bytearray
.fromhex(colour
.lstrip("#"))
29 if not len(bytes
) == 3:
30 raise ValueError("Invalid colour: %s" % colour
)
35 byte
= round(byte
* amount
)
37 # Ensure the result is within range
44 return "#%s" % ret
.hex()
46 def lighten(colour
, scale
=0.25):
48 Takes a hexadecimal colour code
49 and brightens the colour.
51 return _add(colour
, scale
)
53 def darken(colour
, scale
=0.25):
55 Takes a hexadecimal colour code
56 and darkens the colour.
58 return _add(colour
, -scale
)
60 def transparency(colour
, scale
=0.1):
62 Adds transparency to the given colour code
64 return "%s%02X" % (colour
, round(0xff * scale
))
69 LIGHT_GREY
= "#F5F5F5"
74 LIGHT_YELLOW
= "#FFFF66"
76 LIGHT_GREEN
= "#8BC34A"
78 LIGHT_BLUE
= "#03A9F4"
86 DEEP_ORANGE
= "#FF5722"
89 DEEP_PURPLE
= "#673AB7"
92 COLOUR_OK
= LIGHT_GREEN
93 COLOUR_CRITICAL
= LIGHT_RED
94 COLOUR_ERROR
= COLOUR_CRITICAL
95 COLOUR_WARN
= LIGHT_YELLOW
96 COLOUR_TEXT
= lighten(BLACK
, 0.87) # 87% grey
101 # Lighten the areas by this factor
103 STDDEV_OPACITY
= 0.33
105 # Receive and transmit
116 COLOUR_IPVX
= GREY
# other
122 COLOUR_UDPLITE
= DEEP_ORANGE
123 COLOUR_SCTP
= LIGHT_GREEN
124 COLOUR_DCCP
= LIGHT_BLUE
125 COLOUR_OTHER
= COLOUR_IPVX
128 CPU_USER
= LIGHT_GREEN
131 CPU_WAIT
= DEEP_PURPLE
134 CPU_STEAL
= LIGHT_BLUE
136 CPU_GUEST_NICE
= lighten(PINK
, 0.8)
137 CPU_IDLE
= LIGHT_GREY
141 MEMORY_BUFFERED
= BLUE
142 MEMORY_CACHED
= YELLOW
144 MEMORY_FREE
= LIGHT_GREY
146 COLOURS_PROTOCOL_STATES
= {
153 "CLOSE_WAIT" : lighten(BLACK
, 0.25),
154 "ESTABLISHED" : LIGHT_GREEN
,
162 "CLOSEREQ" : lighten(BLACK
, 0.5),
163 "CLOSING" : lighten(BLACK
, 0.25),
166 "OPEN" : LIGHT_GREEN
,
173 "COOKIE_ECHOED" : AMBER
,
174 "COOKIE_WAIT" : CYAN
,
175 "SHUTDOWN_ACK_SENT" : TEAL
,
176 "SHUTDOWN_RECD" : PURPLE
,
177 "SHUTDOWN_SENT" : LIGHT_BLUE
,