mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 02:26:58 -07:00
Run futurize --stage1
This commit is contained in:
parent
221be380ee
commit
ab6196589b
36 changed files with 736 additions and 497 deletions
|
@ -1,4 +1,6 @@
|
|||
# This file is part of Tautulli.
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# This file is part of Tautulli.
|
||||
#
|
||||
# Tautulli is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -13,6 +15,11 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Tautulli. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from builtins import next
|
||||
from builtins import str
|
||||
from builtins import object
|
||||
|
||||
import arrow
|
||||
from collections import OrderedDict
|
||||
import json
|
||||
|
@ -23,14 +30,14 @@ import os
|
|||
import re
|
||||
|
||||
import plexpy
|
||||
import common
|
||||
import database
|
||||
import helpers
|
||||
import libraries
|
||||
import logger
|
||||
import newsletter_handler
|
||||
import pmsconnect
|
||||
from notifiers import send_notification, EMAIL
|
||||
from plexpy import common
|
||||
from plexpy import database
|
||||
from plexpy import helpers
|
||||
from plexpy import libraries
|
||||
from plexpy import logger
|
||||
from plexpy import newsletter_handler
|
||||
from plexpy import pmsconnect
|
||||
from plexpy.notifiers import send_notification, EMAIL
|
||||
|
||||
|
||||
AGENT_IDS = {
|
||||
|
@ -229,11 +236,11 @@ def set_newsletter_config(newsletter_id=None, agent_id=None, **kwargs):
|
|||
email_config_prefix = 'newsletter_email_'
|
||||
|
||||
newsletter_config = {k[len(config_prefix):]: kwargs.pop(k)
|
||||
for k in kwargs.keys() if k.startswith(config_prefix)}
|
||||
for k in list(kwargs.keys()) if k.startswith(config_prefix)}
|
||||
email_config = {k[len(email_config_prefix):]: kwargs.pop(k)
|
||||
for k in kwargs.keys() if k.startswith(email_config_prefix)}
|
||||
for k in list(kwargs.keys()) if k.startswith(email_config_prefix)}
|
||||
|
||||
for cfg, val in email_config.iteritems():
|
||||
for cfg, val in email_config.items():
|
||||
# Check for a password config keys and a blank password from the HTML form
|
||||
if 'password' in cfg and val == ' ':
|
||||
# Get the previous password so we don't overwrite it with a blank value
|
||||
|
@ -418,7 +425,7 @@ class Newsletter(object):
|
|||
return default
|
||||
|
||||
new_config = {}
|
||||
for k, v in default.iteritems():
|
||||
for k, v in default.items():
|
||||
if isinstance(v, int):
|
||||
new_config[k] = helpers.cast_to_int(config.get(k, v))
|
||||
elif isinstance(v, list):
|
||||
|
@ -602,50 +609,50 @@ class Newsletter(object):
|
|||
return parameters
|
||||
|
||||
def build_text(self):
|
||||
from notification_handler import CustomFormatter
|
||||
from plexpy.notification_handler import CustomFormatter
|
||||
custom_formatter = CustomFormatter()
|
||||
|
||||
try:
|
||||
subject = custom_formatter.format(unicode(self.subject), **self.parameters)
|
||||
subject = custom_formatter.format(str(self.subject), **self.parameters)
|
||||
except LookupError as e:
|
||||
logger.error("Tautulli Newsletter :: Unable to parse parameter %s in newsletter subject. Using fallback." % e)
|
||||
subject = unicode(self._DEFAULT_SUBJECT).format(**self.parameters)
|
||||
subject = str(self._DEFAULT_SUBJECT).format(**self.parameters)
|
||||
except Exception as e:
|
||||
logger.error("Tautulli Newsletter :: Unable to parse custom newsletter subject: %s. Using fallback." % e)
|
||||
subject = unicode(self._DEFAULT_SUBJECT).format(**self.parameters)
|
||||
subject = str(self._DEFAULT_SUBJECT).format(**self.parameters)
|
||||
|
||||
try:
|
||||
body = custom_formatter.format(unicode(self.body), **self.parameters)
|
||||
body = custom_formatter.format(str(self.body), **self.parameters)
|
||||
except LookupError as e:
|
||||
logger.error("Tautulli Newsletter :: Unable to parse parameter %s in newsletter body. Using fallback." % e)
|
||||
body = unicode(self._DEFAULT_BODY).format(**self.parameters)
|
||||
body = str(self._DEFAULT_BODY).format(**self.parameters)
|
||||
except Exception as e:
|
||||
logger.error("Tautulli Newsletter :: Unable to parse custom newsletter body: %s. Using fallback." % e)
|
||||
body = unicode(self._DEFAULT_BODY).format(**self.parameters)
|
||||
body = str(self._DEFAULT_BODY).format(**self.parameters)
|
||||
|
||||
try:
|
||||
message = custom_formatter.format(unicode(self.message), **self.parameters)
|
||||
message = custom_formatter.format(str(self.message), **self.parameters)
|
||||
except LookupError as e:
|
||||
logger.error("Tautulli Newsletter :: Unable to parse parameter %s in newsletter message. Using fallback." % e)
|
||||
message = unicode(self._DEFAULT_MESSAGE).format(**self.parameters)
|
||||
message = str(self._DEFAULT_MESSAGE).format(**self.parameters)
|
||||
except Exception as e:
|
||||
logger.error("Tautulli Newsletter :: Unable to parse custom newsletter message: %s. Using fallback." % e)
|
||||
message = unicode(self._DEFAULT_MESSAGE).format(**self.parameters)
|
||||
message = str(self._DEFAULT_MESSAGE).format(**self.parameters)
|
||||
|
||||
return subject, body, message
|
||||
|
||||
def build_filename(self):
|
||||
from notification_handler import CustomFormatter
|
||||
from plexpy.notification_handler import CustomFormatter
|
||||
custom_formatter = CustomFormatter()
|
||||
|
||||
try:
|
||||
filename = custom_formatter.format(unicode(self.filename), **self.parameters)
|
||||
filename = custom_formatter.format(str(self.filename), **self.parameters)
|
||||
except LookupError as e:
|
||||
logger.error("Tautulli Newsletter :: Unable to parse parameter %s in newsletter filename. Using fallback." % e)
|
||||
filename = unicode(self._DEFAULT_FILENAME).format(**self.parameters)
|
||||
filename = str(self._DEFAULT_FILENAME).format(**self.parameters)
|
||||
except Exception as e:
|
||||
logger.error("Tautulli Newsletter :: Unable to parse custom newsletter subject: %s. Using fallback." % e)
|
||||
filename = unicode(self._DEFAULT_FILENAME).format(**self.parameters)
|
||||
filename = str(self._DEFAULT_FILENAME).format(**self.parameters)
|
||||
|
||||
return filename
|
||||
|
||||
|
@ -682,7 +689,7 @@ class RecentlyAdded(Newsletter):
|
|||
_TEMPLATE = 'recently_added.html'
|
||||
|
||||
def _get_recently_added(self, media_type=None):
|
||||
from notification_handler import format_group_index
|
||||
from plexpy.notification_handler import format_group_index
|
||||
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
|
||||
|
@ -798,7 +805,7 @@ class RecentlyAdded(Newsletter):
|
|||
return recently_added
|
||||
|
||||
def retrieve_data(self):
|
||||
from notification_handler import get_img_info, set_hash_image_info
|
||||
from plexpy.notification_handler import get_img_info, set_hash_image_info
|
||||
|
||||
if not self.config['incl_libraries']:
|
||||
logger.warn("Tautulli Newsletters :: Failed to retrieve %s newsletter data: no libraries selected." % self.NAME)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue