Skip to content

Commit

Permalink
supress sleekxmpp logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dschep committed Feb 7, 2016
1 parent 530130f commit 858e510
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions ntfy/backends/xmpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,26 @@ def notify(title, message, jid, password, recipient,
NOTE: Ignored without specified hostname
"""

xmpp_bot = NtfySendMsgBot(jid, password, recipient,
title, message, mtype)

# NOTE: Below plugins weren't needed for Google Hangouts
# but may be useful (from original sleekxmpp example)
# xmpp_bot.register_plugin('xep_0030') # Service Discovery
# xmpp_bot.register_plugin('xep_0199') # XMPP Ping

if path_to_certs and os.path.isdir(path_to_certs):
xmpp_bot.ca_certs = path_to_certs

# Connect to the XMPP server and start processing XMPP stanzas.
if xmpp_bot.connect(*([(hostname, int(port)) if hostname else []])):
xmpp_bot.process(block=True)
else:
logging.getLogger(__name__).error('Unable to connect', exc_info=True)
loglevel = logging.getEffectiveLevel()
try:
logging.disable(logging.ERROR)
xmpp_bot = NtfySendMsgBot(jid, password, recipient,
title, message, mtype)

# NOTE: Below plugins weren't needed for Google Hangouts
# but may be useful (from original sleekxmpp example)
# xmpp_bot.register_plugin('xep_0030') # Service Discovery
# xmpp_bot.register_plugin('xep_0199') # XMPP Ping

if path_to_certs and os.path.isdir(path_to_certs):
xmpp_bot.ca_certs = path_to_certs

# Connect to the XMPP server and start processing XMPP stanzas.
if xmpp_bot.connect(*([(hostname, int(port)) if hostname else []])):
xmpp_bot.process(block=True)
else:
logging.disable(loglevel)
logging.getLogger(__name__).error('Unable to connect',
exc_info=True)
finally:
logging.disable(loglevel)

0 comments on commit 858e510

Please sign in to comment.