mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 18:26:15 +00:00
Merge pull request #286 from oddstr13/pr-file-encoding-android-1
Handle sys.getfilesystemencoding() returning None
This commit is contained in:
commit
7368265e2f
4 changed files with 20 additions and 7 deletions
|
@ -21,6 +21,7 @@ from .utils import create_id
|
|||
from .utils import convert_to_local as Local
|
||||
from .utils import has_attribute
|
||||
from .utils import set_addon_mode
|
||||
from .utils import get_filesystem_encoding
|
||||
|
||||
from .wrapper import progress
|
||||
from .wrapper import catch
|
||||
|
|
|
@ -4,14 +4,14 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
##################################################################################################
|
||||
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from six import ensure_text
|
||||
|
||||
from kodi_six import xbmc, xbmcaddon
|
||||
|
||||
import database
|
||||
from helper import get_filesystem_encoding
|
||||
|
||||
from . import settings
|
||||
|
||||
|
@ -90,7 +90,7 @@ class MyFormatter(logging.Formatter):
|
|||
|
||||
def format(self, record):
|
||||
if record.pathname:
|
||||
record.pathname = ensure_text(record.pathname, sys.getfilesystemencoding())
|
||||
record.pathname = ensure_text(record.pathname, get_filesystem_encoding())
|
||||
|
||||
self._gen_rel_path(record)
|
||||
|
||||
|
@ -104,7 +104,7 @@ class MyFormatter(logging.Formatter):
|
|||
res = []
|
||||
|
||||
for o in traceback.format_exception(*exc_info):
|
||||
o = ensure_text(o, sys.getfilesystemencoding())
|
||||
o = ensure_text(o, get_filesystem_encoding())
|
||||
|
||||
if o.startswith(' File "'):
|
||||
# If this split can't handle your file names, you should seriously consider renaming your files.
|
||||
|
|
|
@ -6,6 +6,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
import binascii
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import unicodedata
|
||||
from uuid import uuid4
|
||||
|
@ -488,3 +489,15 @@ class JsonDebugPrinter(object):
|
|||
|
||||
def __str__(self):
|
||||
return json.dumps(self.data, indent=4)
|
||||
|
||||
|
||||
def get_filesystem_encoding():
|
||||
enc = sys.getfilesystemencoding()
|
||||
|
||||
if not enc:
|
||||
enc = sys.getdefaultencoding()
|
||||
|
||||
if not enc or enc == 'ascii':
|
||||
enc = 'utf-8'
|
||||
|
||||
return enc
|
||||
|
|
|
@ -5,11 +5,10 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
from six import iteritems, ensure_text
|
||||
|
||||
from helper import LazyLogger
|
||||
from helper import LazyLogger, get_filesystem_encoding
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
@ -34,7 +33,7 @@ class Objects(object):
|
|||
|
||||
''' Load objects mapping.
|
||||
'''
|
||||
file_dir = os.path.dirname(ensure_text(__file__, sys.getfilesystemencoding()))
|
||||
file_dir = os.path.dirname(ensure_text(__file__, get_filesystem_encoding()))
|
||||
|
||||
with open(os.path.join(file_dir, 'obj_map.json')) as infile:
|
||||
self.objects = json.load(infile)
|
||||
|
|
Loading…
Reference in a new issue