mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 02:26:58 -07:00
Remove unicode strings
This commit is contained in:
parent
1c18e72539
commit
c279057f91
28 changed files with 834 additions and 847 deletions
|
@ -447,7 +447,7 @@ def delete_notifier(notifier_id=None):
|
|||
db = database.MonitorDatabase()
|
||||
|
||||
if str(notifier_id).isdigit():
|
||||
logger.debug(u"Tautulli Notifiers :: Deleting notifier_id %s from the database."
|
||||
logger.debug("Tautulli Notifiers :: Deleting notifier_id %s from the database."
|
||||
% notifier_id)
|
||||
result = db.action('DELETE FROM notifiers WHERE id = ?', args=[notifier_id])
|
||||
return True
|
||||
|
@ -459,7 +459,7 @@ def get_notifier_config(notifier_id=None, mask_passwords=False):
|
|||
if str(notifier_id).isdigit():
|
||||
notifier_id = int(notifier_id)
|
||||
else:
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve notifier config: invalid notifier_id %s."
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve notifier config: invalid notifier_id %s."
|
||||
% notifier_id)
|
||||
return None
|
||||
|
||||
|
@ -473,7 +473,7 @@ def get_notifier_config(notifier_id=None, mask_passwords=False):
|
|||
config = json.loads(result.pop('notifier_config', '{}'))
|
||||
notifier_agent = get_agent_class(agent_id=result['agent_id'], config=config)
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli Notifiers :: Failed to get notifier config options: %s." % e)
|
||||
logger.error("Tautulli Notifiers :: Failed to get notifier config options: %s." % e)
|
||||
return
|
||||
|
||||
if mask_passwords:
|
||||
|
@ -517,14 +517,14 @@ def add_notifier_config(agent_id=None, **kwargs):
|
|||
if str(agent_id).isdigit():
|
||||
agent_id = int(agent_id)
|
||||
else:
|
||||
logger.error(u"Tautulli Notifiers :: Unable to add new notifier: invalid agent_id %s."
|
||||
logger.error("Tautulli Notifiers :: Unable to add new notifier: invalid agent_id %s."
|
||||
% agent_id)
|
||||
return False
|
||||
|
||||
agent = next((a for a in available_notification_agents() if a['id'] == agent_id), None)
|
||||
|
||||
if not agent:
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve new notification agent: invalid agent_id %s."
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve new notification agent: invalid agent_id %s."
|
||||
% agent_id)
|
||||
return False
|
||||
|
||||
|
@ -553,12 +553,12 @@ def add_notifier_config(agent_id=None, **kwargs):
|
|||
try:
|
||||
db.upsert(table_name='notifiers', key_dict=keys, value_dict=values)
|
||||
notifier_id = db.last_insert_id()
|
||||
logger.info(u"Tautulli Notifiers :: Added new notification agent: %s (notifier_id %s)."
|
||||
logger.info("Tautulli Notifiers :: Added new notification agent: %s (notifier_id %s)."
|
||||
% (agent['label'], notifier_id))
|
||||
blacklist_logger()
|
||||
return notifier_id
|
||||
except Exception as e:
|
||||
logger.warn(u"Tautulli Notifiers :: Unable to add notification agent: %s." % e)
|
||||
logger.warn("Tautulli Notifiers :: Unable to add notification agent: %s." % e)
|
||||
return False
|
||||
|
||||
|
||||
|
@ -566,14 +566,14 @@ def set_notifier_config(notifier_id=None, agent_id=None, **kwargs):
|
|||
if str(agent_id).isdigit():
|
||||
agent_id = int(agent_id)
|
||||
else:
|
||||
logger.error(u"Tautulli Notifiers :: Unable to set existing notifier: invalid agent_id %s."
|
||||
logger.error("Tautulli Notifiers :: Unable to set existing notifier: invalid agent_id %s."
|
||||
% agent_id)
|
||||
return False
|
||||
|
||||
agent = next((a for a in available_notification_agents() if a['id'] == agent_id), None)
|
||||
|
||||
if not agent:
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve existing notification agent: invalid agent_id %s."
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve existing notification agent: invalid agent_id %s."
|
||||
% agent_id)
|
||||
return False
|
||||
|
||||
|
@ -614,7 +614,7 @@ def set_notifier_config(notifier_id=None, agent_id=None, **kwargs):
|
|||
db = database.MonitorDatabase()
|
||||
try:
|
||||
db.upsert(table_name='notifiers', key_dict=keys, value_dict=values)
|
||||
logger.info(u"Tautulli Notifiers :: Updated notification agent: %s (notifier_id %s)."
|
||||
logger.info("Tautulli Notifiers :: Updated notification agent: %s (notifier_id %s)."
|
||||
% (agent['label'], notifier_id))
|
||||
blacklist_logger()
|
||||
|
||||
|
@ -623,7 +623,7 @@ def set_notifier_config(notifier_id=None, agent_id=None, **kwargs):
|
|||
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.warn(u"Tautulli Notifiers :: Unable to update notification agent: %s." % e)
|
||||
logger.warn("Tautulli Notifiers :: Unable to update notification agent: %s." % e)
|
||||
return False
|
||||
|
||||
|
||||
|
@ -638,7 +638,7 @@ def send_notification(notifier_id=None, subject='', body='', notify_action='', n
|
|||
notification_id=notification_id,
|
||||
**kwargs)
|
||||
else:
|
||||
logger.debug(u"Tautulli Notifiers :: Notification requested but no notifier_id received.")
|
||||
logger.debug("Tautulli Notifiers :: Notification requested but no notifier_id received.")
|
||||
|
||||
|
||||
def blacklist_logger():
|
||||
|
@ -813,10 +813,10 @@ class Notifier(object):
|
|||
def notify(self, subject='', body='', action='', **kwargs):
|
||||
if self.NAME not in ('Script', 'Webhook'):
|
||||
if not subject and self.config.get('incl_subject', True):
|
||||
logger.error(u"Tautulli Notifiers :: %s notification subject cannot be blank." % self.NAME)
|
||||
logger.error("Tautulli Notifiers :: %s notification subject cannot be blank." % self.NAME)
|
||||
return
|
||||
elif not body:
|
||||
logger.error(u"Tautulli Notifiers :: %s notification body cannot be blank." % self.NAME)
|
||||
logger.error("Tautulli Notifiers :: %s notification body cannot be blank." % self.NAME)
|
||||
return
|
||||
|
||||
return self.agent_notify(subject=subject, body=body, action=action, **kwargs)
|
||||
|
@ -825,11 +825,11 @@ class Notifier(object):
|
|||
pass
|
||||
|
||||
def make_request(self, url, method='POST', **kwargs):
|
||||
logger.info(u"Tautulli Notifiers :: Sending {name} notification...".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: Sending {name} notification...".format(name=self.NAME))
|
||||
response, err_msg, req_msg = request.request_response2(url, method, **kwargs)
|
||||
|
||||
if response and not err_msg:
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
return True
|
||||
|
||||
else:
|
||||
|
@ -837,13 +837,13 @@ class Notifier(object):
|
|||
if response is not None and response.status_code >= 400 and response.status_code < 500:
|
||||
verify_msg = " Verify you notification agent settings are correct."
|
||||
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed.{msg}".format(msg=verify_msg, name=self.NAME))
|
||||
logger.error("Tautulli Notifiers :: {name} notification failed.{msg}".format(msg=verify_msg, name=self.NAME))
|
||||
|
||||
if err_msg:
|
||||
logger.error(u"Tautulli Notifiers :: {}".format(err_msg))
|
||||
logger.error("Tautulli Notifiers :: {}".format(err_msg))
|
||||
|
||||
if req_msg:
|
||||
logger.debug(u"Tautulli Notifiers :: Request response: {}".format(req_msg))
|
||||
logger.debug("Tautulli Notifiers :: Request response: {}".format(req_msg))
|
||||
|
||||
return False
|
||||
|
||||
|
@ -876,7 +876,7 @@ class ANDROIDAPP(Notifier):
|
|||
# Check mobile device is still registered
|
||||
device = mobile_app.get_mobile_devices(device_id=self.config['device_id'])
|
||||
if not device:
|
||||
logger.warn(u"Tautulli Notifiers :: Unable to send Android app notification: device not registered.")
|
||||
logger.warn("Tautulli Notifiers :: Unable to send Android app notification: device not registered.")
|
||||
return
|
||||
else:
|
||||
device = device[0]
|
||||
|
@ -927,7 +927,7 @@ class ANDROIDAPP(Notifier):
|
|||
'salt': base64.b64encode(salt)}
|
||||
}
|
||||
else:
|
||||
logger.warn(u"Tautulli Notifiers :: PyCryptodome library is missing. "
|
||||
logger.warn("Tautulli Notifiers :: PyCryptodome library is missing. "
|
||||
"Android app notifications will be sent unecrypted. "
|
||||
"Install the library to encrypt the notifications.")
|
||||
|
||||
|
@ -951,7 +951,7 @@ class ANDROIDAPP(Notifier):
|
|||
query = 'SELECT * FROM mobile_devices'
|
||||
result = db.select(query=query)
|
||||
except Exception as e:
|
||||
logger.warn(u"Tautulli Notifiers :: Unable to retrieve Android app devices list: %s." % e)
|
||||
logger.warn("Tautulli Notifiers :: Unable to retrieve Android app devices list: %s." % e)
|
||||
return {'': ''}
|
||||
|
||||
devices = {}
|
||||
|
@ -1107,7 +1107,7 @@ class BROWSER(Notifier):
|
|||
}
|
||||
|
||||
def agent_notify(self, subject='', body='', action='', **kwargs):
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
return True
|
||||
|
||||
def _return_config_options(self):
|
||||
|
@ -1380,11 +1380,11 @@ class EMAIL(Notifier):
|
|||
mailserver.login(str(self.config['smtp_user']), str(self.config['smtp_password']))
|
||||
|
||||
mailserver.sendmail(self.config['from'], recipients, msg.as_string())
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
success = True
|
||||
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed: {e}".format(
|
||||
logger.error("Tautulli Notifiers :: {name} notification failed: {e}".format(
|
||||
name=self.NAME, e=str(e).decode('utf-8')))
|
||||
|
||||
finally:
|
||||
|
@ -1517,7 +1517,7 @@ class FACEBOOK(Notifier):
|
|||
perms=['publish_to_groups'])
|
||||
|
||||
def _get_credentials(self, code=''):
|
||||
logger.info(u"Tautulli Notifiers :: Requesting access token from {name}.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: Requesting access token from {name}.".format(name=self.NAME))
|
||||
|
||||
app_id = plexpy.CONFIG.FACEBOOK_APP_ID
|
||||
app_secret = plexpy.CONFIG.FACEBOOK_APP_SECRET
|
||||
|
@ -1539,7 +1539,7 @@ class FACEBOOK(Notifier):
|
|||
|
||||
plexpy.CONFIG.FACEBOOK_TOKEN = response['access_token']
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli Notifiers :: Error requesting {name} access token: {e}".format(name=self.NAME, e=e))
|
||||
logger.error("Tautulli Notifiers :: Error requesting {name} access token: {e}".format(name=self.NAME, e=e))
|
||||
plexpy.CONFIG.FACEBOOK_TOKEN = ''
|
||||
|
||||
# Clear out temporary config values
|
||||
|
@ -1555,14 +1555,14 @@ class FACEBOOK(Notifier):
|
|||
|
||||
try:
|
||||
api.put_object(parent_object=self.config['group_id'], connection_name='feed', **data)
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli Notifiers :: Error sending {name} post: {e}".format(name=self.NAME, e=e))
|
||||
logger.error("Tautulli Notifiers :: Error sending {name} post: {e}".format(name=self.NAME, e=e))
|
||||
return False
|
||||
|
||||
else:
|
||||
logger.error(u"Tautulli Notifiers :: Error sending {name} post: No {name} Group ID provided.".format(name=self.NAME))
|
||||
logger.error("Tautulli Notifiers :: Error sending {name} post: No {name} Group ID provided.".format(name=self.NAME))
|
||||
return False
|
||||
|
||||
def agent_notify(self, subject='', body='', action='', **kwargs):
|
||||
|
@ -1700,7 +1700,7 @@ class GROUPME(Notifier):
|
|||
poster_content = result[0]
|
||||
else:
|
||||
poster_content = ''
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve image for {name}.".format(name=self.NAME))
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve image for {name}.".format(name=self.NAME))
|
||||
|
||||
if poster_content:
|
||||
headers = {'X-Access-Token': self.config['access_token'],
|
||||
|
@ -1709,14 +1709,14 @@ class GROUPME(Notifier):
|
|||
r = requests.post('https://image.groupme.com/pictures', headers=headers, data=poster_content)
|
||||
|
||||
if r.status_code == 200:
|
||||
logger.info(u"Tautulli Notifiers :: {name} poster sent.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: {name} poster sent.".format(name=self.NAME))
|
||||
r_content = r.json()
|
||||
data['attachments'] = [{'type': 'image',
|
||||
'url': r_content['payload']['picture_url']}]
|
||||
else:
|
||||
logger.error(u"Tautulli Notifiers :: {name} poster failed: "
|
||||
u"[{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
logger.debug(u"Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
logger.error("Tautulli Notifiers :: {name} poster failed: "
|
||||
"[{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
logger.debug("Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
|
||||
return self.make_request('https://api.groupme.com/v3/bots/post', json=data)
|
||||
|
||||
|
@ -1788,10 +1788,10 @@ class GROWL(Notifier):
|
|||
try:
|
||||
growl.register()
|
||||
except gntp.notifier.errors.NetworkError:
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed: network error".format(name=self.NAME))
|
||||
logger.error("Tautulli Notifiers :: {name} notification failed: network error".format(name=self.NAME))
|
||||
return False
|
||||
except gntp.notifier.errors.AuthError:
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed: authentication error".format(name=self.NAME))
|
||||
logger.error("Tautulli Notifiers :: {name} notification failed: authentication error".format(name=self.NAME))
|
||||
return False
|
||||
|
||||
# Fix message
|
||||
|
@ -1811,10 +1811,10 @@ class GROWL(Notifier):
|
|||
description=body,
|
||||
icon=image
|
||||
)
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
return True
|
||||
except gntp.notifier.errors.NetworkError:
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed: network error".format(name=self.NAME))
|
||||
logger.error("Tautulli Notifiers :: {name} notification failed: network error".format(name=self.NAME))
|
||||
return False
|
||||
|
||||
def _return_config_options(self):
|
||||
|
@ -2113,15 +2113,15 @@ class JOIN(Notifier):
|
|||
if r.status_code == 200:
|
||||
response_data = r.json()
|
||||
if response_data.get('success'):
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
return True
|
||||
else:
|
||||
error_msg = response_data.get('errorMessage')
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed: {msg}".format(name=self.NAME, msg=error_msg))
|
||||
logger.error("Tautulli Notifiers :: {name} notification failed: {msg}".format(name=self.NAME, msg=error_msg))
|
||||
return False
|
||||
else:
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed: [{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
logger.debug(u"Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
logger.error("Tautulli Notifiers :: {name} notification failed: [{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
logger.debug("Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
return False
|
||||
|
||||
def get_devices(self):
|
||||
|
@ -2141,14 +2141,14 @@ class JOIN(Notifier):
|
|||
devices.update({d['deviceName']: d['deviceName'] for d in response_devices})
|
||||
else:
|
||||
error_msg = response_data.get('errorMessage')
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: {msg}".format(name=self.NAME, msg=error_msg))
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve {name} devices list: {msg}".format(name=self.NAME, msg=error_msg))
|
||||
|
||||
else:
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: [{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
logger.debug(u"Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve {name} devices list: [{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
logger.debug("Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: {msg}".format(name=self.NAME, msg=e))
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve {name} devices list: {msg}".format(name=self.NAME, msg=e))
|
||||
|
||||
return devices
|
||||
|
||||
|
@ -2235,7 +2235,7 @@ class MQTT(Notifier):
|
|||
|
||||
def agent_notify(self, subject='', body='', action='', **kwargs):
|
||||
if not self.config['topic']:
|
||||
logger.error(u"Tautulli Notifiers :: MQTT topic not specified.")
|
||||
logger.error("Tautulli Notifiers :: MQTT topic not specified.")
|
||||
return
|
||||
|
||||
data = {'subject': subject.encode('utf-8'),
|
||||
|
@ -2349,11 +2349,11 @@ class NMA(Notifier):
|
|||
|
||||
response = p.push(title, subject, body, priority=self.config['priority'], batch_mode=batch)
|
||||
|
||||
if response[self.config['api_key']][u'code'] == u'200':
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
if response[self.config['api_key']]['code'] == '200':
|
||||
logger.info("Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
return True
|
||||
else:
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed.".format(name=self.NAME))
|
||||
logger.error("Tautulli Notifiers :: {name} notification failed.".format(name=self.NAME))
|
||||
return False
|
||||
|
||||
def _return_config_options(self):
|
||||
|
@ -2390,7 +2390,7 @@ class OSX(Notifier):
|
|||
self.objc = __import__("objc")
|
||||
self.AppKit = __import__("AppKit")
|
||||
except:
|
||||
# logger.error(u"Tautulli Notifiers :: Cannot load OSX Notifications agent.")
|
||||
# logger.error("Tautulli Notifiers :: Cannot load OSX Notifications agent.")
|
||||
pass
|
||||
|
||||
def validate(self):
|
||||
|
@ -2449,13 +2449,13 @@ class OSX(Notifier):
|
|||
|
||||
notification_center = NSUserNotificationCenter.defaultUserNotificationCenter()
|
||||
notification_center.deliverNotification_(notification)
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
|
||||
del pool
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli Notifiers :: {name} failed: {e}".format(name=self.NAME, e=e))
|
||||
logger.error("Tautulli Notifiers :: {name} failed: {e}".format(name=self.NAME, e=e))
|
||||
return False
|
||||
|
||||
def _return_config_options(self):
|
||||
|
@ -2527,7 +2527,7 @@ class PLEX(Notifier):
|
|||
image = os.path.join(plexpy.DATA_DIR, os.path.abspath("data/interfaces/default/images/logo-circle.png"))
|
||||
|
||||
for host in hosts:
|
||||
logger.info(u"Tautulli Notifiers :: Sending notification command to {name} @ {host}".format(name=self.NAME, host=host))
|
||||
logger.info("Tautulli Notifiers :: Sending notification command to {name} @ {host}".format(name=self.NAME, host=host))
|
||||
try:
|
||||
version = self._sendjson(host, 'Application.GetProperties', {'properties': ['version']})['version']['major']
|
||||
|
||||
|
@ -2543,10 +2543,10 @@ class PLEX(Notifier):
|
|||
if not request:
|
||||
raise Exception
|
||||
else:
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed: {e}".format(name=self.NAME, e=e))
|
||||
logger.error("Tautulli Notifiers :: {name} notification failed: {e}".format(name=self.NAME, e=e))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -2694,7 +2694,7 @@ class PUSHBULLET(Notifier):
|
|||
poster_content = result[0]
|
||||
else:
|
||||
poster_content = ''
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve image for {name}.".format(name=self.NAME))
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve image for {name}.".format(name=self.NAME))
|
||||
|
||||
if poster_content:
|
||||
poster_filename = 'poster_{}.png'.format(pretty_metadata.parameters['rating_key'])
|
||||
|
@ -2713,9 +2713,9 @@ class PUSHBULLET(Notifier):
|
|||
file_response.pop('data', None)
|
||||
data.update(file_response)
|
||||
else:
|
||||
logger.error(u"Tautulli Notifiers :: Unable to upload image to {name}: "
|
||||
u"[{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
logger.debug(u"Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
logger.error("Tautulli Notifiers :: Unable to upload image to {name}: "
|
||||
"[{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
logger.debug("Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
|
||||
return self.make_request('https://api.pushbullet.com/v2/pushes', headers=headers, json=data)
|
||||
|
||||
|
@ -2734,12 +2734,12 @@ class PUSHBULLET(Notifier):
|
|||
pushbullet_devices = response_data.get('devices', [])
|
||||
devices.update({d['iden']: d['nickname'] for d in pushbullet_devices if d['active']})
|
||||
else:
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: "
|
||||
u"[{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
logger.debug(u"Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve {name} devices list: "
|
||||
"[{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
logger.debug("Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} devices list: {msg}".format(name=self.NAME, msg=e))
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve {name} devices list: {msg}".format(name=self.NAME, msg=e))
|
||||
|
||||
return devices
|
||||
|
||||
|
@ -2851,7 +2851,7 @@ class PUSHOVER(Notifier):
|
|||
poster_content = result[0]
|
||||
else:
|
||||
poster_content = ''
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve image for {name}.".format(name=self.NAME))
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve image for {name}.".format(name=self.NAME))
|
||||
|
||||
if poster_content:
|
||||
poster_filename = 'poster_{}.png'.format(pretty_metadata.parameters['rating_key'])
|
||||
|
@ -2901,9 +2901,9 @@ class PUSHOVER(Notifier):
|
|||
# print sounds
|
||||
# return sounds
|
||||
# else:
|
||||
# logger.error(u"Tautulli Notifiers :: Unable to retrieve {name} sounds list: "
|
||||
# u"[{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
# logger.debug(u"Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
# logger.error("Tautulli Notifiers :: Unable to retrieve {name} sounds list: "
|
||||
# "[{r.status_code}] {r.reason}".format(name=self.NAME, r=r))
|
||||
# logger.debug("Tautulli Notifiers :: Request response: {}".format(request.server_message(r, True)))
|
||||
# return {'': ''}
|
||||
#
|
||||
# else:
|
||||
|
@ -3089,13 +3089,13 @@ class SCRIPTS(Notifier):
|
|||
timer.start()
|
||||
output, error = process.communicate()
|
||||
status = process.returncode
|
||||
logger.debug(u"Tautulli Notifiers :: Subprocess returned with status code %s." % status)
|
||||
logger.debug("Tautulli Notifiers :: Subprocess returned with status code %s." % status)
|
||||
finally:
|
||||
if timer:
|
||||
timer.cancel()
|
||||
|
||||
except OSError as e:
|
||||
logger.error(u"Tautulli Notifiers :: Failed to run script: %s" % e)
|
||||
logger.error("Tautulli Notifiers :: Failed to run script: %s" % e)
|
||||
return False
|
||||
|
||||
if error:
|
||||
|
@ -3107,13 +3107,13 @@ class SCRIPTS(Notifier):
|
|||
logger.debug("Tautulli Notifiers :: Script returned: \n %s" % out)
|
||||
|
||||
if not self.script_killed:
|
||||
logger.info(u"Tautulli Notifiers :: Script notification sent.")
|
||||
logger.info("Tautulli Notifiers :: Script notification sent.")
|
||||
return True
|
||||
|
||||
def kill_script(self, process):
|
||||
process.kill()
|
||||
self.script_killed = True
|
||||
logger.warn(u"Tautulli Notifiers :: Script exceeded timeout limit of %d seconds. "
|
||||
logger.warn("Tautulli Notifiers :: Script exceeded timeout limit of %d seconds. "
|
||||
"Script killed." % self.config['timeout'])
|
||||
|
||||
def agent_notify(self, subject='', body='', action='', **kwargs):
|
||||
|
@ -3124,12 +3124,12 @@ class SCRIPTS(Notifier):
|
|||
action(string): 'play'
|
||||
"""
|
||||
if not self.config['script_folder']:
|
||||
logger.error(u"Tautulli Notifiers :: No script folder specified.")
|
||||
logger.error("Tautulli Notifiers :: No script folder specified.")
|
||||
return
|
||||
|
||||
script_args = helpers.split_args(kwargs.get('script_args', subject))
|
||||
|
||||
logger.debug(u"Tautulli Notifiers :: Trying to run notify script, action: %s, arguments: %s"
|
||||
logger.debug("Tautulli Notifiers :: Trying to run notify script, action: %s, arguments: %s"
|
||||
% (action, script_args))
|
||||
|
||||
script = kwargs.get('script', self.config.get('script', ''))
|
||||
|
@ -3137,10 +3137,10 @@ class SCRIPTS(Notifier):
|
|||
|
||||
# Don't try to run the script if the action does not have one
|
||||
if action and not script:
|
||||
logger.debug(u"Tautulli Notifiers :: No script selected for action %s, exiting..." % action)
|
||||
logger.debug("Tautulli Notifiers :: No script selected for action %s, exiting..." % action)
|
||||
return
|
||||
elif not script:
|
||||
logger.debug(u"Tautulli Notifiers :: No script selected, exiting...")
|
||||
logger.debug("Tautulli Notifiers :: No script selected, exiting...")
|
||||
return
|
||||
|
||||
name, ext = os.path.splitext(script)
|
||||
|
@ -3178,8 +3178,8 @@ class SCRIPTS(Notifier):
|
|||
|
||||
script.extend(script_args)
|
||||
|
||||
logger.debug(u"Tautulli Notifiers :: Full script is: %s" % script)
|
||||
logger.debug(u"Tautulli Notifiers :: Executing script in a new thread.")
|
||||
logger.debug("Tautulli Notifiers :: Full script is: %s" % script)
|
||||
logger.debug("Tautulli Notifiers :: Executing script in a new thread.")
|
||||
thread = threading.Thread(target=self.run_script, args=(script, user_id)).start()
|
||||
|
||||
return True
|
||||
|
@ -3433,7 +3433,7 @@ class TELEGRAM(Notifier):
|
|||
poster_content = result[0]
|
||||
else:
|
||||
poster_content = ''
|
||||
logger.error(u"Tautulli Notifiers :: Unable to retrieve image for {name}.".format(name=self.NAME))
|
||||
logger.error("Tautulli Notifiers :: Unable to retrieve image for {name}.".format(name=self.NAME))
|
||||
|
||||
if poster_content:
|
||||
poster_filename = 'poster_{}.png'.format(pretty_metadata.parameters['rating_key'])
|
||||
|
@ -3531,16 +3531,16 @@ class TWITTER(Notifier):
|
|||
access_token = self.config['access_token']
|
||||
access_token_secret = self.config['access_token_secret']
|
||||
|
||||
# logger.info(u"Tautulli Notifiers :: Sending tweet: " + message)
|
||||
# logger.info("Tautulli Notifiers :: Sending tweet: " + message)
|
||||
|
||||
api = twitter.Api(consumer_key, consumer_secret, access_token, access_token_secret)
|
||||
|
||||
try:
|
||||
api.PostUpdate(message, media=attachment)
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed: {e}".format(name=self.NAME, e=e))
|
||||
logger.error("Tautulli Notifiers :: {name} notification failed: {e}".format(name=self.NAME, e=e))
|
||||
return False
|
||||
|
||||
def agent_notify(self, subject='', body='', action='', **kwargs):
|
||||
|
@ -3618,7 +3618,7 @@ class WEBHOOK(Notifier):
|
|||
try:
|
||||
webhook_headers = json.loads(subject)
|
||||
except ValueError as e:
|
||||
logger.error(u"Tautulli Notifiers :: Invalid {name} json header data: {e}".format(name=self.NAME, e=e))
|
||||
logger.error("Tautulli Notifiers :: Invalid {name} json header data: {e}".format(name=self.NAME, e=e))
|
||||
return False
|
||||
else:
|
||||
webhook_headers = None
|
||||
|
@ -3627,7 +3627,7 @@ class WEBHOOK(Notifier):
|
|||
try:
|
||||
webhook_body = json.loads(body)
|
||||
except ValueError as e:
|
||||
logger.error(u"Tautulli Notifiers :: Invalid {name} json body data: {e}".format(name=self.NAME, e=e))
|
||||
logger.error("Tautulli Notifiers :: Invalid {name} json body data: {e}".format(name=self.NAME, e=e))
|
||||
return False
|
||||
else:
|
||||
webhook_body = None
|
||||
|
@ -3711,7 +3711,7 @@ class XBMC(Notifier):
|
|||
image = os.path.join(plexpy.DATA_DIR, os.path.abspath("data/interfaces/default/images/logo-circle.png"))
|
||||
|
||||
for host in hosts:
|
||||
logger.info(u"Tautulli Notifiers :: Sending notification command to XMBC @ " + host)
|
||||
logger.info("Tautulli Notifiers :: Sending notification command to XMBC @ " + host)
|
||||
try:
|
||||
version = self._sendjson(host, 'Application.GetProperties', {'properties': ['version']})['version']['major']
|
||||
|
||||
|
@ -3727,10 +3727,10 @@ class XBMC(Notifier):
|
|||
if not request:
|
||||
raise Exception
|
||||
else:
|
||||
logger.info(u"Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
logger.info("Tautulli Notifiers :: {name} notification sent.".format(name=self.NAME))
|
||||
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli Notifiers :: {name} notification failed: {e}".format(name=self.NAME, e=e))
|
||||
logger.error("Tautulli Notifiers :: {name} notification failed: {e}".format(name=self.NAME, e=e))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -3870,7 +3870,7 @@ class ZAPIER(Notifier):
|
|||
|
||||
|
||||
def upgrade_config_to_db():
|
||||
logger.info(u"Tautulli Notifiers :: Upgrading to new notification system...")
|
||||
logger.info("Tautulli Notifiers :: Upgrading to new notification system...")
|
||||
|
||||
# Set flag first in case something fails we don't want to keep re-adding the notifiers
|
||||
plexpy.CONFIG.__setattr__('UPDATE_NOTIFIERS_DB', 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue