From 3e10e0e5113ca0e80c9d65e3f8a66550a29821c2 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Mon, 27 Apr 2020 19:03:45 -0700 Subject: [PATCH] Python 2 compatible Windows imports --- plexpy/windows.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plexpy/windows.py b/plexpy/windows.py index 6f588c75..ced93c5c 100644 --- a/plexpy/windows.py +++ b/plexpy/windows.py @@ -16,10 +16,18 @@ # along with Tautulli. If not, see . import os -import shlex import sys from systray import SysTrayIcon -import winreg + +try: + from shlex import quote as cmd_quote +except ImportError: + from pipes import quote as cmd_quote + +try: + import winreg +except ImportError: + import _winreg as winreg import plexpy if plexpy.PYTHON2: @@ -127,7 +135,7 @@ def set_startup(): else: args = [exe, plexpy.FULL_PATH] - cmd = ' '.join(shlex.quote(arg) for arg in args).replace('python.exe', 'pythonw.exe').replace("'", '"') + cmd = ' '.join(cmd_quote(arg) for arg in args).replace('python.exe', 'pythonw.exe').replace("'", '"') if plexpy.CONFIG.LAUNCH_STARTUP: try: