More rename, more -python2

This commit is contained in:
2021-02-05 17:29:23 +01:00
parent b867dc9be2
commit 1df28243c3
40 changed files with 1424 additions and 1412 deletions

View File

@@ -15,14 +15,8 @@
# 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 unicode_literals
from future.builtins import next
from future.builtins import object
from future.builtins import str
from backports import csv
from io import open, BytesIO
import base64
import csv
import json
import linecache
import os
@@ -30,88 +24,52 @@ import shutil
import sys
import threading
import zipfile
from future.moves.urllib.parse import urlencode
from io import open, BytesIO
import cherrypy
import mako.exceptions
import mako.template
import websocket
from cherrypy import NotFound
from cherrypy.lib.static import serve_file, serve_fileobj, serve_download
from cherrypy._cperror import NotFound
from hashing_passwords import make_hash
from mako.lookup import TemplateLookup
import mako.template
import mako.exceptions
import websocket
import jellypy
if jellypy.PYTHON2:
import activity_pinger
import common
import config
import database
import datafactory
import exporter
import graphs
import helpers
import http_handler
import libraries
import log_reader
import logger
import newsletter_handler
import newsletters
import mobile_app
import notification_handler
import notifiers
import plextv
import plexivity_import
import plexwatch_import
import pmsconnect
import users
import versioncheck
import web_socket
import webstart
from api2 import API2
from helpers import checked, addtoapi, get_ip, create_https_certificates, build_datatables_json, sanitize_out
from session import get_session_info, get_session_user_id, allow_session_user, allow_session_library
from webauth import AuthController, requireAuth, member_of, check_auth
if common.PLATFORM == 'Windows':
import windows
elif common.PLATFORM == 'Darwin':
import macos
else:
from jellypy import activity_pinger
from jellypy import common
from jellypy import config
from jellypy import database
from jellypy import datafactory
from jellypy import exporter
from jellypy import graphs
from jellypy import helpers
from jellypy import http_handler
from jellypy import libraries
from jellypy import log_reader
from jellypy import logger
from jellypy import newsletter_handler
from jellypy import newsletters
from jellypy import mobile_app
from jellypy import notification_handler
from jellypy import notifiers
from jellypy import plextv
from jellypy import plexivity_import
from jellypy import plexwatch_import
from jellypy import pmsconnect
from jellypy import users
from jellypy import versioncheck
from jellypy import web_socket
from jellypy import webstart
from jellypy.api2 import API2
from jellypy.helpers import checked, addtoapi, get_ip, create_https_certificates, build_datatables_json, sanitize_out
from jellypy.session import get_session_info, get_session_user_id, allow_session_user, allow_session_library
from jellypy.webauth import AuthController, requireAuth, member_of, check_auth
if common.PLATFORM == 'Windows':
from jellypy import windows
elif common.PLATFORM == 'Darwin':
from jellypy import macos
from jellypy import activity_pinger
from jellypy import common
from jellypy import config
from jellypy import database
from jellypy import datafactory
from jellypy import exporter
from jellypy import graphs
from jellypy import helpers
from jellypy import http_handler
from jellypy import libraries
from jellypy import log_reader
from jellypy import logger
from jellypy import newsletter_handler
from jellypy import newsletters
from jellypy import mobile_app
from jellypy import notification_handler
from jellypy import notifiers
from jellypy import plextv
from jellypy import plexivity_import
from jellypy import plexwatch_import
from jellypy import pmsconnect
from jellypy import users
from jellypy import versioncheck
from jellypy import web_socket
from jellypy import webstart
from jellypy.api2 import API2
from jellypy.helpers import checked, addtoapi, get_ip, create_https_certificates, build_datatables_json, sanitize_out
from jellypy.session import get_session_info, get_session_user_id, allow_session_user, allow_session_library
from jellypy.webauth import AuthController, requireAuth, member_of, check_auth
if common.PLATFORM == 'Windows':
from jellypy import windows
elif common.PLATFORM == 'Darwin':
from jellypy import macos
def serve_template(templatename, **kwargs):
@@ -181,7 +139,6 @@ class BaseRedirect(object):
class WebInterface(object):
auth = AuthController()
def __init__(self):
@@ -195,7 +152,6 @@ class WebInterface(object):
else:
raise cherrypy.HTTPRedirect(jellypy.HTTP_ROOT + "welcome")
##### Welcome #####
@cherrypy.expose
@@ -265,7 +221,6 @@ class WebInterface(object):
if servers_list:
return servers_list
##### Home #####
@cherrypy.expose
@@ -455,7 +410,6 @@ class WebInterface(object):
else:
return {'result': 'error', 'message': 'Flush recently added failed.'}
##### Libraries #####
@cherrypy.expose
@@ -741,7 +695,8 @@ class WebInterface(object):
result = None
if result:
return serve_template(templatename="library_recently_added.html", data=result['recently_added'], title="Recently Added")
return serve_template(templatename="library_recently_added.html", data=result['recently_added'],
title="Recently Added")
else:
logger.warn("Unable to retrieve data for library_recently_added.")
return serve_template(templatename="library_recently_added.html", data=None, title="Recently Added")
@@ -1170,7 +1125,7 @@ class WebInterface(object):
result = library_data.undelete(section_id=section_id, section_name=section_name)
if result:
if section_id:
msg ='section_id %s' % section_id
msg = 'section_id %s' % section_id
elif section_name:
msg = 'section_name %s' % section_name
return {'result': 'success', 'message': 'Re-added library with %s.' % msg}
@@ -1356,7 +1311,8 @@ class WebInterface(object):
result = None
status_message = 'An error occured.'
return serve_template(templatename="edit_user.html", title="Edit User", data=result, status_message=status_message)
return serve_template(templatename="edit_user.html", title="Edit User", data=result,
status_message=status_message)
@cherrypy.expose
@requireAuth(member_of("admin"))
@@ -1801,13 +1757,12 @@ class WebInterface(object):
result = user_data.undelete(user_id=user_id, username=username)
if result:
if user_id:
msg ='user_id %s' % user_id
msg = 'user_id %s' % user_id
elif username:
msg = 'username %s' % username
return {'result': 'success', 'message': 'Re-added user with %s.' % msg}
return {'result': 'error', 'message': 'Unable to re-add user. Invalid user_id or username.'}
##### History #####
@cherrypy.expose
@@ -2093,7 +2048,6 @@ class WebInterface(object):
else:
return {'result': 'error', 'message': 'No row ids received.'}
##### Graphs #####
@cherrypy.expose
@@ -2570,7 +2524,8 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_stream_type_by_top_10_platforms(self, time_range='30', y_axis='plays', user_id=None, grouping=None, **kwargs):
def get_stream_type_by_top_10_platforms(self, time_range='30', y_axis='plays', user_id=None, grouping=None,
**kwargs):
""" Get graph data by stream type by top 10 platforms.
```
@@ -2617,7 +2572,6 @@ class WebInterface(object):
return serve_template(templatename="history_table_modal.html", title="History Data", data=kwargs)
##### Sync #####
@cherrypy.expose
@@ -2673,7 +2627,6 @@ class WebInterface(object):
else:
return {'result': 'error', 'message': 'Missing client ID and sync ID.'}
##### Logs #####
@cherrypy.expose
@requireAuth(member_of("admin"))
@@ -3026,9 +2979,9 @@ class WebInterface(object):
def log_js_errors(self, page, message, file, line, **kwargs):
""" Logs javascript errors from the web interface. """
logger.error("WebUI :: /%s : %s. (%s:%s)" % (page.rpartition('/')[-1],
message,
file.rpartition('/')[-1].partition('?')[0],
line))
message,
file.rpartition('/')[-1].partition('?')[0],
line))
return "js error logged."
@cherrypy.expose
@@ -3047,7 +3000,6 @@ class WebInterface(object):
except IOError as e:
return "Log file not found."
##### Settings #####
@cherrypy.expose
@@ -3525,9 +3477,9 @@ class WebInterface(object):
result = notifiers.get_notifier_config(notifier_id=notifier_id, mask_passwords=True)
parameters = [
{'name': param['name'], 'type': param['type'], 'value': param['value']}
for category in common.NOTIFICATION_PARAMETERS for param in category['parameters']
]
{'name': param['name'], 'type': param['type'], 'value': param['value']}
for category in common.NOTIFICATION_PARAMETERS for param in category['parameters']
]
return serve_template(templatename="notifier_config.html", notifier=result, parameters=parameters)
@@ -3646,7 +3598,8 @@ class WebInterface(object):
@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))
def send_notification(self, notifier_id=None, subject='Tautulli', body='Test notification', notify_action='', **kwargs):
def send_notification(self, notifier_id=None, subject='Tautulli', body='Test notification', notify_action='',
**kwargs):
""" Send a notification using Tautulli.
```
@@ -3713,7 +3666,8 @@ class WebInterface(object):
redirect_uri=redirect_uri)
if url:
return {'result': 'success', 'msg': 'Confirm Authorization. Check pop-up blocker if no response.', 'url': url}
return {'result': 'success', 'msg': 'Confirm Authorization. Check pop-up blocker if no response.',
'url': url}
else:
return {'result': 'error', 'msg': 'Failed to retrieve authorization url.'}
@@ -3727,8 +3681,8 @@ class WebInterface(object):
if access_token:
return "Facebook authorization successful. Tautulli can send notification to Facebook. " \
"Your Facebook access token is:" \
"<pre>{0}</pre>You may close this page.".format(access_token)
"Your Facebook access token is:" \
"<pre>{0}</pre>You may close this page.".format(access_token)
else:
return "Failed to request authorization from Facebook. Check the Tautulli logs for details.<br />You may close this page."
@@ -3807,7 +3761,6 @@ class WebInterface(object):
else:
return {'result': 'error', 'message': 'Device not registered.'}
@cherrypy.expose
@requireAuth(member_of("admin"))
def get_mobile_device_config_modal(self, mobile_device_id=None, **kwargs):
@@ -4240,7 +4193,8 @@ class WebInterface(object):
@requireAuth(member_of("admin"))
def generate_api_key(self, device=None, **kwargs):
apikey = ''
while not apikey or apikey == jellypy.CONFIG.API_KEY or mobile_app.get_mobile_device_by_token(device_token=apikey):
while not apikey or apikey == jellypy.CONFIG.API_KEY or mobile_app.get_mobile_device_by_token(
device_token=apikey):
apikey = jellypy.generate_uuid()
logger.info("New API key generated.")
@@ -4739,7 +4693,6 @@ class WebInterface(object):
else:
return "Plex log folder not set in the settings."
if log_file and os.path.isfile(log_file_path):
return serve_download(log_file_path, name=log_file)
else:
@@ -4847,7 +4800,6 @@ class WebInterface(object):
else:
return {'result': 'error', 'message': 'Failed to delete lookup info.'}
##### Search #####
@cherrypy.expose
@@ -4915,7 +4867,6 @@ class WebInterface(object):
logger.warn("Unable to retrieve data for get_search_results_children.")
return serve_template(templatename="info_search_results_list.html", data=None, title="Search Result List")
##### Update Metadata #####
@cherrypy.expose
@@ -5304,7 +5255,8 @@ class WebInterface(object):
media_type = kwargs['type']
pms_connect = pmsconnect.PmsConnect()
result = pms_connect.get_recently_added_details(start=start, count=count, media_type=media_type, section_id=section_id)
result = pms_connect.get_recently_added_details(start=start, count=count, media_type=media_type,
section_id=section_id)
if result:
return result
@@ -6411,7 +6363,7 @@ class WebInterface(object):
subject=subject,
body=body,
message=message,
**kwargs)
**kwargs)
return {'result': 'success', 'message': 'Newsletter queued.'}
else:
logger.debug("Unable to send %snewsletter, invalid newsletter_id %s." % (test, newsletter_id))
@@ -6897,7 +6849,6 @@ class WebInterface(object):
else:
return {'result': 'error', 'message': 'Failed to delete export.'}
@cherrypy.expose
@requireAuth(member_of("admin"))
def exporter_docs(self, **kwargs):