当前位置: 首页>>代码示例>>Python>>正文


Python apprise.Apprise方法代码示例

本文整理汇总了Python中apprise.Apprise方法的典型用法代码示例。如果您正苦于以下问题:Python apprise.Apprise方法的具体用法?Python apprise.Apprise怎么用?Python apprise.Apprise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在apprise的用法示例。


在下文中一共展示了apprise.Apprise方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def send(self, **kwargs):
        if not self.url:
            log.error("You must specify a URL when initializing this class")
            return False

        # send notification
        try:
            apobj = apprise.Apprise()
            apobj.add(self.url)
            apobj.notify(
                title=self.title,
                body=kwargs['message'],
            )

        except Exception:
            log.exception("Error sending notification to %r", self.url)
        return False 
开发者ID:l3uddz,项目名称:traktarr,代码行数:19,代码来源:apprise.py

示例2: test_object_parsing

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def test_object_parsing():
    """
    API: NotifySNS Plugin() Object Parsing

    """

    # Create our object
    a = Apprise()

    # Now test failing variations of our URL
    assert a.add('sns://') is False
    assert a.add('sns://nosecret') is False
    assert a.add('sns://nosecret/noregion/') is False

    # This is valid but without valid recipients, the URL is actually useless
    assert a.add('sns://norecipient/norecipient/us-west-2') is False
    assert len(a) == 0

    # Parse a good one
    assert a.add('sns://oh/yeah/us-west-2/abcdtopic/+12223334444') is True
    assert len(a) == 1

    assert a.add('sns://oh/yeah/us-west-2/12223334444') is True
    assert len(a) == 2 
开发者ID:caronc,项目名称:apprise,代码行数:26,代码来源:test_sns_plugin.py

示例3: build_apprise

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def build_apprise(self):
        asset = apprise.AppriseAsset(
            image_url_mask='https://i.imgur.com/L40ksWY.png',
            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 
开发者ID:pyouroboros,项目名称:ouroboros,代码行数:21,代码来源:notifiers.py

示例4: notify

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def notify(self, check):

        if not settings.APPRISE_ENABLED:
            # Not supported and/or enabled
            return "Apprise is disabled and/or not installed"

        a = apprise.Apprise()
        title = tmpl("apprise_title.html", check=check)
        body = tmpl("apprise_description.html", check=check)

        a.add(self.channel.value)

        notify_type = (
            apprise.NotifyType.SUCCESS
            if check.status == "up"
            else apprise.NotifyType.FAILURE
        )

        return (
            "Failed"
            if not a.notify(body=body, title=title, notify_type=notify_type)
            else None
        ) 
开发者ID:healthchecks,项目名称:healthchecks,代码行数:25,代码来源:transports.py

示例5: build_apprise

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def build_apprise(self, notifiers):
        asset = apprise.AppriseAsset()
        asset.app_id = "dockupdater"
        asset.app_desc = "dockupdater"
        asset.app_url = "https://github.com/dockupdater/dockupdater"
        asset.html_notify_map['info'] = '#5F87C6'

        apprise_obj = apprise.Apprise(asset=asset)

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

        return apprise_obj 
开发者ID:dockupdater,项目名称:dockupdater,代码行数:18,代码来源:notifiers.py

示例6: send_notification

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def send_notification(title, body):
    """Send notification."""
    hostname = socket.gethostname()

    recipient = RECIPIENTS.get(hostname, "eisenhauer@policy-lab.org")

    # This allows to run the scripts even when no notification can be send.
    home = Path(os.environ.get("HOME") or os.environ.get("HOMEPATH"))
    credentials = home / ".credentials"

    if not credentials.exists():
        warnings.warn("No configuration file for notifications available.")
        sys.exit(0)

    credentials = json.loads(credentials.read_text())
    message_header = {
        "domain": "gmail.com",
        "to": recipient,
        "name": "respy",
        **credentials,
    }
    service = "mailto://{username}:{password}@{domain}?to={to}&name={name}"

    apobj = apprise.Apprise()
    apobj.add(service.format(**message_header))
    apobj.notify(title=title, body=body) 
开发者ID:OpenSourceEconomics,项目名称:respy,代码行数:28,代码来源:notifications.py

示例7: __init__

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def __init__(self, url, title='Traktarr'):
        self.url = url
        self.title = title
        log.debug("Initialized Apprise notification agent") 
开发者ID:l3uddz,项目名称:traktarr,代码行数:6,代码来源:apprise.py

示例8: __init__

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def __init__(self, url, title='Cloudplow'):
        self.url = url
        self.title = title
        log.debug("Initialized Apprise notification agent") 
开发者ID:l3uddz,项目名称:cloudplow,代码行数:6,代码来源:apprise.py

示例9: update_notifier

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def update_notifier():
    # define apprise object
    a = apprise.Apprise()

    # Retrieve all of the details
    results = a.details()

    notifiers_new = []
    notifiers_old = []

    notifiers_current_db = database.execute("SELECT name FROM table_settings_notifier")

    notifiers_current = []
    for notifier in notifiers_current_db:
        notifiers_current.append([notifier['name']])

    for x in results['schemas']:
        if [x['service_name']] not in notifiers_current:
            notifiers_new.append([x['service_name'], 0])
            logging.debug('Adding new notifier agent: ' + x['service_name'])
        else:
            notifiers_old.append([x['service_name']])

    notifiers_to_delete = [item for item in notifiers_current if item not in notifiers_old]

    database.execute("INSERT INTO table_settings_notifier (name, enabled) VALUES (?, ?)", notifiers_new,
                     execute_many=True)

    database.execute("DELETE FROM table_settings_notifier WHERE name=?", notifiers_to_delete, execute_many=True) 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:31,代码来源:notifier.py

示例10: send_notifications

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def send_notifications(sonarr_series_id, sonarr_episode_id, message):
    providers = get_notifier_providers()
    series = get_series_name(sonarr_series_id)
    episode = get_episode_name(sonarr_episode_id)

    apobj = apprise.Apprise()

    for provider in providers:
        if provider['url'] is not None:
            apobj.add(provider['url'])

    apobj.notify(
        title='Bazarr notification',
        body="{} - S{:02d}E{:02d} - {} : {}".format(series, episode[1], episode[2], episode[0], message),
    ) 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:17,代码来源:notifier.py

示例11: send_notifications_movie

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def send_notifications_movie(radarr_id, message):
    providers = get_notifier_providers()
    movie = get_movies_name(radarr_id)

    apobj = apprise.Apprise()

    for provider in providers:
        if provider['url'] is not None:
            apobj.add(provider['url'])

    apobj.notify(
        title='Bazarr notification',
        body="{} : {}".format(movie, message),
    ) 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:16,代码来源:notifier.py

示例12: test_notification

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def test_notification(protocol, provider):
    authorize()
    provider = six.moves.urllib.parse.unquote(provider)
    apobj = apprise.Apprise()
    apobj.add(protocol + "://" + provider)
    
    apobj.notify(
        title='Bazarr test notification',
        body=('Test notification')
    ) 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:12,代码来源:main.py

示例13: plugin

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def plugin(srv, item):
    """Send a message to Apprise plugin(s)."""

    srv.logging.debug("*** MODULE=%s: service=%s, target=%s", __file__, item.service, item.target)

    addresses = item.addrs

    if not addresses:
        srv.logging.warn("Skipped sending notification to Apprise %s, "
                         "no addresses configured" % (item.target))
        return False

    sender = item.config.get('sender')
    sender_name = item.config.get('sender_name')
    baseuri = item.config['baseuri']
    title = item.title
    body = item.message

    try:
        srv.logging.debug("Sending notification to Apprise %s, addresses: %s" % (item.target, addresses))
        to = ','.join(addresses)

        # Create an Apprise instance.
        apobj = apprise.Apprise()

        # Add notification services by server url.
        uri = '{baseuri}?from={sender}&to={to}'.format(baseuri=baseuri, sender=sender, to=to)
        if sender_name:
            uri += '&name={sender_name}'.format(sender_name=sender_name)
        apobj.add(uri)

        # Submit notification.
        outcome = apobj.notify(
            body=body,
            title=title,
        )

        if outcome:
            srv.logging.info("Successfully sent message using Apprise")
            return True

        else:
            srv.logging.error("Sending message using Apprise failed")
            return False

    except Exception as e:
        srv.logging.error("Error sending message to %s: %s" % (item.target, e))
        return False 
开发者ID:jpmens,项目名称:mqttwarn,代码行数:50,代码来源:apprise.py

示例14: test_apprise_pretty_print

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def test_apprise_pretty_print(tmpdir):
    """
    API: Apprise() Pretty Print tests

    """
    # Privacy Print
    # PrivacyMode.Secret always returns the same thing to avoid guessing
    assert URLBase.pprint(
        None, privacy=True, mode=PrivacyMode.Secret) == '****'
    assert URLBase.pprint(
        42, privacy=True, mode=PrivacyMode.Secret) == '****'
    assert URLBase.pprint(
        object, privacy=True, mode=PrivacyMode.Secret) == '****'
    assert URLBase.pprint(
        "", privacy=True, mode=PrivacyMode.Secret) == '****'
    assert URLBase.pprint(
        "a", privacy=True, mode=PrivacyMode.Secret) == '****'
    assert URLBase.pprint(
        "ab", privacy=True, mode=PrivacyMode.Secret) == '****'
    assert URLBase.pprint(
        "abcdefghijk", privacy=True, mode=PrivacyMode.Secret) == '****'

    # PrivacyMode.Outer
    assert URLBase.pprint(
        None, privacy=True, mode=PrivacyMode.Outer) == ''
    assert URLBase.pprint(
        42, privacy=True, mode=PrivacyMode.Outer) == ''
    assert URLBase.pprint(
        object, privacy=True, mode=PrivacyMode.Outer) == ''
    assert URLBase.pprint(
        "", privacy=True, mode=PrivacyMode.Outer) == ''
    assert URLBase.pprint(
        "a", privacy=True, mode=PrivacyMode.Outer) == 'a...a'
    assert URLBase.pprint(
        "ab", privacy=True, mode=PrivacyMode.Outer) == 'a...b'
    assert URLBase.pprint(
        "abcdefghijk", privacy=True, mode=PrivacyMode.Outer) == 'a...k'

    # PrivacyMode.Tail
    assert URLBase.pprint(
        None, privacy=True, mode=PrivacyMode.Tail) == ''
    assert URLBase.pprint(
        42, privacy=True, mode=PrivacyMode.Tail) == ''
    assert URLBase.pprint(
        object, privacy=True, mode=PrivacyMode.Tail) == ''
    assert URLBase.pprint(
        "", privacy=True, mode=PrivacyMode.Tail) == ''
    assert URLBase.pprint(
        "a", privacy=True, mode=PrivacyMode.Tail) == '...a'
    assert URLBase.pprint(
        "ab", privacy=True, mode=PrivacyMode.Tail) == '...ab'
    assert URLBase.pprint(
        "abcdefghijk", privacy=True, mode=PrivacyMode.Tail) == '...hijk'

    # Quoting settings
    assert URLBase.pprint(" ", privacy=False, safe='') == '%20'
    assert URLBase.pprint(" ", privacy=False, quote=False, safe='') == ' ' 
开发者ID:caronc,项目名称:apprise,代码行数:59,代码来源:test_api.py

示例15: test_config_base_parse_yaml_file02

# 需要导入模块: import apprise [as 别名]
# 或者: from apprise import Apprise [as 别名]
def test_config_base_parse_yaml_file02(tmpdir):
    """
    API: ConfigBase.parse_yaml_file (#2)

    """
    t = tmpdir.mkdir("matching-tags").join("apprise.yml")
    t.write("""urls:
  - pover://nsisxnvnqixq39t0cw54pxieyvtdd9@2jevtmstfg5a7hfxndiybasttxxfku:
    - tag: test1
  - pover://rg8ta87qngcrkc6t4qbykxktou0uug@tqs3i88xlufexwl8t4asglt4zp5wfn:
    - tag: test2
  - pover://jcqgnlyq2oetea4qg3iunahj8d5ijm@evalvutkhc8ipmz2lcgc70wtsm0qpb:
    - tag: test3""")

    # Create ourselves a config object
    ac = AppriseConfig(paths=str(t))

    # The number of configuration files that exist
    assert len(ac) == 1

    # no notifications are loaded
    assert len(ac.servers()) == 3

    # Test our ability to add Config objects to our apprise object
    a = Apprise()

    # Add our configuration object
    assert a.add(servers=ac) is True

    # Detect our 3 entry as they should have loaded successfully
    assert len(a) == 3

    # No match
    assert sum(1 for _ in a.find('no-match')) == 0
    # Match everything
    assert sum(1 for _ in a.find('all')) == 3
    # Match test1 entry
    assert sum(1 for _ in a.find('test1')) == 1
    # Match test2 entry
    assert sum(1 for _ in a.find('test2')) == 1
    # Match test3 entry
    assert sum(1 for _ in a.find('test3')) == 1
    # Match test1 or test3 entry
    assert sum(1 for _ in a.find('test1, test3')) == 2 
开发者ID:caronc,项目名称:apprise,代码行数:46,代码来源:test_apprise_config.py


注:本文中的apprise.Apprise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。