Skip to content

Commit

Permalink
make screenshot optional. Call special logbook function from interfac…
Browse files Browse the repository at this point in the history
…e plugin
  • Loading branch information
wyrnat committed Dec 12, 2023
1 parent 164f4e6 commit b5495d4
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/badger/logbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .settings import read_value
from .archive import BADGER_ARCHIVE_ROOT
from .errors import BadgerConfigError, BadgerLogbookError
from .factory import get_intf


# Check badger logbook root
Expand Down Expand Up @@ -89,9 +90,25 @@ def send_to_logbook(routine, data, widget=None):
xmlFile.write(xmlString)
xmlFile.write('\n') # Close with newline so cron job parses correctly
xmlFile.close()
screenshot(widget, f'{fileName}.png')

#TODO either return data or send from here to interface
# make screenshot optional
try:
screenshot(widget, f'{fileName}.png')
except BadgerLogbookError:
logger.warning(f"No Widget available for screenshot")
except ImportError:
logger.warning(f"Cannot save Screenshot. PIL package missing")

# Call customized logbook if interface has a logbook function
try:
intf_name = routine['intf']
intf_logbook = routine['intf_params']['logbook']
if intf_logbook:
intf = get_intf(intf_name)
#TODO: define parameters for to_logbook function
intf.to_logbook()
except KeyError:
logger.warning(f"Interface {intf_name} has no logbook method.")


def screenshot(widget, filename):
Expand Down

0 comments on commit b5495d4

Please sign in to comment.