Remove __cache__, __pcache__ and related code.

This commit is contained in:
Odd Stråbø 2019-07-14 19:33:27 +02:00
parent c574d7ceb3
commit 6bac723da3
8 changed files with 7 additions and 76 deletions

View file

@ -14,11 +14,7 @@ import xbmcaddon
__addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin')
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
__libraries__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'libraries')).decode('utf-8')
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'jellyfin')).decode('utf-8')
__cache__ = xbmc.translatePath('special://temp/jellyfin').decode('utf-8')
sys.path.insert(0, __cache__)
sys.path.insert(0, __pcache__)
sys.path.insert(0, __libraries__)
sys.path.append(__base__)

View file

@ -14,11 +14,7 @@ import xbmcaddon
__addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin')
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
__libraries__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'libraries')).decode('utf-8')
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'jellyfin')).decode('utf-8')
__cache__ = xbmc.translatePath('special://temp/jellyfin').decode('utf-8')
sys.path.insert(0, __cache__)
sys.path.insert(0, __pcache__)
sys.path.insert(0, __libraries__)
sys.path.append(__base__)

View file

@ -14,11 +14,7 @@ import xbmcaddon
__addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin')
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
__libraries__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'libraries')).decode('utf-8')
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'jellyfin')).decode('utf-8')
__cache__ = xbmc.translatePath('special://temp/jellyfin').decode('utf-8')
sys.path.insert(0, __cache__)
sys.path.insert(0, __pcache__)
sys.path.insert(0, __libraries__)
sys.path.append(__base__)

View file

@ -12,7 +12,6 @@ import xbmc
import xbmcvfs
import jellyfin_db
from helper.utils import delete_folder
from helper import _, settings, window, dialog
from objects import obj

View file

@ -5,15 +5,10 @@
import logging
import Queue
import threading
import os
import xbmc
import xbmcvfs
import xbmcaddon
import requests
from helper.utils import delete_folder
from helper import settings, stop, event, window, unzip, create_id
from helper import settings, stop, event, window, create_id
from jellyfin import Jellyfin
from jellyfin.core import api
from jellyfin.core.exceptions import HTTPException
@ -22,7 +17,6 @@ from jellyfin.core.exceptions import HTTPException
LOG = logging.getLogger("JELLYFIN."+__name__)
LIMIT = min(int(settings('limitIndex') or 50), 50)
CACHE = xbmc.translatePath(os.path.join(xbmcaddon.Addon(id='plugin.video.jellyfin').getAddonInfo('profile').decode('utf-8'), 'jellyfin')).decode('utf-8')
#################################################################################################
@ -372,40 +366,3 @@ class TheVoid(object):
xbmc.sleep(100)
LOG.info("--[ void/%s ]", self.data['VoidName'])
def get_objects(src, filename):
''' Download objects dependency to temp cache folder.
'''
temp = CACHE
restart = not xbmcvfs.exists(os.path.join(temp, "objects") + '/')
path = os.path.join(temp, filename).encode('utf-8')
if restart and (settings('appliedPatch') or "") == filename:
LOG.warn("Something went wrong applying this patch %s previously.", filename)
restart = False
if not xbmcvfs.exists(path) or filename.startswith('DEV'):
delete_folder(CACHE)
LOG.info("From %s to %s", src, path.decode('utf-8'))
try:
response = requests.get(src, stream=True, verify=True)
response.raise_for_status()
except requests.exceptions.SSLError as error:
LOG.error(error)
response = requests.get(src, stream=True, verify=False)
dl = xbmcvfs.File(path, 'w')
dl.write(response.content)
dl.close()
del response
settings('appliedPatch', filename)
unzip(path, temp, "objects")
return restart

View file

@ -17,10 +17,8 @@ import client
import library
import setup
import monitor
import requests
from views import Views, verify_kodi_defaults
from helper import _, window, settings, event, dialog, find, compare_version
from downloader import get_objects
from helper import _, window, settings, event, dialog, compare_version
from jellyfin import Jellyfin
from database import Database, jellyfin_db, reset

View file

@ -277,13 +277,12 @@ def write_xml(content, file):
content = content.replace('?>', ' standalone="yes" ?>', 1)
infile.write(content)
def delete_folder(path=None):
def delete_folder(path):
''' Delete objects from kodi cache
'''
LOG.debug("--[ delete folder ]")
delete_path = path is not None
path = path or xbmc.translatePath('special://temp/jellyfin').decode('utf-8')
dirs, files = xbmcvfs.listdir(path)
delete_recursive(path, dirs)
@ -291,11 +290,11 @@ def delete_folder(path=None):
for file in files:
xbmcvfs.delete(os.path.join(path, file.decode('utf-8')))
if delete_path:
xbmcvfs.delete(path)
xbmcvfs.delete(path)
LOG.info("DELETE %s", path)
def delete_recursive(path, dirs):
''' Delete files and dirs recursively.
@ -309,6 +308,7 @@ def delete_recursive(path, dirs):
delete_recursive(os.path.join(path, directory.decode('utf-8')), dirs2)
xbmcvfs.rmdir(os.path.join(path, directory.decode('utf-8')))
def unzip(path, dest, folder=None):
''' Unzip file. zipfile module seems to fail on android with badziperror.

View file

@ -8,7 +8,6 @@ import threading
import sys
import xbmc
import xbmcvfs
import xbmcaddon
#################################################################################################
@ -16,18 +15,8 @@ import xbmcaddon
__addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin')
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
__libraries__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'libraries')).decode('utf-8')
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'jellyfin')).decode('utf-8')
__cache__ = xbmc.translatePath('special://temp/jellyfin').decode('utf-8')
sys.path.insert(0, __libraries__)
if not xbmcvfs.exists(__pcache__ + '/'):
from resources.lib.helper.utils import copytree
copytree(os.path.join(__base__, 'objects'), os.path.join(__pcache__, 'objects'))
sys.path.insert(0, __cache__)
sys.path.insert(0, __pcache__)
sys.path.append(__base__)
#################################################################################################