1
0
Fork 0

Compare commits

..

2 commits

Author SHA1 Message Date
83be4bae11
Releasing debian version 2.1.2~dev0+20250301-1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-03-21 01:38:45 +01:00
5369fed815
Merging upstream version 2.1.2~dev0+20250301.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-03-21 01:38:30 +01:00
9 changed files with 47 additions and 38 deletions

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
deluge (2.1.2~dev0+20250301-1) sid; urgency=medium
* Merging upstream version 2.1.2~dev0+20250301.
-- Daniel Baumann <daniel@debian.org> Fri, 21 Mar 2025 01:38:41 +0100
deluge (2.1.2~dev0+20240910-6) sid; urgency=medium deluge (2.1.2~dev0+20240910-6) sid; urgency=medium
* Updating to standards version 4.7.1. * Updating to standards version 4.7.1.

View file

@ -196,11 +196,27 @@ def activate(self):
d = defer.ensureDeferred(self.coro) d = defer.ensureDeferred(self.coro)
d.chainDeferred(self) d.chainDeferred(self)
def addCallbacks(self, *args, **kwargs): # noqa: N802 def _callback_activate(self):
"""Verify awaited status before calling activate."""
assert not self.awaited, 'Cannot add callbacks to an already awaited coroutine.' assert not self.awaited, 'Cannot add callbacks to an already awaited coroutine.'
self.activate() self.activate()
def addCallback(self, *args, **kwargs): # noqa: N802
self._callback_activate()
return super().addCallback(*args, **kwargs)
def addCallbacks(self, *args, **kwargs): # noqa: N802
self._callback_activate()
return super().addCallbacks(*args, **kwargs) return super().addCallbacks(*args, **kwargs)
def addErrback(self, *args, **kwargs): # noqa: N802
self._callback_activate()
return super().addErrback(*args, **kwargs)
def addBoth(self, *args, **kwargs): # noqa: N802
self._callback_activate()
return super().addBoth(*args, **kwargs)
_RetT = TypeVar('_RetT') _RetT = TypeVar('_RetT')

View file

@ -199,6 +199,8 @@ def test_set_prioritize_first_last_pieces_false(self):
# self.print_priority_list(priorities) # self.print_priority_list(priorities)
def test_torrent_error_data_missing(self): def test_torrent_error_data_missing(self):
if VersionSplit(lt.__version__) > VersionSplit('2.0.7.0'):
pytest.xfail('Test not working as expected after lt 2.0.7')
options = {'seed_mode': True} options = {'seed_mode': True}
filename = common.get_test_data_file('test_torrent.file.torrent') filename = common.get_test_data_file('test_torrent.file.torrent')
with open(filename, 'rb') as _file: with open(filename, 'rb') as _file:
@ -214,6 +216,8 @@ def test_torrent_error_data_missing(self):
self.assert_state_wait(torrent, 'Error') self.assert_state_wait(torrent, 'Error')
def test_torrent_error_resume_original_state(self): def test_torrent_error_resume_original_state(self):
if VersionSplit(lt.__version__) > VersionSplit('2.0.7.0'):
pytest.xfail('Test not working as expected after lt 2.0.7')
options = {'seed_mode': True, 'add_paused': True} options = {'seed_mode': True, 'add_paused': True}
filename = common.get_test_data_file('test_torrent.file.torrent') filename = common.get_test_data_file('test_torrent.file.torrent')
with open(filename, 'rb') as _file: with open(filename, 'rb') as _file:
@ -233,7 +237,7 @@ def test_torrent_error_resume_original_state(self):
def test_torrent_error_resume_data_unaltered(self): def test_torrent_error_resume_data_unaltered(self):
if VersionSplit(lt.__version__) >= VersionSplit('1.2.0.0'): if VersionSplit(lt.__version__) >= VersionSplit('1.2.0.0'):
pytest.skip('Test not working as expected on lt 1.2 or greater') pytest.xfail('Test not working as expected on lt 1.2 or greater')
resume_data = { resume_data = {
'active_time': 13399, 'active_time': 13399,

View file

@ -12,8 +12,6 @@
from unittest import mock from unittest import mock
import pytest import pytest
import pytest_twisted
from twisted.internet import defer
import deluge import deluge
import deluge.component as component import deluge.component as component
@ -27,7 +25,6 @@
from deluge.ui.web.server import DelugeWeb from deluge.ui.web.server import DelugeWeb
from . import common from . import common
from .daemon_base import DaemonBase
DEBUG_COMMAND = False DEBUG_COMMAND = False
@ -70,15 +67,6 @@ def exec_command(self):
return self.var['start_cmd']() return self.var['start_cmd']()
class UIWithDaemonBaseTestCase(UIBaseTestCase, DaemonBase):
"""Subclass for test that require a deluged daemon"""
def set_up(self):
d = self.common_set_up()
common.setup_test_logger(level='info', prefix=self.config_dir / self.id())
return d
class TestDelugeEntry(BaseTestCase): class TestDelugeEntry(BaseTestCase):
def set_up(self): def set_up(self):
return component.start() return component.start()
@ -321,13 +309,13 @@ def test_console_unrecognized_arguments(self):
assert 'unrecognized arguments: --ui' in fd.out.getvalue() assert 'unrecognized arguments: --ui' in fd.out.getvalue()
class ConsoleUIWithDaemonBaseTestCase(UIWithDaemonBaseTestCase): class ConsoleUIWithDaemonBaseTestCase(UIBaseTestCase):
"""Implement Console tests that require a running daemon""" """Implement Console tests that require a running daemon"""
def set_up(self): def set_up(self):
# Avoid calling reactor.shutdown after commands are executed by main.exec_args() # Avoid calling reactor.shutdown after commands are executed by main.exec_args()
deluge.ui.console.main.reactor = common.ReactorOverride() deluge.ui.console.main.reactor = common.ReactorOverride()
return UIWithDaemonBaseTestCase.set_up(self) return super().set_up()
def patch_arg_command(self, command): def patch_arg_command(self, command):
if isinstance(command, str): if isinstance(command, str):
@ -346,14 +334,13 @@ def patch_arg_command(self, command):
+ command, + command,
) )
@pytest_twisted.inlineCallbacks async def test_console_command_add(self):
def test_console_command_add(self):
filename = common.get_test_data_file('test.torrent') filename = common.get_test_data_file('test.torrent')
self.patch_arg_command([f'add "{filename}"']) self.patch_arg_command([f'add "{filename}"'])
fd = StringFileDescriptor(sys.stdout) fd = StringFileDescriptor(sys.stdout)
self.patch(sys, 'stdout', fd) self.patch(sys, 'stdout', fd)
yield self.exec_command() await self.exec_command()
std_output = fd.out.getvalue() std_output = fd.out.getvalue()
assert ( assert (
@ -361,8 +348,7 @@ def test_console_command_add(self):
== 'Attempting to add torrent: ' + filename + '\nTorrent added!\n' == 'Attempting to add torrent: ' + filename + '\nTorrent added!\n'
) )
@pytest_twisted.inlineCallbacks async def test_console_command_add_move_completed(self):
def test_console_command_add_move_completed(self):
filename = common.get_test_data_file('test.torrent') filename = common.get_test_data_file('test.torrent')
tmp_path = 'c:\\tmp' if windows_check() else '/tmp' tmp_path = 'c:\\tmp' if windows_check() else '/tmp'
self.patch_arg_command( self.patch_arg_command(
@ -377,7 +363,7 @@ def test_console_command_add_move_completed(self):
fd = StringFileDescriptor(sys.stdout) fd = StringFileDescriptor(sys.stdout)
self.patch(sys, 'stdout', fd) self.patch(sys, 'stdout', fd)
yield self.exec_command() await self.exec_command()
std_output = fd.out.getvalue() std_output = fd.out.getvalue()
assert std_output.endswith( assert std_output.endswith(
@ -397,20 +383,19 @@ async def test_console_command_status(self):
assert std_output.startswith('Total upload: ') assert std_output.startswith('Total upload: ')
assert std_output.endswith(' Moving: 0\n') assert std_output.endswith(' Moving: 0\n')
@defer.inlineCallbacks async def test_console_command_config_set_download_location(self):
def test_console_command_config_set_download_location(self):
fd = StringFileDescriptor(sys.stdout) fd = StringFileDescriptor(sys.stdout)
self.patch_arg_command(['config --set download_location /downloads']) self.patch_arg_command(['config --set download_location /downloads'])
self.patch(sys, 'stdout', fd) self.patch(sys, 'stdout', fd)
yield self.exec_command() await self.exec_command()
std_output = fd.out.getvalue() std_output = fd.out.getvalue()
assert std_output.startswith('Setting "download_location" to: \'/downloads\'') assert std_output.startswith('Setting "download_location" to: \'/downloads\'')
assert std_output.endswith('Configuration value successfully updated.\n') assert std_output.endswith('Configuration value successfully updated.\n')
@pytest.mark.usefixtures('daemon', 'client') @pytest.mark.usefixtures('daemon', 'client', 'base_fixture')
class TestConsoleScriptEntryWithDaemon(BaseTestCase, ConsoleUIWithDaemonBaseTestCase): class TestConsoleScriptEntryWithDaemon(ConsoleUIWithDaemonBaseTestCase):
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def set_var(self, request): def set_var(self, request):
request.cls.var = { request.cls.var = {

View file

@ -9,6 +9,8 @@
import logging import logging
from twisted.internet import defer
import deluge.component as component import deluge.component as component
from deluge.ui.client import client from deluge.ui.client import client
@ -63,7 +65,7 @@ def handle(self, options):
_('Confirm with -c to remove the listed torrents (Count: %d)') _('Confirm with -c to remove the listed torrents (Count: %d)')
% len(torrent_ids) % len(torrent_ids)
) )
return return defer.succeed(True)
def on_removed_finished(errors): def on_removed_finished(errors):
if errors: if errors:
@ -76,6 +78,7 @@ def on_removed_finished(errors):
log.info('Removing %d torrents', len(torrent_ids)) log.info('Removing %d torrents', len(torrent_ids))
d = client.core.remove_torrents(torrent_ids, options.remove_data) d = client.core.remove_torrents(torrent_ids, options.remove_data)
d.addCallback(on_removed_finished) d.addCallback(on_removed_finished)
return d
def complete(self, line): def complete(self, line):
# We use the ConsoleUI torrent tab complete method # We use the ConsoleUI torrent tab complete method

View file

@ -493,7 +493,7 @@ def on_button_add_clicked(self, widget):
*textview_buf.get_bounds(), include_hidden_chars=False *textview_buf.get_bounds(), include_hidden_chars=False
) )
log.debug('Create torrent tracker lines: %s', trackers_text) log.debug('Create torrent tracker lines: %s', trackers_text)
self.config['createtorrent.trackers'] = trackers_text.split('/n') self.config['createtorrent.trackers'] = trackers_text.splitlines()
# Append trackers liststore with unique trackers and tiers starting from last tier number. # Append trackers liststore with unique trackers and tiers starting from last tier number.
last_tier, orig_trackers = last_tier_trackers_from_liststore( last_tier, orig_trackers = last_tier_trackers_from_liststore(

View file

@ -782,7 +782,7 @@ def add_texticon_column(
return True return True
def on_keypress_search_by_name(self, model, column, key, _iter): def on_keypress_search_by_name(self, model, column, key, _iter, *search_data):
torrent_name_col = self.columns[_('Name')].column_indices[1] torrent_name_col = self.columns[_('Name')].column_indices[1]
return not model[_iter][torrent_name_col].lower().startswith(key.lower()) return not model[_iter][torrent_name_col].lower().startswith(key.lower())

View file

@ -461,15 +461,12 @@ def resize_icon(self, icon):
# Requires Pillow(PIL) to resize. # Requires Pillow(PIL) to resize.
if icon and Image: if icon and Image:
filename = icon.get_filename() filename = icon.get_filename()
remove_old = False
with Image.open(filename) as img: with Image.open(filename) as img:
new_filename = os.path.splitext(filename)[0] + '.png'
if img.size > (16, 16): if img.size > (16, 16):
new_filename = filename.rpartition('.')[0] + '.png'
img = img.resize((16, 16), Image.Resampling.LANCZOS) img = img.resize((16, 16), Image.Resampling.LANCZOS)
img.save(new_filename) img.save(new_filename)
if new_filename != filename: if new_filename != filename:
remove_old = True
if remove_old:
os.remove(filename) os.remove(filename)
icon = TrackerIcon(new_filename) icon = TrackerIcon(new_filename)
return icon return icon

View file

@ -1,4 +1,2 @@
-r requirements.txt -r requirements.txt
-r requirements-tests.txt -r requirements-tests.txt
libtorrent==2.0.7
pytest==7.4.2