How to use the apprise.Apprise function in apprise

To help you get started, we’ve selected a few apprise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github caronc / apprise / test / test_windows_plugin.py View on Github external
obj._on_destroy(0, '', 0, 0)

    # test notifications
    assert obj.notify(
        title='title', body='body',
        notify_type=apprise.NotifyType.INFO) is True

    obj = apprise.Apprise.instantiate(
        'windows://_/?image=True', suppress_exceptions=False)
    obj.duration = 0
    assert isinstance(obj.url(), six.string_types) is True
    assert obj.notify(
        title='title', body='body',
        notify_type=apprise.NotifyType.INFO) is True

    obj = apprise.Apprise.instantiate(
        'windows://_/?image=False', suppress_exceptions=False)
    obj.duration = 0
    assert isinstance(obj.url(), six.string_types) is True
    assert obj.notify(
        title='title', body='body',
        notify_type=apprise.NotifyType.INFO) is True

    obj = apprise.Apprise.instantiate(
        'windows://_/?duration=1', suppress_exceptions=False)
    assert isinstance(obj.url(), six.string_types) is True
    assert obj.notify(
        title='title', body='body',
        notify_type=apprise.NotifyType.INFO) is True
    # loads okay
    assert obj.duration == 1
github caronc / apprise / test / test_gnome_plugin.py View on Github external
mock_pixbuf.new_from_file.return_value = True

    # The following libraries need to be reloaded to prevent
    #  TypeError: super(type, obj): obj must be an instance or subtype of type
    #  This is better explained in this StackOverflow post:
    #     https://stackoverflow.com/questions/31363311/\
    #       any-way-to-manually-fix-operation-of-\
    #          super-after-ipython-reload-avoiding-ty
    #
    reload(sys.modules['apprise.plugins.NotifyGnome'])
    reload(sys.modules['apprise.plugins'])
    reload(sys.modules['apprise.Apprise'])
    reload(sys.modules['apprise'])

    # Create our instance
    obj = apprise.Apprise.instantiate('gnome://', suppress_exceptions=False)
    obj.duration = 0

    # Check that it found our mocked environments
    assert obj._enabled is True

    # Test url() call
    assert isinstance(obj.url(), six.string_types) is True

    # test notifications
    assert obj.notify(title='title', body='body',
                      notify_type=apprise.NotifyType.INFO) is True

    # test notification without a title
    assert obj.notify(title='', body='body',
                      notify_type=apprise.NotifyType.INFO) is True
github caronc / apprise / test / test_rest_plugins.py View on Github external
"# Heading 3 ##\n\n\n" + \
        "normal content\n" + \
        "# heading 4\n" + \
        "#### Heading 5"

    results = obj.extract_markdown_sections(test_markdown)
    assert isinstance(results, list) is True
    # We should have 5 sections (since there are 5 headers identified above)
    assert len(results) == 5

    # Use our test markdown string during a notification
    assert obj.notify(
        body=test_markdown, title='title', notify_type=NotifyType.INFO) is True

    # Create an apprise instance
    a = Apprise()

    # Our processing is slightly different when we aren't using markdown
    # as we do not pre-parse content during our notifications
    assert a.add(
        'discord://{webhook_id}/{webhook_token}/'
        '?format=markdown&footer=Yes'.format(
            webhook_id=webhook_id,
            webhook_token=webhook_token)) is True

    # This call includes an image with it's payload:
    assert a.notify(body=test_markdown, title='title',
                    notify_type=NotifyType.INFO,
                    body_format=NotifyFormat.TEXT) is True

    assert a.notify(body=test_markdown, title='title',
                    notify_type=NotifyType.INFO,
github daghaian / nzbthrottle / notification.py View on Github external
def __init__(self):
        self._logger = logging.getLogger()
        try:
            with open("./config.json") as w:
                self._logger.debug("Loading Notification Data from config.json")
                cfg = json.load(w)
                self._logger.debug("Notification Data loaded successfully" + str(cfg))
                self._notifier = apprise.Apprise(asset=apprise.AppriseAsset(
                    image_url_mask="https://avatars3.githubusercontent.com/u/3368377?s=200&v=4",
                    default_extension=".jpeg"))
                for k,v in cfg['notifications'].items():
                    if(v['enabled'] == True):
                        self._notifier.add(v['url'])
        except Exception as e:
            self._logger.exception("Problem encountered when creating Notification object")
            sys.exit(1)
github BlameButton / disrupt / main.py View on Github external
"""
    Loops over all the Swarm services, checking if they need updates.

    :raises Exception when Docker Engine is not in Swarm Mode
    """
    update_delay = getenv('UPDATE_DELAY', '300')
    notification_url = getenv('NOTIFICATION_URL', '')

    try:
        client = docker.from_env()
    except ConnectionError:
        logger.error('Could not connect to Docker Engine. Check https://git.io/fjvRd for possible solutions')
        return

    logger.info('Started checking for updates')
    apprise = Apprise()
    if len(notification_url) > 0:
        # Add notification provider from URL if provided
        apprise.add(notification_url)

    if not is_swarm_manager(client):
        raise Exception('Docker Engine is not in Swarm Mode')
    while True:
        update_services(client, apprise)
        time.sleep(float(update_delay))
github gpulido / SwarmAlert / src / swarm-alert.py View on Github external
#Configure logging
    logger = configure_logger(l.loglevel.upper())
    
    logger.info("Initializing monitor")

    check_interval = l.check_interval
    white_pattern_list = get_list_from_params(l.whitelist)
    logger.debug("Whitelist: " + str(white_pattern_list))
    
    black_list = get_list_from_params(l.blacklist) 
    logger.debug("BlackList: " + str(black_list))
   
    msg_prefix =  sanitize_str_arg(l.msg_prefix)
        
    logger.info("Registering Apprise service")
    apobj = apprise.Apprise()
    config = apprise.AppriseConfig()
    if not config.add('/src/config.yml'):
         print("Warning: Please provide a valid apprise configuration.")   
    
    apobj.add(config)
    apobj.notify(body='Initializing monitoring',
                 title='SwarmAlert' ) 
    logger.info("Registering Docker Client")

    docker_client = docker.DockerClient(base_url='unix://var/run/docker.sock')
    monitor_and_notify(docker_client, apobj)
github morpheus65535 / bazarr / bazarr / notifier.py View on Github external
def send_notifications(sonarrSeriesId, sonarrEpisodeId, message):
    providers = get_notifier_providers()
    series = get_series_name(sonarrSeriesId)
    episode = get_episode_name(sonarrEpisodeId)
    
    apobj = apprise.Apprise()
    
    for provider in providers:
        if provider.url is not None:
            apobj.add(provider.url)
    
    apobj.notify(
        title='Bazarr notification',
        body=(series + ' - S' + str(episode[1]).zfill(2) + 'E' + str(episode[2]).zfill(2) + ' - ' + episode[0] + ' : ' + message),
    )
github dockupdater / dockupdater / pyouroboros / notifiers.py View on Github external
def build_apprise(self):
        asset = apprise.AppriseAsset(
            image_url_mask='https://bin.cajun.pro/images/ouroboros/notifications/ouroboros-logo-{XY}{EXTENSION}',
            default_extension='.png'
        )
        asset.app_id = "Ouroboros"
        asset.app_desc = "Ouroboros"
        asset.app_url = "https://github.com/pyouroboros/ouroboros"
        asset.html_notify_map['info'] = '#5F87C6'
        asset.image_url_logo = 'https://bin.cajun.pro/images/ouroboros/notifications/ouroboros-logo-256x256.png'

        apprise_obj = apprise.Apprise(asset=asset)

        for notifier in self.config.notifiers:
            add = apprise_obj.add(notifier)
            if not add:
                self.logger.error('Could not add notifier %s', notifier)

        return apprise_obj