mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
Fix #1874.
While developing, if there's a second deluge package, installed globally and another in develop mode somewhere else, while pkg_resources.require("Deluge") returns the proper deluge instance, pkg_resources.resource_filename does not, it returns the first found on the python path, which is not good enough. Work around this issue.
This commit is contained in:
parent
087e94f6a1
commit
9e9261e6f8
2 changed files with 30 additions and 18 deletions
|
@ -69,21 +69,6 @@ import pkg_resources
|
||||||
import gettext
|
import gettext
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
# Initialize gettext
|
|
||||||
try:
|
|
||||||
if hasattr(locale, "bindtextdomain"):
|
|
||||||
locale.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n"))
|
|
||||||
if hasattr(locale, "textdomain"):
|
|
||||||
locale.textdomain("deluge")
|
|
||||||
gettext.bindtextdomain("deluge", pkg_resources.resource_filename("deluge", "i18n"))
|
|
||||||
gettext.textdomain("deluge")
|
|
||||||
gettext.install("deluge", pkg_resources.resource_filename("deluge", "i18n"))
|
|
||||||
except Exception, e:
|
|
||||||
log.error("Unable to initialize gettext/locale!")
|
|
||||||
log.exception(e)
|
|
||||||
import __builtin__
|
|
||||||
__builtin__.__dict__["_"] = lambda x: x
|
|
||||||
|
|
||||||
from deluge.error import *
|
from deluge.error import *
|
||||||
|
|
||||||
LT_TORRENT_STATE = {
|
LT_TORRENT_STATE = {
|
||||||
|
@ -220,8 +205,19 @@ def get_pixmap(fname):
|
||||||
:rtype: string
|
:rtype: string
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return pkg_resources.resource_filename("deluge", os.path.join("ui/data", \
|
return resource_filename("deluge", os.path.join("ui", "data", "pixmaps", fname))
|
||||||
"pixmaps", fname))
|
|
||||||
|
def resource_filename(package, path):
|
||||||
|
# While developing, if there's a second deluge package, installed globally
|
||||||
|
# and another in develop mode somewhere else, while pkg_resources.require("Deluge")
|
||||||
|
# returns the proper deluge instance, pkg_resources.resource_filename does
|
||||||
|
# not, it returns the first found on the python path, which is not good
|
||||||
|
# enough.
|
||||||
|
# This is a work-around that.
|
||||||
|
return pkg_resources.require("Deluge>=%s" % get_version())[0].get_resource_filename(
|
||||||
|
pkg_resources.resource_filename.im_self,
|
||||||
|
os.path.join(package, path)
|
||||||
|
)
|
||||||
|
|
||||||
def open_file(path):
|
def open_file(path):
|
||||||
"""
|
"""
|
||||||
|
@ -683,3 +679,20 @@ def create_localclient_account(append=False):
|
||||||
fd.flush()
|
fd.flush()
|
||||||
os.fsync(fd.fileno())
|
os.fsync(fd.fileno())
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
|
|
||||||
|
# Initialize gettext
|
||||||
|
try:
|
||||||
|
if hasattr(locale, "bindtextdomain"):
|
||||||
|
locale.bindtextdomain("deluge", resource_filename("deluge", "i18n"))
|
||||||
|
if hasattr(locale, "textdomain"):
|
||||||
|
locale.textdomain("deluge")
|
||||||
|
gettext.bindtextdomain("deluge", resource_filename("deluge", "i18n"))
|
||||||
|
gettext.textdomain("deluge")
|
||||||
|
gettext.install("deluge", resource_filename("deluge", "i18n"))
|
||||||
|
except Exception, e:
|
||||||
|
raise
|
||||||
|
log.error("Unable to initialize gettext/locale!")
|
||||||
|
log.exception(e)
|
||||||
|
import __builtin__
|
||||||
|
__builtin__.__dict__["_"] = lambda x: x
|
||||||
|
|
|
@ -45,7 +45,6 @@ import sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
import deluge.log
|
import deluge.log
|
||||||
#import deluge.common
|
|
||||||
import deluge.error
|
import deluge.error
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue