From 12f7345d0cd141322b368f53c9f2a3fc8cf71fcb Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 17 Dec 2017 10:55:13 +0000 Subject: [PATCH] Use a constant for versions --- deluge/_libtorrent.py | 3 ++- deluge/core/core.py | 6 ++++-- deluge/ui/baseargparser.py | 4 ++-- setup.py | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/deluge/_libtorrent.py b/deluge/_libtorrent.py index 385eed155..02edf187c 100644 --- a/deluge/_libtorrent.py +++ b/deluge/_libtorrent.py @@ -25,6 +25,7 @@ except ImportError: import libtorrent as lt REQUIRED_VERSION = '1.1.2.0' +LT_VERSION = lt.__version__ -if VersionSplit(lt.__version__) < VersionSplit(REQUIRED_VERSION): +if VersionSplit(LT_VERSION) < VersionSplit(REQUIRED_VERSION): raise ImportError('Deluge %s requires libtorrent >= %s' % (get_version(), REQUIRED_VERSION)) diff --git a/deluge/core/core.py b/deluge/core/core.py index 855d37500..f54b77e03 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -24,7 +24,7 @@ from twisted.web.client import getPage import deluge.common import deluge.component as component from deluge import path_chooser_common -from deluge._libtorrent import lt +from deluge._libtorrent import lt, LT_VERSION from deluge.common import PY2 from deluge.configmanager import ConfigManager, get_config_dir from deluge.core.alertmanager import AlertManager @@ -97,6 +97,8 @@ SESSION_RATES_MAPPING = { 'upload_rate': 'net.sent_bytes', } +DELUGE_VER = deluge.common.get_version() + class Core(component.Component): def __init__(self, listen_interface=None, read_only_config_keys=None): @@ -1058,7 +1060,7 @@ class Core(component.Component): :rtype: string """ - return lt.__version__ + return LT_VERSION @export def get_completion_paths(self, args): diff --git a/deluge/ui/baseargparser.py b/deluge/ui/baseargparser.py index 682f72fcf..3f116c9eb 100644 --- a/deluge/ui/baseargparser.py +++ b/deluge/ui/baseargparser.py @@ -89,8 +89,8 @@ argparse.ArgumentParser.set_default_subparser = set_default_subparser def get_version(): version_str = '%s\n' % (common.get_version()) try: - from deluge._libtorrent import lt - version_str += 'libtorrent: %s\n' % lt.__version__ + from deluge._libtorrent import LT_VERSION + version_str += 'libtorrent: %s\n' % LT_VERSION except ImportError: pass version_str += 'Python: %s\n' % platform.python_version() diff --git a/setup.py b/setup.py index ab3f3b637..8a9a5ceb5 100755 --- a/setup.py +++ b/setup.py @@ -360,8 +360,8 @@ class Build(_build): # Run all sub-commands (at least those that need to be run). _build.run(self) try: - from deluge._libtorrent import lt - print('Info: Found libtorrent ({}) installed.'.format(lt.__version__)) + from deluge._libtorrent import LT_VERSION + print('Info: Found libtorrent ({}) installed.'.format(LT_VERSION)) except ImportError as ex: print('Warning: libtorrent (libtorrent-rasterbar) not found: %s' % ex)