def send_failure_alert_pushover(printer, rotated_jpg_url, is_warning,
                                print_paused):
    if not printer.user.pushover_user_token:
        return

    try:
        photo = requests.get(rotated_jpg_url).content
    except:
        photo = None

    pausing_msg = ''
    if print_paused:
        pausing_msg = 'Printer is paused.'
    elif printer.action_on_failure == Printer.PAUSE and is_warning:
        pausing_msg = 'Printer is NOT paused because The Detective is not very sure about it.'

    title = 'The Spaghetti Detective - Failure alert!'

    msg = 'Your print {} on {} {}.'.format(
        printer.current_print.filename or '', printer.name,
        'smells fishy' if is_warning else 'is probably failing')
    link = site.build_full_url('/')
    body = '{}\n{}\nGo check it at: {}'.format(msg, pausing_msg, link)
    priority = PushoverPriority.HIGH

    try:
        pushover_notification(printer.user.pushover_user_token, body, title,
                              photo, priority)
    except (PushoverException) as e:
        LOGGER.error(e)
def send_print_notification_pushover(_print):
    printer = _print.printer
    if not printer.user.pushover_user_token:
        return

    try:
        photo = requests.get(_print.poster_url).content
    except:
        photo = None

    title = 'The Spaghetti Detective - Print job notification'
    body = f"Your print job {_print.filename} {'has been canceled' if _print.is_canceled() else 'is done'} on printer {_print.printer.name}."

    try:
        pushover_notification(printer.user.pushover_user_token, body, title,
                              photo)
    except (PushoverException) as e:
        LOGGER.error(e)
def send_print_notification_pushover(_print, event_type=None):
    printer = _print.printer
    if not printer.user.pushover_user_token:
        return

    try:
        photo = requests.get(_print.poster_url).content
    except:
        photo = None

    title = 'The Spaghetti Detective - Print job notification'
    body = get_notification_body(_print, event_type=event_type)

    try:
        pushover_notification(printer.user.pushover_user_token, body, title,
                              photo)
    except (PushoverException) as e:
        LOGGER.error(e)