Notification screenshot option should only be available to webdriver/playwright watches, screenshot sent as JPEG to save bandwidth, Simplify the logic around screenshot, (#1140)

This commit is contained in:
dgtlmoon
2022-11-20 14:40:41 +01:00
committed by GitHub
parent d07d7a1b18
commit 35d44c8277
9 changed files with 64 additions and 14 deletions

View File

@@ -248,7 +248,28 @@ class model(dict):
if os.path.isfile(fname):
return fname
return False
# False is not an option for AppRise, must be type None
return None
def get_screenshot_as_jpeg(self):
"""Best used in notifications due to its smaller size"""
png_fname = os.path.join(self.watch_data_dir, "last-screenshot.png")
jpg_fname = os.path.join(self.watch_data_dir, "last-screenshot.jpg")
if os.path.isfile(jpg_fname):
return jpg_fname
if os.path.isfile(png_fname) and not os.path.isfile(jpg_fname):
# Doesnt exist, so create the JPEG from the PNG
from PIL import Image
im1 = Image.open(png_fname)
im1.convert('RGB').save(jpg_fname, quality=int(os.getenv("NOTIFICATION_SCREENSHOT_JPG_QUALITY", 75)))
return jpg_fname
# False is not an option for AppRise, must be type None
return None
def __get_file_ctime(self, filename):
fname = os.path.join(self.watch_data_dir, filename)