Use a constant for versions

This commit is contained in:
Calum Lind 2017-12-17 10:55:13 +00:00
commit 12f7345d0c
4 changed files with 10 additions and 7 deletions

View file

@ -25,6 +25,7 @@ except ImportError:
import libtorrent as lt import libtorrent as lt
REQUIRED_VERSION = '1.1.2.0' 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)) raise ImportError('Deluge %s requires libtorrent >= %s' % (get_version(), REQUIRED_VERSION))

View file

@ -24,7 +24,7 @@ from twisted.web.client import getPage
import deluge.common import deluge.common
import deluge.component as component import deluge.component as component
from deluge import path_chooser_common 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.common import PY2
from deluge.configmanager import ConfigManager, get_config_dir from deluge.configmanager import ConfigManager, get_config_dir
from deluge.core.alertmanager import AlertManager from deluge.core.alertmanager import AlertManager
@ -97,6 +97,8 @@ SESSION_RATES_MAPPING = {
'upload_rate': 'net.sent_bytes', 'upload_rate': 'net.sent_bytes',
} }
DELUGE_VER = deluge.common.get_version()
class Core(component.Component): class Core(component.Component):
def __init__(self, listen_interface=None, read_only_config_keys=None): def __init__(self, listen_interface=None, read_only_config_keys=None):
@ -1058,7 +1060,7 @@ class Core(component.Component):
:rtype: string :rtype: string
""" """
return lt.__version__ return LT_VERSION
@export @export
def get_completion_paths(self, args): def get_completion_paths(self, args):

View file

@ -89,8 +89,8 @@ argparse.ArgumentParser.set_default_subparser = set_default_subparser
def get_version(): def get_version():
version_str = '%s\n' % (common.get_version()) version_str = '%s\n' % (common.get_version())
try: try:
from deluge._libtorrent import lt from deluge._libtorrent import LT_VERSION
version_str += 'libtorrent: %s\n' % lt.__version__ version_str += 'libtorrent: %s\n' % LT_VERSION
except ImportError: except ImportError:
pass pass
version_str += 'Python: %s\n' % platform.python_version() version_str += 'Python: %s\n' % platform.python_version()

View file

@ -360,8 +360,8 @@ class Build(_build):
# Run all sub-commands (at least those that need to be run). # Run all sub-commands (at least those that need to be run).
_build.run(self) _build.run(self)
try: try:
from deluge._libtorrent import lt from deluge._libtorrent import LT_VERSION
print('Info: Found libtorrent ({}) installed.'.format(lt.__version__)) print('Info: Found libtorrent ({}) installed.'.format(LT_VERSION))
except ImportError as ex: except ImportError as ex:
print('Warning: libtorrent (libtorrent-rasterbar) not found: %s' % ex) print('Warning: libtorrent (libtorrent-rasterbar) not found: %s' % ex)