mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 05:13:16 -07:00
Fix sys.setdefaultencoding in Python 3
This does away with the setdefaultencoding hack in Python 3
This commit is contained in:
parent
6992a9c66e
commit
02ae99b117
1 changed files with 16 additions and 14 deletions
|
@ -31,6 +31,7 @@ CONFIG_TV_FILE = os.path.join(PROGRAM_DIR, 'autoProcessTv.cfg')
|
||||||
TEST_FILE = os.path.join(os.path.join(PROGRAM_DIR, 'tests'), 'test.mp4')
|
TEST_FILE = os.path.join(os.path.join(PROGRAM_DIR, 'tests'), 'test.mp4')
|
||||||
MYAPP = None
|
MYAPP = None
|
||||||
|
|
||||||
|
import six
|
||||||
from six.moves import reload_module
|
from six.moves import reload_module
|
||||||
|
|
||||||
from core.autoProcess.autoProcessComics import autoProcessComics
|
from core.autoProcess.autoProcessComics import autoProcessComics
|
||||||
|
@ -269,21 +270,22 @@ def initialize(section=None):
|
||||||
if not SYS_ENCODING or SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
|
if not SYS_ENCODING or SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
|
||||||
SYS_ENCODING = 'UTF-8'
|
SYS_ENCODING = 'UTF-8'
|
||||||
|
|
||||||
if not hasattr(sys, "setdefaultencoding"):
|
if six.PY2:
|
||||||
reload_module(sys)
|
if not hasattr(sys, "setdefaultencoding"):
|
||||||
|
reload_module(sys)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# pylint: disable=E1101
|
# pylint: disable=E1101
|
||||||
# On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
|
# On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
|
||||||
sys.setdefaultencoding(SYS_ENCODING)
|
sys.setdefaultencoding(SYS_ENCODING)
|
||||||
except:
|
except:
|
||||||
print('Sorry, you MUST add the nzbToMedia folder to the PYTHONPATH environment variable'
|
print('Sorry, you MUST add the nzbToMedia folder to the PYTHONPATH environment variable'
|
||||||
'\nor find another way to force Python to use {codec} for string encoding.'.format
|
'\nor find another way to force Python to use {codec} for string encoding.'.format
|
||||||
(codec=SYS_ENCODING))
|
(codec=SYS_ENCODING))
|
||||||
if 'NZBOP_SCRIPTDIR' in os.environ:
|
if 'NZBOP_SCRIPTDIR' in os.environ:
|
||||||
sys.exit(NZBGET_POSTPROCESS_ERROR)
|
sys.exit(NZBGET_POSTPROCESS_ERROR)
|
||||||
else:
|
else:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# init logging
|
# init logging
|
||||||
logger.ntm_log_instance.initLogging()
|
logger.ntm_log_instance.initLogging()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue