Fix encoding of file paths
This commit is contained in:
parent
a1f4bc75e6
commit
dcd6756a7d
3 changed files with 20 additions and 22 deletions
|
@ -20,7 +20,6 @@ from os import path # allows to use path_ops.path.join, for example
|
|||
from distutils import dir_util
|
||||
import re
|
||||
|
||||
import xbmc
|
||||
import xbmcvfs
|
||||
|
||||
from .tools import unicode_paths
|
||||
|
@ -56,8 +55,7 @@ def translate_path(path):
|
|||
e.g. Converts 'special://masterprofile/script_data'
|
||||
-> '/home/user/XBMC/UserData/script_data' on Linux.
|
||||
"""
|
||||
translated = xbmc.translatePath(path.encode(KODI_ENCODING, 'strict'))
|
||||
return translated.decode(KODI_ENCODING, 'strict')
|
||||
return xbmcvfs.translatePath(path)
|
||||
|
||||
|
||||
def exists(path):
|
||||
|
@ -65,7 +63,7 @@ def exists(path):
|
|||
Returns True if the path [unicode] exists. Folders NEED a trailing slash or
|
||||
backslash!!
|
||||
"""
|
||||
return xbmcvfs.exists(path.encode(KODI_ENCODING, 'strict')) == 1
|
||||
return xbmcvfs.exists(path) == 1
|
||||
|
||||
|
||||
def rmtree(path, *args, **kwargs):
|
||||
|
@ -79,12 +77,12 @@ def rmtree(path, *args, **kwargs):
|
|||
is false and onerror is None, an exception is raised.
|
||||
|
||||
"""
|
||||
return shutil.rmtree(encode_path(path), *args, **kwargs)
|
||||
return shutil.rmtree(path, *args, **kwargs)
|
||||
|
||||
|
||||
def copyfile(src, dst):
|
||||
"""Copy data from src to dst"""
|
||||
return shutil.copyfile(encode_path(src), encode_path(dst))
|
||||
return shutil.copyfile(src, dst)
|
||||
|
||||
|
||||
def makedirs(path, *args, **kwargs):
|
||||
|
@ -94,7 +92,7 @@ def makedirs(path, *args, **kwargs):
|
|||
mkdir, except that any intermediate path segment (not just the rightmost)
|
||||
will be created if it does not exist. This is recursive.
|
||||
"""
|
||||
return os.makedirs(encode_path(path), *args, **kwargs)
|
||||
return os.makedirs(path, *args, **kwargs)
|
||||
|
||||
|
||||
def remove(path):
|
||||
|
@ -106,7 +104,7 @@ def remove(path):
|
|||
removed but the storage allocated to the file is not made available until
|
||||
the original file is no longer in use.
|
||||
"""
|
||||
return os.remove(encode_path(path))
|
||||
return os.remove(path)
|
||||
|
||||
|
||||
def walk(top, topdown=True, onerror=None, followlinks=False):
|
||||
|
@ -169,14 +167,14 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
|
|||
|
||||
"""
|
||||
# Get all the results from os.walk and store them in a list
|
||||
walker = list(os.walk(encode_path(top),
|
||||
walker = list(os.walk(top,
|
||||
topdown,
|
||||
onerror,
|
||||
followlinks))
|
||||
for top, dirs, nondirs in walker:
|
||||
yield (decode_path(top),
|
||||
[decode_path(x) for x in dirs],
|
||||
[decode_path(x) for x in nondirs])
|
||||
yield (top,
|
||||
[x for x in dirs],
|
||||
[x for x in nondirs])
|
||||
|
||||
|
||||
def copy_tree(src, dst, *args, **kwargs):
|
||||
|
@ -200,8 +198,6 @@ def copy_tree(src, dst, *args, **kwargs):
|
|||
(the default), the destination of the symlink will be copied.
|
||||
'update' and 'verbose' are the same as for 'copy_file'.
|
||||
"""
|
||||
src = encode_path(src)
|
||||
dst = encode_path(dst)
|
||||
return dir_util.copy_tree(src, dst, *args, **kwargs)
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import logging
|
||||
import sys
|
||||
import xbmc
|
||||
import xbmcvfs
|
||||
|
||||
from . import utils, clientinfo
|
||||
from . import initialsetup
|
||||
|
@ -37,7 +38,7 @@ class Service(object):
|
|||
def __init__(self):
|
||||
self._init_done = False
|
||||
# Detect switch of Kodi profile - a second instance of PKC is started
|
||||
self.profile = xbmc.translatePath('special://profile')
|
||||
self.profile = xbmcvfs.translatePath('special://profile')
|
||||
utils.window('plex_kodi_profilepath', value=self.profile)
|
||||
|
||||
# Kodi Version supported by PKC?
|
||||
|
|
|
@ -5,6 +5,7 @@ import sys
|
|||
import platform
|
||||
|
||||
import xbmc
|
||||
import xbmcvfs
|
||||
from xbmcaddon import Addon
|
||||
|
||||
from . import path_ops
|
||||
|
@ -41,13 +42,13 @@ ADDON_NAME = 'PlexKodiConnect'
|
|||
ADDON_ID = 'plugin.video.plexkodiconnect'
|
||||
ADDON_VERSION = _ADDON.getAddonInfo('version')
|
||||
ADDON_PATH = try_decode(_ADDON.getAddonInfo('path'))
|
||||
ADDON_FOLDER = try_decode(xbmc.translatePath('special://home'))
|
||||
ADDON_PROFILE = try_decode(xbmc.translatePath(_ADDON.getAddonInfo('profile')))
|
||||
ADDON_FOLDER = try_decode(xbmcvfs.translatePath('special://home'))
|
||||
ADDON_PROFILE = try_decode(xbmcvfs.translatePath(_ADDON.getAddonInfo('profile')))
|
||||
|
||||
KODILANGUAGE = xbmc.getLanguage(xbmc.ISO_639_1)
|
||||
KODIVERSION = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
|
||||
KODILONGVERSION = xbmc.getInfoLabel('System.BuildVersion')
|
||||
KODI_PROFILE = try_decode(xbmc.translatePath("special://profile"))
|
||||
KODI_PROFILE = try_decode(xbmcvfs.translatePath("special://profile"))
|
||||
|
||||
if xbmc.getCondVisibility('system.platform.osx'):
|
||||
DEVICE = "MacOSX"
|
||||
|
@ -120,10 +121,10 @@ DB_MUSIC_VERSION = None
|
|||
DB_MUSIC_PATH = None
|
||||
DB_TEXTURE_VERSION = None
|
||||
DB_TEXTURE_PATH = None
|
||||
DB_PLEX_PATH = try_decode(xbmc.translatePath("special://database/plex.db"))
|
||||
DB_PLEX_COPY_PATH = try_decode(xbmc.translatePath("special://database/plex-copy.db"))
|
||||
DB_PLEX_PATH = try_decode(xbmcvfs.translatePath("special://database/plex.db"))
|
||||
DB_PLEX_COPY_PATH = try_decode(xbmcvfs.translatePath("special://database/plex-copy.db"))
|
||||
|
||||
EXTERNAL_SUBTITLE_TEMP_PATH = try_decode(xbmc.translatePath(
|
||||
EXTERNAL_SUBTITLE_TEMP_PATH = try_decode(xbmcvfs.translatePath(
|
||||
"special://profile/addon_data/%s/temp/" % ADDON_ID))
|
||||
|
||||
|
||||
|
@ -698,7 +699,7 @@ def database_paths():
|
|||
if KODIVERSION not in (19, ):
|
||||
raise RuntimeError('Kodiversion %s not supported by PKC' % KODIVERSION)
|
||||
|
||||
database_path = try_decode(xbmc.translatePath('special://database'))
|
||||
database_path = try_decode(xbmcvfs.translatePath('special://database'))
|
||||
thismodule = sys.modules[__name__]
|
||||
types = (('MyVideos%s.db', SUPPORTED_VIDEO_DB,
|
||||
'DB_VIDEO_VERSION', 'DB_VIDEO_PATH'),
|
||||
|
|
Loading…
Reference in a new issue