[GTK] Fix showing correct error on libtorrent import error
The exception string "No module named libtorrent" was changed to "No module named 'libtorrent'" in python 3.3, which results in a "unknown Import Error" message being displayed instead of the message meant for libtorrent import error. Change to raising LibtorrentImportError in _libtorrent.py and catch this error to display libtorrent specific import errors.
This commit is contained in:
parent
d6c96d6291
commit
3519f341d4
|
@ -18,16 +18,21 @@ Example:
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from deluge.common import VersionSplit, get_version
|
||||
from deluge.error import LibtorrentImportError
|
||||
|
||||
try:
|
||||
import deluge.libtorrent as lt
|
||||
except ImportError:
|
||||
import libtorrent as lt
|
||||
try:
|
||||
import libtorrent as lt
|
||||
except ImportError as ex:
|
||||
raise LibtorrentImportError('No libtorrent library found: %s' % (ex))
|
||||
|
||||
|
||||
REQUIRED_VERSION = '1.1.2.0'
|
||||
LT_VERSION = lt.__version__
|
||||
|
||||
if VersionSplit(LT_VERSION) < VersionSplit(REQUIRED_VERSION):
|
||||
raise ImportError(
|
||||
raise LibtorrentImportError(
|
||||
'Deluge %s requires libtorrent >= %s' % (get_version(), REQUIRED_VERSION)
|
||||
)
|
||||
|
|
|
@ -94,3 +94,7 @@ class AuthenticationRequired(_UsernameBasedPasstroughError):
|
|||
|
||||
class AuthManagerError(_UsernameBasedPasstroughError):
|
||||
pass
|
||||
|
||||
|
||||
class LibtorrentImportError(ImportError):
|
||||
pass
|
||||
|
|
|
@ -45,7 +45,7 @@ from deluge.common import (
|
|||
windows_check,
|
||||
)
|
||||
from deluge.configmanager import ConfigManager, get_config_dir
|
||||
from deluge.error import DaemonRunningError
|
||||
from deluge.error import DaemonRunningError, LibtorrentImportError
|
||||
from deluge.i18n import I18N_DOMAIN, set_language, setup_translation
|
||||
from deluge.ui.client import client
|
||||
from deluge.ui.hostlist import LOCALHOST
|
||||
|
@ -313,8 +313,8 @@ class GtkUI(object):
|
|||
'A Deluge daemon (deluged) is already running.\n'
|
||||
'To use Standalone mode, stop local daemon and restart Deluge.'
|
||||
)
|
||||
except ImportError as ex:
|
||||
if 'No module named libtorrent' in str(ex):
|
||||
except LibtorrentImportError as ex:
|
||||
if 'libtorrent library not found' in str(ex):
|
||||
err_msg = _(
|
||||
'Only Thin Client mode is available because libtorrent is not installed.\n'
|
||||
'To use Standalone mode, please install libtorrent package.'
|
||||
|
@ -322,9 +322,17 @@ class GtkUI(object):
|
|||
else:
|
||||
log.exception(ex)
|
||||
err_msg = _(
|
||||
'Only Thin Client mode is available due to unknown Import Error.\n'
|
||||
'Only Thin Client mode is available due to libtorrent import error: %s\n'
|
||||
'To use Standalone mode, please see logs for error details.'
|
||||
% (str(ex))
|
||||
)
|
||||
|
||||
except ImportError as ex:
|
||||
log.exception(ex)
|
||||
err_msg = _(
|
||||
'Only Thin Client mode is available due to unknown Import Error.\n'
|
||||
'To use Standalone mode, please see logs for error details.'
|
||||
)
|
||||
except Exception as ex:
|
||||
log.exception(ex)
|
||||
err_msg = _(
|
||||
|
|
Loading…
Reference in New Issue