def create_path(result, path): """Creates the specified path if deluge is older than 1.3""" from deluge.common import VersionSplit # Before 1.3, deluge would not create a non-existent move directory, so we need to. if VersionSplit('1.3.0') > VersionSplit(self.deluge_version): if client.is_localhost(): if not os.path.isdir(path): log.debug('path %s doesn\'t exist, creating' % path) os.makedirs(path) else: log.warning('If path does not exist on the machine running the daemon, move will fail.')
def check_version(lt): from deluge.common import VersionSplit if VersionSplit(lt.version) < VersionSplit(REQUIRED_VERSION): raise ImportError("This version of Deluge requires libtorrent >=%s!" % REQUIRED_VERSION)
def test_version_split(self): self.assertTrue(VersionSplit('1.2.2') == VersionSplit('1.2.2')) self.assertTrue(VersionSplit('1.2.1') < VersionSplit('1.2.2')) self.assertTrue(VersionSplit('1.1.9') < VersionSplit('1.2.2')) self.assertTrue(VersionSplit('1.2.2') > VersionSplit('1.2.1')) self.assertTrue(VersionSplit('1.2.2') > VersionSplit('1.2.2-dev0')) self.assertTrue(VersionSplit('1.2.2-dev') < VersionSplit('1.3.0-rc2')) self.assertTrue(VersionSplit('1.2.2') > VersionSplit('1.2.2-rc2')) self.assertTrue(VersionSplit('1.2.2-rc2-dev') < VersionSplit('1.2.2-rc2')) self.assertTrue(VersionSplit('1.2.2-rc3') > VersionSplit('1.2.2-rc2')) self.assertTrue(VersionSplit('0.14.9') == VersionSplit('0.14.9')) self.assertTrue(VersionSplit('0.14.9') > VersionSplit('0.14.5')) self.assertTrue(VersionSplit('0.14.10') >= VersionSplit('0.14.9')) self.assertTrue(VersionSplit('1.4.0') > VersionSplit('1.3.900.dev123')) self.assertTrue(VersionSplit('1.3.2rc2.dev1') < VersionSplit('1.3.2-rc2')) self.assertTrue(VersionSplit('1.3.900.dev888') > VersionSplit('1.3.900.dev123')) self.assertTrue(VersionSplit('1.4.0') > VersionSplit('1.4.0.dev123')) self.assertTrue(VersionSplit('1.4.0.dev1') < VersionSplit('1.4.0')) self.assertTrue(VersionSplit('1.4.0a1') < VersionSplit('1.4.0'))
# the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # """ This module is used to handle the importing of libtorrent and also controls the minimum versions of libtorrent that this version of Deluge supports. Example: >>> from deluge._libtorrent import lt """ 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: 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 LibtorrentImportError('Deluge %s requires libtorrent >= %s' % (get_version(), REQUIRED_VERSION))
def test_torrent_error_resume_data_unaltered(self): if windows_check(): raise unittest.SkipTest( 'unexpected end of file in bencoded string') if VersionSplit(lt.__version__) >= VersionSplit('1.2.0.0'): raise unittest.SkipTest( 'Test not working as expected on lt 1.2 or greater') resume_data = { 'active_time': 13399, 'num_incomplete': 16777215, 'announce_to_lsd': 1, 'seed_mode': 0, 'pieces': '\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01', 'paused': 0, 'seeding_time': 13399, 'last_scrape': 13399, 'info-hash': '-\xc5\xd0\xe7\x1af\xfeid\x9ad\r9\xcb\x00\xa2YpIs', 'max_uploads': 16777215, 'max_connections': 16777215, 'num_downloaders': 16777215, 'total_downloaded': 0, 'file-format': 'libtorrent resume file', 'peers6': '', 'added_time': 1411826665, 'banned_peers6': '', 'file_priority': [1], 'last_seen_complete': 0, 'total_uploaded': 0, 'piece_priority': '\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01', 'file-version': 1, 'announce_to_dht': 1, 'auto_managed': 1, 'upload_rate_limit': 0, 'completed_time': 1411826665, 'allocation': 'sparse', 'blocks per piece': 2, 'download_rate_limit': 0, 'libtorrent-version': '0.16.17.0', 'banned_peers': '', 'num_seeds': 16777215, 'sequential_download': 0, 'announce_to_trackers': 1, 'peers': '\n\x00\x02\x0f=\xc6SC\x17]\xd8}\x7f\x00\x00\x01=\xc6', 'finished_time': 13399, 'last_upload': 13399, 'trackers': [[]], 'super_seeding': 0, 'file sizes': [[512000, 1411826586]], 'last_download': 13399, } torrent_state = TorrentState( torrent_id='2dc5d0e71a66fe69649a640d39cb00a259704973', filename='test_torrent.file.torrent', name='', save_path='/home/ubuntu/Downloads', file_priorities=[1], is_finished=True, ) filename = common.get_test_data_file('test_torrent.file.torrent') with open(filename, 'rb') as _file: filedump = _file.read() resume_data = utf8_encode_structure(resume_data) torrent_id = self.core.torrentmanager.add( state=torrent_state, filedump=filedump, resume_data=lt.bencode(resume_data)) torrent = self.core.torrentmanager.torrents[torrent_id] def assert_resume_data(): self.assert_state(torrent, 'Error') tm_resume_data = lt.bdecode( self.core.torrentmanager.resume_data[torrent.torrent_id]) self.assertEqual(tm_resume_data, resume_data) return deferLater(reactor, 0.5, assert_resume_data)
# -*- coding: utf-8 -*- # # Copyright (C) 2009 Andrew Resch <*****@*****.**> # # This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with # the additional special exception to link portions of this program with the OpenSSL library. # See LICENSE for more details. # """ This module is used to handle the importing of libtorrent and also controls the minimum versions of libtorrent that this version of Deluge supports. Example: >>> from deluge._libtorrent import lt """ from __future__ import unicode_literals from deluge.common import VersionSplit, get_version try: import deluge.libtorrent as lt except ImportError: import libtorrent as lt REQUIRED_VERSION = '1.1.2.0' if VersionSplit(lt.__version__) < VersionSplit(REQUIRED_VERSION): raise ImportError('Deluge %s requires libtorrent >= %s' % (get_version(), REQUIRED_VERSION))