From 9e0153e9627544c1c9923e9cfddfd4d8f2017e43 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Sat, 4 Apr 2020 07:57:51 -0700 Subject: [PATCH] Set PYTHON2 global variable --- plexpy/__init__.py | 5 +++-- plexpy/activity_handler.py | 2 +- plexpy/activity_pinger.py | 2 +- plexpy/activity_processor.py | 2 +- plexpy/api2.py | 2 +- plexpy/classes.py | 2 +- plexpy/common.py | 2 +- plexpy/config.py | 2 +- plexpy/database.py | 2 +- plexpy/datafactory.py | 2 +- plexpy/datatables.py | 2 +- plexpy/graphs.py | 2 +- plexpy/helpers.py | 6 +++--- plexpy/http_handler.py | 2 +- plexpy/libraries.py | 2 +- plexpy/lock.py | 2 +- plexpy/log_reader.py | 2 +- plexpy/logger.py | 2 +- plexpy/mobile_app.py | 2 +- plexpy/newsletter_handler.py | 2 +- plexpy/newsletters.py | 2 +- plexpy/notification_handler.py | 6 +++--- plexpy/notifiers.py | 6 +++--- plexpy/plexivity_import.py | 2 +- plexpy/plextv.py | 2 +- plexpy/plexwatch_import.py | 2 +- plexpy/pmsconnect.py | 2 +- plexpy/request.py | 2 +- plexpy/session.py | 2 +- plexpy/users.py | 2 +- plexpy/versioncheck.py | 2 +- plexpy/web_socket.py | 2 +- plexpy/webauth.py | 2 +- plexpy/webserve.py | 2 +- plexpy/webstart.py | 2 +- 35 files changed, 43 insertions(+), 42 deletions(-) diff --git a/plexpy/__init__.py b/plexpy/__init__.py index 34fb6ce3..32575e29 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -37,9 +37,10 @@ from apscheduler.triggers.interval import IntervalTrigger from UniversalAnalytics import Tracker import pytz -PYTHON_VERSION = sys.version_info[0] +PYTHON_VERSION = sys.version_info[:3] +PYTHON2 = PYTHON_VERSION[0] == 2 -if PYTHON_VERSION < 3: +if PYTHON2: import activity_handler import activity_pinger import common diff --git a/plexpy/activity_handler.py b/plexpy/activity_handler.py index 47e055bf..bb3000e5 100644 --- a/plexpy/activity_handler.py +++ b/plexpy/activity_handler.py @@ -25,7 +25,7 @@ from apscheduler.triggers.date import DateTrigger import pytz import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import activity_processor import datafactory import helpers diff --git a/plexpy/activity_pinger.py b/plexpy/activity_pinger.py index 1bc0b947..d284dac8 100644 --- a/plexpy/activity_pinger.py +++ b/plexpy/activity_pinger.py @@ -20,7 +20,7 @@ import threading import time import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import activity_handler import activity_processor import database diff --git a/plexpy/activity_processor.py b/plexpy/activity_processor.py index d80f8bc7..51633948 100644 --- a/plexpy/activity_processor.py +++ b/plexpy/activity_processor.py @@ -22,7 +22,7 @@ import json import time import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import database import helpers import libraries diff --git a/plexpy/api2.py b/plexpy/api2.py index 7d13e2fb..e216d668 100644 --- a/plexpy/api2.py +++ b/plexpy/api2.py @@ -33,7 +33,7 @@ import cherrypy import xmltodict import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import config import database import helpers diff --git a/plexpy/classes.py b/plexpy/classes.py index 325a85c9..8480b952 100644 --- a/plexpy/classes.py +++ b/plexpy/classes.py @@ -25,7 +25,7 @@ from __future__ import unicode_literals from future.moves.urllib.request import FancyURLopener import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: from common import USER_AGENT else: from plexpy.common import USER_AGENT diff --git a/plexpy/common.py b/plexpy/common.py index 03c8096a..ab1a0501 100644 --- a/plexpy/common.py +++ b/plexpy/common.py @@ -22,7 +22,7 @@ import platform from collections import OrderedDict import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import version else: from plexpy import version diff --git a/plexpy/config.py b/plexpy/config.py index f917ecb5..7403cdb3 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -26,7 +26,7 @@ import time from configobj import ConfigObj import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import logger else: from plexpy import logger diff --git a/plexpy/database.py b/plexpy/database.py index 047f30c8..99e36315 100644 --- a/plexpy/database.py +++ b/plexpy/database.py @@ -24,7 +24,7 @@ import threading import time import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import logger else: from plexpy import logger diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 4a834452..334ca678 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -26,7 +26,7 @@ import json from itertools import groupby import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import common import database import datatables diff --git a/plexpy/datatables.py b/plexpy/datatables.py index a666a9fb..55056187 100644 --- a/plexpy/datatables.py +++ b/plexpy/datatables.py @@ -19,7 +19,7 @@ from future.builtins import object import re import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import database import helpers import logger diff --git a/plexpy/graphs.py b/plexpy/graphs.py index e32b11de..c2115302 100644 --- a/plexpy/graphs.py +++ b/plexpy/graphs.py @@ -23,7 +23,7 @@ from future.builtins import object import datetime import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import common import database import logger diff --git a/plexpy/helpers.py b/plexpy/helpers.py index 778186c1..7ea6d86e 100644 --- a/plexpy/helpers.py +++ b/plexpy/helpers.py @@ -60,7 +60,7 @@ from xml.dom import minidom import xmltodict import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import logger import request from api2 import API2 @@ -1265,10 +1265,10 @@ def split_args(args=None): if isinstance(args, list): return args elif isinstance(args, str): - if plexpy.PYTHON_VERSION < 3: + if plexpy.PYTHON2: args = args.encode('utf-8') args = shlex.split(args) - if plexpy.PYTHON_VERSION < 3: + if plexpy.PYTHON2: args = [a.decode('utf-8') for a in args] return args return [] diff --git a/plexpy/http_handler.py b/plexpy/http_handler.py index f38454a8..72ee46dd 100644 --- a/plexpy/http_handler.py +++ b/plexpy/http_handler.py @@ -27,7 +27,7 @@ import certifi import urllib3 import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import helpers import logger else: diff --git a/plexpy/libraries.py b/plexpy/libraries.py index d0a7abeb..a4135845 100644 --- a/plexpy/libraries.py +++ b/plexpy/libraries.py @@ -24,7 +24,7 @@ import json import os import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import common import database import datatables diff --git a/plexpy/lock.py b/plexpy/lock.py index 75c3cfd4..6cdc6800 100644 --- a/plexpy/lock.py +++ b/plexpy/lock.py @@ -23,7 +23,7 @@ import time import threading import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import logger else: from plexpy import logger diff --git a/plexpy/log_reader.py b/plexpy/log_reader.py index 579cec7b..76d8b23c 100644 --- a/plexpy/log_reader.py +++ b/plexpy/log_reader.py @@ -21,7 +21,7 @@ from io import open import os import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import helpers import logger else: diff --git a/plexpy/logger.py b/plexpy/logger.py index dc9fca3c..33c929d0 100644 --- a/plexpy/logger.py +++ b/plexpy/logger.py @@ -33,7 +33,7 @@ import threading import traceback import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: from helpers import is_public_ip from config import _BLACKLIST_KEYS, _WHITELIST_KEYS else: diff --git a/plexpy/mobile_app.py b/plexpy/mobile_app.py index aef6ab61..d9655ac5 100644 --- a/plexpy/mobile_app.py +++ b/plexpy/mobile_app.py @@ -21,7 +21,7 @@ from future.builtins import str import time import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import database import helpers import logger diff --git a/plexpy/newsletter_handler.py b/plexpy/newsletter_handler.py index a17f5813..5882579d 100644 --- a/plexpy/newsletter_handler.py +++ b/plexpy/newsletter_handler.py @@ -24,7 +24,7 @@ from apscheduler.triggers.cron import CronTrigger import email.utils import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import database import helpers import logger diff --git a/plexpy/newsletters.py b/plexpy/newsletters.py index 23a4b5d6..ae55787b 100644 --- a/plexpy/newsletters.py +++ b/plexpy/newsletters.py @@ -30,7 +30,7 @@ import os import re import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import common import database import helpers diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 8b9307da..bc176e44 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -42,7 +42,7 @@ import time import musicbrainzngs import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import activity_processor import common import database @@ -1785,7 +1785,7 @@ class CustomFormatter(Formatter): obj = self.convert_field(obj, conversion) # expand the format spec, if needed - if plexpy.PYTHON_VERSION < 3: + if plexpy.PYTHON2: format_spec = self._vformat(format_spec, args, kwargs, used_args, recursion_depth - 1) else: @@ -1804,7 +1804,7 @@ class CustomFormatter(Formatter): result.append(suffix) # result.append(self.format_field(obj, format_spec)) - if plexpy.PYTHON_VERSION < 3: + if plexpy.PYTHON2: return ''.join(result) else: return ''.join(result), auto_arg_index diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index 6f2715eb..1d534963 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -59,7 +59,7 @@ import facebook import twitter import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import common import database import helpers @@ -2814,7 +2814,7 @@ class SCRIPTS(Notifier): if self.pythonpath: custom_env['PYTHONPATH'] = os.pathsep.join([p for p in sys.path if p]) - if plexpy.PYTHON_VERSION < 3: + if plexpy.PYTHON2: custom_env = {k.encode('utf-8'): v.encode('utf-8') for k, v in custom_env.items()} env = os.environ.copy() @@ -2914,7 +2914,7 @@ class SCRIPTS(Notifier): script.extend(script_args) - if plexpy.PYTHON_VERSION < 3: + if plexpy.PYTHON2: script = [s.encode(plexpy.SYS_ENCODING, 'ignore') for s in script] logger.debug("Tautulli Notifiers :: Full script is: %s" % script) diff --git a/plexpy/plexivity_import.py b/plexpy/plexivity_import.py index 5621200d..6e51fa23 100644 --- a/plexpy/plexivity_import.py +++ b/plexpy/plexivity_import.py @@ -23,7 +23,7 @@ import sqlite3 from xml.dom import minidom import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import activity_pinger import activity_processor import database diff --git a/plexpy/plextv.py b/plexpy/plextv.py index 3cde51a5..8a047747 100644 --- a/plexpy/plextv.py +++ b/plexpy/plextv.py @@ -24,7 +24,7 @@ import base64 import json import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import common import helpers import http_handler diff --git a/plexpy/plexwatch_import.py b/plexpy/plexwatch_import.py index ef988568..e23975f6 100644 --- a/plexpy/plexwatch_import.py +++ b/plexpy/plexwatch_import.py @@ -22,7 +22,7 @@ import sqlite3 from xml.dom import minidom import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import activity_pinger import activity_processor import database diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 06725fbe..0d7c8463 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -26,7 +26,7 @@ import time from future.moves.urllib.parse import quote, quote_plus, urlencode import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import activity_processor import common import helpers diff --git a/plexpy/request.py b/plexpy/request.py index 8a1f913c..80323514 100644 --- a/plexpy/request.py +++ b/plexpy/request.py @@ -25,7 +25,7 @@ import collections import requests import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import lock import logger else: diff --git a/plexpy/session.py b/plexpy/session.py index 2334454a..c4346ede 100644 --- a/plexpy/session.py +++ b/plexpy/session.py @@ -21,7 +21,7 @@ from future.builtins import str import cherrypy import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import common import users else: diff --git a/plexpy/users.py b/plexpy/users.py index f451aa4e..f8ee47c0 100644 --- a/plexpy/users.py +++ b/plexpy/users.py @@ -24,7 +24,7 @@ import httpagentparser import time import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import common import database import datatables diff --git a/plexpy/versioncheck.py b/plexpy/versioncheck.py index 20917579..2bab630f 100644 --- a/plexpy/versioncheck.py +++ b/plexpy/versioncheck.py @@ -28,7 +28,7 @@ import subprocess import tarfile import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import common import logger import request diff --git a/plexpy/web_socket.py b/plexpy/web_socket.py index 43462ce0..700888b7 100644 --- a/plexpy/web_socket.py +++ b/plexpy/web_socket.py @@ -27,7 +27,7 @@ import time import websocket import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import activity_handler import activity_pinger import activity_processor diff --git a/plexpy/webauth.py b/plexpy/webauth.py index b32c9226..ed1785ec 100644 --- a/plexpy/webauth.py +++ b/plexpy/webauth.py @@ -30,7 +30,7 @@ from hashing_passwords import check_hash import jwt import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import logger from database import MonitorDatabase from users import Users, refresh_users diff --git a/plexpy/webserve.py b/plexpy/webserve.py index ecb5cc86..f0dfd2a4 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -41,7 +41,7 @@ import mako.exceptions import websocket import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import activity_pinger import common import config diff --git a/plexpy/webstart.py b/plexpy/webstart.py index 80d617dc..1b89b896 100644 --- a/plexpy/webstart.py +++ b/plexpy/webstart.py @@ -21,7 +21,7 @@ import sys import cherrypy import plexpy -if plexpy.PYTHON_VERSION < 3: +if plexpy.PYTHON2: import logger import webauth from helpers import create_https_certificates