Search icons and fonts near the script
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
62fc7eb2f0
commit
1cae3824b2
5 changed files with 32 additions and 20 deletions
|
|
@ -1,12 +1,16 @@
|
|||
import os
|
||||
import os.path
|
||||
import logging
|
||||
from tempfile import NamedTemporaryFile
|
||||
import sys
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
class Config:
|
||||
|
||||
def __init__(self, cache_timeout, max_cache_timeout, cals_file_list=".cals"):
|
||||
self.icons_dir = os.path.join(os.path.dirname(sys.argv[0]), "icons")
|
||||
self.fonts_dir = os.path.join(os.path.dirname(sys.argv[0]), "fonts")
|
||||
self.cache_timeout = cache_timeout
|
||||
self.max_cache_timeout = max_cache_timeout
|
||||
|
||||
|
|
@ -94,7 +98,8 @@ class RuleModule:
|
|||
|
||||
class AlertsModule:
|
||||
|
||||
def __init__(self, alerts=[], ignore_module=[]):
|
||||
def __init__(self, config, alerts=[], ignore_module=[]):
|
||||
self._config = config
|
||||
self.icon_size = 50
|
||||
self.alerts = alerts
|
||||
self.ignore_module = ignore_module
|
||||
|
|
@ -106,7 +111,7 @@ class AlertsModule:
|
|||
image.paste(icon_img, (int(self.icon_size / 2 - font_size*self.icon_size/32), align))
|
||||
else:
|
||||
color_img = Image.new('RGB', (self.icon_size, self.icon_size), "#fff")
|
||||
icon_img = Image.open("icons/" + alert["icon"]).resize((self.icon_size, self.icon_size))
|
||||
icon_img = Image.open(os.path.join(self._config.icons_dir, alert["icon"])).resize((self.icon_size, self.icon_size))
|
||||
image.paste(color_img, (0, align - 5), icon_img)
|
||||
|
||||
if "title" in alert:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue