Commit Graph

9018 Commits

Author SHA1 Message Date
Calum Lind 39bd97f03e
[Core] Fix getting libtorrent alert type
Encountered a problem with dht_error alert not returning the correct
alert name using Python type.

This should likely be fixed in libtorrent but we should be using
the alert.what method to determine alert type/name.

Since the alert name does not include the `_alert` suffix, strip this
when registering alerts.
2023-03-07 16:18:50 +00:00
Calum Lind 196086c1fb
[Core] Refactor alert handler for readability 2023-03-07 16:05:17 +00:00
Chase Sterling 527cfa586c
[Tests] Autorun async tests with pytest_twisted.
Since all of our async tests should be run with twisted, it's
annoying to have to decorate them with pytest_twisted.ensureDeferred.
Forgetting to do this will cause the test to pass without actually
running. This changes the behavior to detect all coroutine function
tests and mark them to be run by pytest_twisted the same way the
decorator does.

Closes: https://github.com/deluge-torrent/deluge/pull/414
2023-03-07 09:24:46 +00:00
DjLegolas 25a2b113e2
[Component] Add pause and resume events methods
For future use add ability to handle pause and resume events

Co-authored-by: Calum Lind <calumlind+deluge@gmail.com>
2023-03-06 13:25:18 +00:00
Calum Lind c38b4c72d0
[Tests] Refactor component tests for readability
Modified test functions to be async.

Used pytest_twisted_ensuredeferred_for_class decorator to avoid needed
ensureDeferred for each test within the class. There might be a way to
do this with fixtures so likely to be improvements for use in all test
classes.

Used Mock in component subclass for simpler tracking of event method calls
2023-03-06 13:25:00 +00:00
DjLegolas 0745c0eff8
[Component] Refactor to remove hasattr usage
Functions are defined in the class now

https://github.com/deluge-torrent/deluge/pull/221#discussion_r228275050
2023-03-06 13:20:14 +00:00
Calum Lind e90f6c7eef
[Tests] Use tmp_path for test logfile
Daemon logfile were being stored in dir where tests were started from
which cluttered up local dev env.

Entry point logfiles are stored in config dir since getting tmp_path in
set_up was a bit too tricky.
2023-03-03 15:57:46 +00:00
Calum Lind 7b1a0ef89c
[Tests] Fix error in TestJSONRequestFailed test
Fix test generating following error

    'TestJSONRequestFailed' object has no attribute 'core'
2023-03-03 15:18:47 +00:00
Calum Lind 75b27485e1
Add metainfo.xml to gitignore 2023-03-03 10:46:31 +00:00
Calum Lind a64cdfaf78
[GtkUI] Enable remapping of keyboard shortcuts
With key shortcuts set in the glade files it is not easy to change
the shortcuts on macOS.

Add AccelPaths to each MenuItem to allow adding or modifying accelerator
in codes. Uses the recommended format `<Deluge-MainWindow>/MenuName`

Update menubar code to use new functionality, taking advantage of
accelerator_parse to specify accelerators as strings instead of Gdk
flags.

A future idea would be to use `Gtk.AccelMap.load` to have shortcuts
loaded from user config.

Co-authored-by: Gregorio Litenstein <g.litenstein@gmail.com>
2023-03-03 10:42:29 +00:00
Calum Lind 4b6ac1f4c4
[WebUI] Fix setting base path
Simplify the code for setting the base path, both via headers and
config. Replaced putchild since it is not recommended for dynamic
paths and overriding getChildWithDefault provides a proper solution.

This also fixes recursive base path problem with previous code where
appending base paths to URL would still return Deluge web e.g.

    http://localhost:8112/deluge/deluge/deluge

Removed getChild override by consolidating empty path conditional to
getChildWithDefault. This simplifies and combines the returning of
TopLevel resource for root path or base path.

Added workaround for test logfile error with forwardslash in filename
2023-03-03 09:37:46 +00:00
Calum Lind 683a4f906e
[WebUI] Minor refactoring
Simplify getting port for WebUI tests
Extract adding slashes to base to function
Use super function to simplify parent class calls
2023-03-03 09:37:36 +00:00
Calum Lind e70a983a55
[Tests] Fix save_resume_data errors in test_torrent
Error in test_rename_unicode:

   TypeError: object MagicMock can't be used in 'await' expression

Fixed by using AsyncMock that can be awaited.
Added backport asyncmock for Python 3.7
2023-02-28 15:05:52 +00:00
Calum Lind 9ce8afe507
[Tests] Fix component warning in Plugin tests
The component fixture was warning about existing registered components since
the standalone client was setup before the componentregistry test was performed.
The problem is due to fixture ordering with the setup fixture running
first since it was marked with autouse followed by component fixture.

* Fixed warning by moving component fixture as a dependency of the set_up fixture
* Cleaned up unneeded code
* Added try..except to catch CorePluginBase KeyError deregistering
RPCServer since component fixture already removed it.
* Ignore test-specific Twisted readBody warnings
2023-02-28 14:21:18 +00:00
Calum Lind f67fb4d520
[Tests] Remove unneeded component teardown
The component fixture calls shutdown so teardown not needed here
2023-02-28 14:20:09 +00:00
Calum Lind d00068423f
[Tests] Ignore 3rd-party deprecation warnings in pytest
Move pytest config from tox to pyproject and ignore deprecation warning
generated in 3rd-party libraries.

Fixed GObject deprecation warning
2023-02-27 20:15:12 +00:00
DjLegolas 7336877928
[console] Fix host deletion
The host id didn't receive correctly and the indexing was not being
updated correctly.

Closes: https://github.com/deluge-torrent/deluge/pull/393
2023-02-27 17:39:00 +00:00
DjLegolas 543fce4f29
[console] Fix add host in connection manager
The input is being passed as `str` instead of `int`, so added a
conversion only if the string is indeed a decimal number.
In addition, closing the add host popup after adding it.

Closes: https://dev.deluge-torrent.org/ticket/3538
2023-02-27 17:39:00 +00:00
DjLegolas 38feea0fa4
[hostlist] Add port value validation
When in console, and adding a new host with an invalid port number, the
console starts printing many exceptions regarding the value.
Therefor, we will make sure that the port value is between 0 and 65535.
2023-02-27 17:39:00 +00:00
Calum Lind 7af584d649
[Console] Refactor Eventlog for readability 2023-02-27 17:39:00 +00:00
Calum Lind 1ba7beb7bc
[Console] Move migration func out of main 2023-02-27 17:38:59 +00:00
Calum Lind f4f4accd34
[Console] Move eventlog class to separate file 2023-02-27 17:38:59 +00:00
Calum Lind ae22a52f2f
[Console] Refactor callbacks and cleanup main 2023-02-27 17:38:59 +00:00
Calum Lind 22f74b60ce
[Console] Cleanup terminal resize handler
Improve readability

Move imports available on Windows out of try..except.

For future reference in Python 3.11 termios now has window size methods
but the added complexity of handling older Python versions is not worth
it.

https://docs.python.org/3/library/termios.html#termios.tcgetwinsize
2023-02-27 17:38:58 +00:00
Calum Lind 253eb2240b
[Console] Refactor main to use async instead of callbacks
Use the new maybe_coroutine decorator to replace callbacks with inline
async/await for cleaner code.
2023-02-27 17:38:58 +00:00
DjLegolas 6c924e6128
[GTK] Fix Add-torrent-dialog not respecting dirs
When adding a new torrent, there is a problem changing the path on
Windows machines, due to the difference between the way the files are
being read from the torrent and how we handle them in addtorrentdialog.
This effects both changing and showing the files in the UI.

Now, all path seperator is being considered and converted to slash '/'.

Closes: https://dev.deluge-torrent.org/ticket/3541
Closes: https://github.com/deluge-torrent/deluge/pull/395
2023-02-24 15:17:38 +00:00
Calum Lind 930cf87103
[Lint] Update pre-commit apps to latest versions
Also update github CI action versions
2023-02-24 14:59:15 +00:00
Calum Lind 45c9f3b90a
[Lint] Fix pre-commit isort install error
Update to latest version of isort to fix install error:

    RuntimeError: The Poetry configuration is invalid:
        - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'

Also update the Linting CI to latest version
2023-02-24 14:58:26 +00:00
Torbjörn Lönnemark 13f81efe98
Update metainfo install path
The metainfo file was being installed into /usr/share/appdata, but that
path has been deprecated. Metainfo files should instead be installed
into /usr/share/metainfo.

Closes: https://dev.deluge-torrent.org/ticket/3394
Ref: https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#sect-Metadata-GenericComponent
Closes: https://github.com/deluge-torrent/deluge/pull/389
2023-02-24 13:42:19 +00:00
DjLegolas 98c5830013
[Packaging][Windows] Add DisplayVersion registry key
This addition will help tools (e.g. `winget`) to identify the version
of deluge

Closes: https://dev.deluge-torrent.org/ticket/3560
Closes: https://github.com/deluge-torrent/deluge/pull/402
2023-02-24 13:16:01 +00:00
DjLegolas 8332d1aa39
[Label] fix torrent deletion not removes from config
when deleting a torrent, the on deletion hook deletes the torrent from
the local config but does not save the new config to disk.
note that when setting a new label to a torrent, the config does save.

Closes: https://dev.deluge-torrent.org/ticket/3545
Closes: https://github.com/deluge-torrent/deluge/pull/397
2023-02-24 11:38:28 +00:00
JohnTheCoolingFan 6f7445be18
[Lable] Fix label display name in submenu
Previously every '_' in label's name was incorrectly replaced by '__'

Closes: https://github.com/deluge-torrent/deluge/pull/410
2023-02-24 11:28:41 +00:00
Tydus fb30478123
[GTK3UI] Fix too low upper limit of upload/download in add torrent dialog
Closes: https://github.com/deluge-torrent/deluge/pull/398
2023-02-24 11:19:44 +00:00
DjLegolas 5d7b416373
[Core] Stop using libtorrent.add_torrent_params_flags_t
The `libtorrent.add_torrent_params_flags_t` is deprecated and when
`libtorrent` is being compiled without deprecated functionality, we will
fail on `AttributeError`.

Refs: 4947602a2f
Closes: https://dev.deluge-torrent.org/ticket/3581
Closes: https://github.com/deluge-torrent/deluge/pull/407
2023-02-24 10:44:57 +00:00
DjLegolas 4de754328f
[ConsoleUI] remove `deferred` being returned after command
A `return` statement was added in ece31cf for unit testing to work but
this resulted in Deferred printed in console output.

Added a test_start entry point to return the required deferreds while
removing the return from original start entrypoint.

Closes: https://dev.deluge-torrent.org/ticket/3582
Closes: https://github.com/deluge-torrent/deluge/pull/408
2023-02-24 10:43:09 +00:00
DjLegolas c4b9cc7292
[tox] update tox.ini for support for `tox` 4
`tox` 4 now demands that `passenv` parameter will be comma-separated and
not space-seperated.

Closes: https://github.com/deluge-torrent/deluge/pull/409
2023-02-23 17:10:40 +00:00
Ryan Ernst fa750c9fd0
[AutoAdd] Fixes #3515 - check for more torrent decode errors
https://github.com/deluge-torrent/deluge/pull/381 improved the situation
with possible errors during torrent decoding. However, the log message in
https://dev.deluge-torrent.org/ticket/3515 indicates a RuntimeError:

```
Traceback: <class 'RuntimeError'>: unexpected end of file in bencoded string
```

This commit adds RuntimeError to those caught while loading the torrent
to add.

Closes: https://github.com/deluge-torrent/deluge/pull/411
2023-02-23 17:08:48 +00:00
Calum Lind 2a945de069
[CI] Fix tests stalling/timing out
GitHub pytest runner stalling with the following error:

    [Errno 2] No such file or directory: '/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/deluge/plugins'

This is related to the editable install of Deluge via pip

    pip install -e .

and the custom resource_filename in deluge.common is the source of the
problem where a DistInfoDistribution returns a different path to
EggInfoDistribution.

Working egg-info install

    >>> pkg_resources.get_distribution('Deluge')
    deluge 2.1.1.dev8 (/home/user/deluge)

    >>> type(pkg_resources.get_distribution('Deluge'))
    <class 'pkg_resources.EggInfoDistribution'>

    >>> pkg_resources.resource_filename('deluge', 'plugins')
    '/home/user/deluge/deluge/plugins'

This can identified by the `deluge.egg-info` directory in source
directory.

Broken dist-info install

    >>> pkg_resources.get_distribution('Deluge')
    deluge 2.1.1.dev8 (/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages)

    >>> type(pkg_resources.get_distribution('Deluge'))
    <class 'pkg_resources.DistInfoDistribution'>

    >>> pkg_resources.resource_filename('deluge', 'plugins')
    '/home/user/deluge/deluge/plugins'

This can be worked around by setting an env var that enables legacy mode
but long-term need to replace the custom resource_filename and replace
usage of pkg_resources.

https://setuptools.pypa.io/en/latest/userguide/development_mode.html#legacy-behavior
https://setuptools.pypa.io/en/latest/pkg_resources.html
2022-12-01 22:39:10 +00:00
Calum Lind d0acd3e06e
[CI] Fix installing enchant for github docs workflow
The enchant package was renamed for version 2 to enchant-2 and original
enchant package removed in Ubuntu 22.04 so docs workflow failed

Fixed by using latest package and specifying ubuntu version to avoid
unexpected failures in future.
2022-12-01 13:11:53 +00:00
DjLegolas 3565a9a817
[WebUI] Fix `TypeError` in DelugeWeb constructor
In `twisted 22.10`, a check new for passing the `path` variable as
`bytes` in the `putChild` method.
We were enforcing this on every other place but the `__init__` of
`DelugeWeb` itself.

Ref: https://github.com/twisted/twisted/pull/11718
Closes: https://dev.deluge-torrent.org/ticket/3566
2022-12-01 12:52:00 +00:00
Calum Lind b3d1fd79a8
Update changelog from 2.1.1 release 2022-07-10 14:06:34 +01:00
Calum Lind b64084d248
[Docs] Update changelog and install details 2022-07-08 09:04:57 +01:00
Calum Lind e120536d87
Fix parsing magnet with tracker tiers
Magnets with trackers specified with tr.x param were not being unquoted
so unusable raw tracker string was being set.

Fixed by unquoting tracker and adding test

See-also: https://dev.deluge-torrent.org/ticket/2716
2022-07-08 08:34:29 +01:00
Calum Lind f52cf760e4
Fix missing trackers adding magnets
The changes to remove deprecated lt methods didn't account for magnet
trackers so magnets are missing trackers when added.

Previously the addition of trackers was handled by libtorrent when a url
was passed in add_torrent_params. The url parameter is deprecated so
instead we need to add both the info_hash and trackers.

Trac: https://dev.deluge-torrent.org/ticket/3530
2022-07-05 08:03:33 +01:00
Calum Lind 94d790c159
[CI] Bump ifaddr to 0.2.0
With release of ifaddr 0.2.0 no longer need to pin to github commit to
resolve Windows decoding issues.
2022-06-30 21:47:06 +01:00
Calum Lind f78506161d
[CI] Fix failing Windows Python 3.10 tests
A recent dependency change caused the tests running on GitHub Actions
under Python 3.10.5 on Windows to fail when starting pytest run:

    ...
    INTERNALERROR>   File "<frozen importlib._bootstrap>", line 123, in acquire
    INTERNALERROR> KeyError: xxxx

The cause seems to have been a newer version of chardet package released
recently.

* Fixed by pinning chardet to v4
* Also pin Windows version to 2019 to match packaging workflow

See-also: https://github.com/deluge-torrent/deluge/actions/runs/2578427588
Issue: https://github.com/chardet/chardet/issues/265
2022-06-29 15:07:23 +01:00
Calum Lind 592b05cd87
back to development 2022-06-28 22:11:29 +01:00
Calum Lind 6c8f9ce756
Release 2.1.0 2022-06-28 22:07:35 +01:00
Calum Lind 19dba297ef
[Docs] Fix ReadTheDocs theme rendering issue
Fix rendering issues in ReadTheDocs by specifying latest version of
sphinx-rtd-theme. Normally not an issue to install this latest
dependency from doc/requirement.txt but RTD installs in the env an older
version (<0.5) before running requirements file install
thus sphinx-rtd-theme is not upgraded unless a version is specified.

See-also: https://github.com/readthedocs/sphinx_rtd_theme/issues/1115
2022-06-28 19:45:21 +01:00
N9199 cbacaf0545
[Core] Fix typo in AUTH_LEVEL_MAPPING
Closes: https://github.com/deluge-torrent/deluge/pull/387
2022-06-19 19:02:11 +01:00