Commit Graph

9052 Commits

Author SHA1 Message Date
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
Calum Lind 75db47fc1f
Update Changelog entries 2022-06-19 08:30:54 +01:00
Calum Lind f1ec68704d
[CD] Cleanup pip cache in Win builds
- Use the more reliable setup-python cache
- Move the pip install to GTK install step for consistency
- Don't update pip to ensure consistent version
2022-06-13 19:37:41 +01:00
Martin Hertz ae3fbcca77
[Packaging] Pinned Pyinstaller to v4.10 and readme update
Pin Pyinstaller to latest v4.x until issue of aborting upon missing typelibs for various unbuilt gst-modules can be properly investigated and resolved. Specific error for one of the modules being:

`36738 INFO: Loading module hook 'hook-gi.repository.Gst.py' from 'C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\lib\\site-packages\\PyInstaller\\hooks'...
Traceback (most recent call last):
  File "<string>", line 7, in <module>
gi.repository.GLib.GError: g-irepository-error-quark: Typelib file for namespace 'Gst', version '1.0' not found (0)
36870 ERROR: gi repository 'GIRepository 2.0' not found. Please make sure corresponding package is installed.
Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\gi\__init__.py", line 139, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available`

Added `--no-index` to ensure pip doesn't install from Pypi

Closes: https://github.com/deluge-torrent/deluge/pull/386
2022-06-13 19:31:54 +01:00
Calum Lind 6a10e8f3cd
[Packaging] Bump Win dependencies
* Update Twisted and libtorrent to latest releases
* Update to v3 github actions that now use node 16
2022-06-12 20:05:04 +01:00
ibizaman b0dba97fec
[Web] Accept charset in content-type for json messages
Trac: https://dev.deluge-torrent.org/ticket/3521
Closes: https://github.com/deluge-torrent/deluge/pull/385
2022-06-12 16:08:36 +01:00
Martin Hertz d7c520c85e
[WebUI] Fixed 'Complete Seen' and 'Completed' sorting
Closes: https://github.com/deluge-torrent/deluge/pull/384
2022-05-17 22:45:37 +01:00
Martin Hertz ee3180fd94
[Notifications] Fix UnicodeEncodeError upon non-ascii torrent name
smtplib.SMTP.sendmail expects 'msg' in string of ascii chars or bytes,
where the former gets encoded to bytes through ascii codec, hence
raising said error, but now fixed by encoding to bytes ourself through
utf-8

Closes: https://github.com/deluge-torrent/deluge/pull/383
2022-05-17 22:42:05 +01:00
Chase Sterling 47e548fdb5
[Core] Refactor prefetch_metadata for more clarity
Just trying to clean up some of the more complicated callback logic.

Notable changes:

* The test was awaiting a DeferredList. By default that will eat
exceptions and just add them to the result list (including test
assertion exceptions.) Added fireOnOneErrback=True to make sure that
wasn't happening.  * Moved the logic for multiple calls to await the
same response into torrentmanager from core, so no matter where the
prefetch is called from it will wait for the original call.
* Implemented the multiple calls with an explicit queue of waiting
callbacks, rather than a callback callback chain.  * Moved to one inline
async function rather than split into a main and callback after alert
function.
* Added some more type hints to the stuff I changed.

Adjusted test since we are using prefetch as an async function now
we have to schedule the alert to come after we start awaiting the
prefetch call.

Closes: https://github.com/deluge-torrent/deluge/pull/368
2022-05-17 22:15:55 +01:00
Calum Lind cd63efd935
[Console] Fix curses.init_pair raise ValueError on Py3.10
Fix ValueError crash for console users with Python 3.10

Trac: https://dev.deluge-torrent.org/ticket/3518
See-also: https://docs.python.org/3/whatsnew/3.10.html#curses
2022-05-01 21:09:41 +01:00
Calum Lind 7f0a380576
[Core] Cleanup temp files in add_torrent_url
Temporary torrent files are not deleted by add_torrent_url. Not as big a
problem as with tracker icons pages but should be removed after use.

Fixed by updating the method to use async and a try..finally cleanup
block.

Perhaps could be refactored to not require temporary files and instead
store the downloaded torrent as object for passing to add_torrent_file.

Trac: https://dev.deluge-torrent.org/ticket/3167
2022-05-01 20:38:09 +01:00
Calum Lind 68c75ccc05
[TrackerIcons] Cleanup tmp files created by downloading page
Temporary files created while download host html page are no cleaned up
if the download fails.

Fixed by adding a 'finally' step in the callback chain to delete any
created temporary files.

Added tests to ensure the temporary files are deleted, using a fixture
that creates a known filename for the test.

Trac: https://dev.deluge-torrent.org/ticket/3167
2022-05-01 20:35:28 +01:00
Calum Lind 96a0825add
[TrackerIcon] Use httpdownloader page redirect handling
User reported infinite redirecting when attempting to fetch tracker
icon.

Fixed by allowing httpdownloader and RedirectAgent to handle page
redirects including catching infinite redirects

Trac: https://dev.deluge-torrent.org/ticket/3167
See-also: https://github.com/twisted/twisted/blob/5c24e9/src/twisted/web/client.py#L168
2022-05-01 20:35:28 +01:00
Calum Lind 61a83bbd20
[Tests] Remove winreg interface name check
GitHub CI tests on Windows failing for get_windows_interface_name so
remove the fragile tests since not a requirement to be this specific
with testing whether name exists for these methods relying on standard
lib or 3rd-party libs.
2022-05-01 20:32:57 +01:00
deaddrop9 bc6611fc0d
[AutoAdd] Verify torrent decode and errors cleanly if invalid
Watch folder was disabled in AutoAdd and torrent filename is unchanged
if an invalid torrent was added.

Trac: https://dev.deluge-torrent.org/ticket/3515
Closes: https://github.com/deluge-torrent/deluge/pull/381
2022-05-01 18:34:19 +01:00
DjLegolas 970a0ae240
[lint] update black package
Previous version (22.1.0) didn't support `click` version 8.1.0.
Updating to 22.3.0 to resolve.

See: https://github.com/psf/black/issues/2964
Closes: https://github.com/deluge-torrent/deluge/pull/382
2022-05-01 18:31:12 +01:00
Calum Lind 5acb57b5af
[CI] Use setup-python action pip cache
Replace custom pip cache that didn't work correctly on Windows with
option to use pip cache in setup-python action
2022-03-02 13:08:02 +00:00