summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbendikro <bro.devel+deluge@gmail.com>2019-11-05 01:48:17 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2020-04-23 17:17:20 +0100
commit3519f341d474b09f7c0660724e4f6b970e8a6a7c (patch)
tree742100839d84537d1f9f994b82c95a8da73b090c
parentd6c96d629183e8bab2167ef56457f994017e7c85 (diff)
downloaddeluge-3519f341d474b09f7c0660724e4f6b970e8a6a7c.zip
deluge-3519f341d474b09f7c0660724e4f6b970e8a6a7c.tar.gz
deluge-3519f341d474b09f7c0660724e4f6b970e8a6a7c.tar.bz2
[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.
-rw-r--r--deluge/_libtorrent.py9
-rw-r--r--deluge/error.py4
-rw-r--r--deluge/ui/gtk3/gtkui.py16
3 files changed, 23 insertions, 6 deletions
diff --git a/deluge/_libtorrent.py b/deluge/_libtorrent.py
index f155fee..0020184 100644
--- a/deluge/_libtorrent.py
+++ b/deluge/_libtorrent.py
@@ -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)
)
diff --git a/deluge/error.py b/deluge/error.py
index 8705fdf..46e8e0c 100644
--- a/deluge/error.py
+++ b/deluge/error.py
@@ -94,3 +94,7 @@ class AuthenticationRequired(_UsernameBasedPasstroughError):
class AuthManagerError(_UsernameBasedPasstroughError):
pass
+
+
+class LibtorrentImportError(ImportError):
+ pass
diff --git a/deluge/ui/gtk3/gtkui.py b/deluge/ui/gtk3/gtkui.py
index d93bd2e..47e889c 100644
--- a/deluge/ui/gtk3/gtkui.py
+++ b/deluge/ui/gtk3/gtkui.py
@@ -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 = _(