[Plugins] Replace pkg_resources for abspath and decode path

- Use a BASE_PATH constant.
 - pkg_resources caches the files in python_egg_cache which is not
   required for plugins and causes issues with non-ascii paths.
This commit is contained in:
Calum Lind 2017-03-17 12:45:25 +00:00
commit 85364dc8ab
11 changed files with 57 additions and 33 deletions

View file

@ -14,10 +14,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from os.path import join import os.path
from deluge.common import resource_filename from deluge.common import decode_bytes
BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__)))
def get_resource(filename): def get_resource(filename):
return resource_filename('deluge.plugins.autoadd', join('data', filename)) return os.path.join(BASE_PATH, 'data', filename)

View file

@ -9,15 +9,17 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import os.path
from functools import wraps from functools import wraps
from os.path import join
from sys import exc_info from sys import exc_info
from deluge.common import resource_filename from deluge.common import decode_bytes
BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__)))
def get_resource(filename): def get_resource(filename):
return resource_filename('deluge.plugins.blocklist', join('data', filename)) return os.path.join(BASE_PATH, 'data', filename)
def raises_errors_as(error): def raises_errors_as(error):

View file

@ -9,10 +9,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from os.path import join import os.path
from deluge.common import resource_filename from deluge.common import decode_bytes
BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__)))
def get_resource(filename): def get_resource(filename):
return resource_filename('deluge.plugins.execute', join('data', filename)) return os.path.join(BASE_PATH, 'data', filename)

View file

@ -9,10 +9,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from os.path import join import os.path
from deluge.common import resource_filename from deluge.common import decode_bytes
BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__)))
def get_resource(filename): def get_resource(filename):
return resource_filename('deluge.plugins.extractor', join('data', filename)) return os.path.join(BASE_PATH, 'data', filename)

View file

@ -9,10 +9,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from os.path import join import os.path
from deluge.common import resource_filename from deluge.common import decode_bytes
BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__)))
def get_resource(filename): def get_resource(filename):
return resource_filename('deluge.plugins.label', join('data', filename)) return os.path.join(BASE_PATH, 'data', filename)

View file

@ -15,19 +15,21 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import logging import logging
from os.path import join import os.path
from twisted.internet import defer from twisted.internet import defer
from deluge import component from deluge import component
from deluge.common import resource_filename from deluge.common import decode_bytes
from deluge.event import known_events from deluge.event import known_events
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__)))
def get_resource(filename): def get_resource(filename):
return resource_filename('deluge.plugins.notifications', join('data', filename)) return os.path.join(BASE_PATH, 'data', filename)
class CustomNotifications(object): class CustomNotifications(object):

View file

@ -13,10 +13,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from os.path import join import os.path
from deluge.common import resource_filename from deluge.common import decode_bytes
BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__)))
def get_resource(filename): def get_resource(filename):
return resource_filename('deluge.plugins.scheduler', join('data', filename)) return os.path.join(BASE_PATH, 'data', filename)

View file

@ -9,10 +9,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from os.path import join import os.path
from deluge.common import resource_filename from deluge.common import decode_bytes
BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__)))
def get_resource(filename): def get_resource(filename):
return resource_filename('deluge.plugins.stats', join('data', filename)) return os.path.join(BASE_PATH, 'data', filename)

View file

@ -14,10 +14,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from os.path import join import os.path
from deluge.common import resource_filename from deluge.common import decode_bytes
BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__)))
def get_resource(filename): def get_resource(filename):
return resource_filename('deluge.plugins.toggle', join('data', filename)) return os.path.join(BASE_PATH, 'data', filename)

View file

@ -13,10 +13,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from os.path import join import os.path
from deluge.common import resource_filename from deluge.common import decode_bytes
BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__)))
def get_resource(filename): def get_resource(filename):
return resource_filename('deluge.plugins.webui', join('data', filename)) return os.path.join(BASE_PATH, 'data', filename)

View file

@ -210,12 +210,16 @@ COMMON = """
from __future__ import unicode_literals from __future__ import unicode_literals
from os.path import join import os.path
from deluge.common import decode_bytes
BASE_PATH = decode_bytes(os.path.abspath(os.path.dirname(__file__)))
from deluge.common import resource_filename
def get_resource(filename): def get_resource(filename):
return resource_filename('deluge.plugins.%(safe_name)s', join('data', filename)) return os.path.join(BASE_PATH, 'data', filename)
""" """
GTKUI = """ GTKUI = """