From 048df31cf0ec358af0eaf01459c8bd08a4d5c8b9 Mon Sep 17 00:00:00 2001 From: JackDandy Date: Fri, 13 Jan 2023 13:12:43 +0000 Subject: [PATCH] Change prevent included py3 requests module failure on NZBGet systems that by default, run py2 with py2 requests. --- CHANGES.md | 1 + autoProcessTV/SickGear-NG/SickGear-NG.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 131a30e8..8dd14fac 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -27,6 +27,7 @@ * Update tmdbsimple 2.6.6 (679e343) to 2.9.1 (9da400a) * Update torrent_parser 0.3.0 (2a4eecb) to 0.4.0 (23b9e11) * Update unidecode module 1.1.1 (632af82) to 1.3.6 (4141992) +* Change prevent included py3 requests module failure on NZBGet systems that by default, run py2 with py2 requests * Change prevent included py3 requests module failure on SABnzbd systems that by default, run py2 with py2 requests diff --git a/autoProcessTV/SickGear-NG/SickGear-NG.py b/autoProcessTV/SickGear-NG/SickGear-NG.py index 27184a6b..9c41220d 100755 --- a/autoProcessTV/SickGear-NG/SickGear-NG.py +++ b/autoProcessTV/SickGear-NG/SickGear-NG.py @@ -51,7 +51,7 @@ # Send "Process Media" requests to SickGear # -# Process Media extension version: 2.7. +# Process Media extension version: 2.8. # @@ -444,13 +444,19 @@ if not sg_path or not Ek.ek(os.path.isdir, sg_path): sg_path = Ek.ek(os.path.dirname, Ek.ek(os.path.dirname, script_path)) except (BaseException, Exception): pass -if sg_path and Ek.ek(os.path.isdir, Ek.ek(os.path.join, sg_path, 'lib')): +if not PY2 and sg_path and Ek.ek(os.path.isdir, Ek.ek(os.path.join, sg_path, 'lib')): sys.path.insert(1, Ek.ek(os.path.join, sg_path, 'lib')) +py_msg = 'Python 3 %s be set to run python files instead of the current Python 2.' try: import requests + if PY2: + Logger.log(py_msg % 'should', Logger.WARNING) except ImportError: + if PY2: + Logger.log(py_msg % 'must', Logger.ERROR) + sys.exit(1) # Logger.log('You must set SickGear sg_base_path in script config or install python requests library', Logger.ERROR) Logger.log('You must install python requests library', Logger.ERROR) sys.exit(1)