Fixing lost decimal places in the GTK-UI (2.0.3)

General support for problems installing or using Deluge
Post Reply
just_some_user
New User
New User
Posts: 4
Joined: Mon Sep 20, 2021 4:00 pm

Fixing lost decimal places in the GTK-UI (2.0.3)

Post by just_some_user »

hi there.
i would like to know if it's possible to regain some "features", that were present in the old gtk ui(1.3.15), in the new gtk ui(2.0.3).
specifically, i am talking about the strict rounding that is happening in the new ui.
in the old ui most values had 2 or even 3 decimals. in the new ui everything is rounded to 1 decimal.
only exception (i've noted so far) is the percentage value on the progress bar, which changed from 2 decimals to 0 decimals.
this strict rounding is EXTREMELY annoying to me.
e.g. it's really nonsensical to have a value of "1" in the "available"-column, if you are connected to only one leecher, who has only 95% of the file you try to download...
and if i can set a share-ratio in the settings, which has 2 decimals, i'd also like to have at least 2 decimals in the "ratio"-column...
soo, yeah, would be cool if someone knows a way for me to regain those lost decimal places!

and another feature that seems to be missing: the available seeders & leechers seen by the tracker(s).
both, my "seeders"- and my "leechers"-column now only show the number of seeds/leechers i am connected to, nothing more.
what happened to the number of seeds/leechers reported by the tracker, which used to be shown in brackets?
is it possible to get this back?

thanks in advance to anyone willing/able to help!!
mhertz
Moderator
Moderator
Posts: 1288
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Fixing lost decimal places in the GTK-UI (2.0.3)

Post by mhertz »

just_some_user wrote: Mon Sep 20, 2021 4:44 pm only exception (i've noted so far) is the percentage value on the progress bar, which changed from 2 decimals to 0 decimals.
this strict rounding is EXTREMELY annoying to me.
e.g. it's really nonsensical to have a value of "1" in the "available"-column, if you are connected to only one leecher, who has only 95% of the file you try to download...
and if i can set a share-ratio in the settings, which has 2 decimals, i'd also like to have at least 2 decimals in the "ratio"-column...
soo, yeah, would be cool if someone knows a way for me to regain those lost decimal places!
The 'available' column is defined to 1 decimal, unless that decimal is zero which then is cut - it also shows as 1 when seeding. You can get e.g. 3 decimals for 'available' and 'ratio', by running(or doing manually):

Code: Select all

sudo find / -path */python*/*/deluge/ui/gtk3/torrentview_data_funcs.py -exec sed -i 's/1f/3f/' {} \;
I only verified that 'available' column was changed, and didn't check 'ratio', but the code for this, references same function for the formating of it's value, as per changed here, so should be same I believe.

You also mention progressbar stripped to 0 decimals, which I don't see here though - I see 2 decimals on both deluge 2.0.3 and develop. I'd think 2 decimals is fine for this, but just for completeness then here's example of changing it to 3:

Code: Select all

sudo find / -path */python*/*/deluge/ui/gtk3/tab_data_funcs.py -exec sed -i 's/2f/3f/' {} \;
and another feature that seems to be missing: the available seeders & leechers seen by the tracker(s).
both, my "seeders"- and my "leechers"-column now only show the number of seeds/leechers i am connected to, nothing more.
what happened to the number of seeds/leechers reported by the tracker, which used to be shown in brackets?
is it possible to get this back?
I see what you describe when downloading a magnet without optional trackers appended to magnet URI, but otherwise does show brackets, e.g. latest debian iso torrent, as my test case.
just_some_user
New User
New User
Posts: 4
Joined: Mon Sep 20, 2021 4:00 pm

Re: Fixing lost decimal places in the GTK-UI (2.0.3)

Post by just_some_user »

THANK YOU!!!
Thank you so much, mhertz, you beautiful, beautiful moderator!
I changed torrentview_data_funcs.py manually and also removed the 0-stripping (and "."-stripping; since useless w/o 0-stripping), and now i get a consistent three decimal places in my columns again! <3

When it comes to the progress bar value, I might have expressed myself somewhat inaccurately.
I was not referring to the percent value shown in the status-tab of a torrent.
I was actually talking about the percentage in the progress column.

After playing around with tab_data_funcs.py, I noticed how the names of the files are actually chosen with purpose (LOL).
So I went back to torrentview_data_funcs.py, where I found the function "cell_data_progress".
I changed the line "textstr = '%s %i%%' % (textstr, value)" to "textstr = '{0} {1:.2f}%'.format(textstr, value)"
and now I get 2 decimals in the progress column again. YAY!!

Thanks, mhertz, for pointing me in the right direction!


Digging through torrentview_data_funcs.py, I was able to find out why the brackets are missing, too.
The function "cell_data_peer" is stripping the "(num)" from seeders/leechers-column, when num <= -1.
I.e. I don't get the necessary data from the trackers for the brackets to be shown.
In fact, I don't get properly connected to any trackers at all!
I just didn't notice, because DHT keeps everything running.
So now I got to figure out why I suddenly don't get any tracker connections anymore...
No matter which tracker; the status of every torrent always gets stuck at "announce sent".
just_some_user
New User
New User
Posts: 4
Joined: Mon Sep 20, 2021 4:00 pm

Re: Fixing lost decimal places in the GTK-UI (2.0.3)

Post by just_some_user »

just_some_user wrote: Thu Sep 23, 2021 4:52 am the status of every torrent always gets stuck at "announce sent".
Ok, I'm open to suggestions...

I've tried various network related things... like setting a fixed listening port, exceptions in my firewall and router, etc.; nothing.
By now, I actually think it would have been weird, if that had worked, because AFAIK DHT and tracker connections are both handled by the listen interface.
And my DHT obviously works just fine.
So I reverted all settings to the original state (the same configuration that worked flawlessly under debian 10/deluge v1.3.15).
Then I installed qBittorrent and fed it the same configuration. And it works. I get tracker connections left and right.
Now, since qBittorrent and Deluge both use libtorrent-rasterbar, it ultimately seems to be a Deluge issue...
I would hate it, if I had to migrate to qBittorrent because of this.
Any ideas?!


BTW. Feels like a different issue now. Should I open a new thread for this?
mhertz wrote: Tue Sep 21, 2021 6:18 pm .
Sorry for the quote.
Just wanted to get someone's eyes on this, before I continue having a conversation all by myself... (-_-メ)
mhertz
Moderator
Moderator
Posts: 1288
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Fixing lost decimal places in the GTK-UI (2.0.3)

Post by mhertz »

You're most welcome mate, and thanks likewise for the really kind words, genuinelly appreciate that! :)

Sorry, obviously should have recogniced you referred to the columns like your other issues likeminded, but good job changing this yourself.

Good catch also for the missing parenthesis issue, and regarding your tracker-connectivity issue then up to you how wanna go about this, it's pretty laid back and not so strict here :)

I presume you're on debian 11(as you mentioned being on deluge 10 before upgrading) which I see uses libtorrent 1.2.9 - btw that version has an issue about move_complete not working, just a headsup, and fixed in newer versions.

Anyway, libtorrent 1.2.x has a new multi-home feature which announces from all your interfaces found pretty much, including localhost etc, which times out. Deluge 2.0.3 shows the last recieved tracker message and if that is an error, then list said torrent as in error status. I'm thinking possibly you're having this happening. If not this, then sorry I don't know, maybe if can, then could see if upgrading libtorrent to newer version would help, e.g. I see there is a v1.2.14 in testing or unstable cannot remember, but don't know if just can download and upgrade to that deb package, or if it also need other dependencies upgraded etc. Btw, this issue with showing torrents in error state erroniously, is fixed in deluge's develop branch, so if using libtorrent 1.2.x and atleast one end-point succeds in announcing to tracker, then won't show error, unlike on deluge 2.0.3, and qbittorrent did same thing previously.

You can check debug-logging(see FAQ) and see if any clues there to the issue, and if not helping then possibly helpfull to enable extended debug logging instead(enabling all libtorrent alerts, instead of default subset deluge defines), which though gives very big log so maybe best to grep through it afterwards for the announcing parts or something of sorts(previously read libtorrent lead-dev Arvid state upon tracker announce troubleshooting, that relevant alerts probably are tracker_error_alert and torrent_log_alert of the logging). Easiest way to enable extended logging is using ltconfig plugin and setting alert_mask to '-1' and restart, but if wanna enable it without that plugin, then need change the file(back it up first) '../deluge/core/alertmanager.py', line 52 and onwards, from:

Code: Select all

alert_mask = (
            lt.alert.category_t.error_notification
            | lt.alert.category_t.port_mapping_notification
            | lt.alert.category_t.storage_notification
            | lt.alert.category_t.tracker_notification
            | lt.alert.category_t.status_notification
            | lt.alert.category_t.ip_block_notification
            | lt.alert.category_t.performance_warning
        )
Into:

Code: Select all

alert_mask = (
            lt.alert.category_t.all_categories
        )
Good luck mate.
just_some_user
New User
New User
Posts: 4
Joined: Mon Sep 20, 2021 4:00 pm

Re: Fixing lost decimal places in the GTK-UI (2.0.3)

Post by just_some_user »

mhertz wrote: Wed Sep 29, 2021 10:48 am it's pretty laid back and not so strict here
OK, guess I continue here with my whining then ;)
mhertz wrote: Wed Sep 29, 2021 10:48 am I presume you're on debian 11(as you mentioned being on deluge 10 before upgrading) which I see uses libtorrent 1.2.9 - btw that version has an issue about move_complete not working, just a headsup, and fixed in newer versions.
Correct! I'm on debian 11.
Thanks for the heads-up! Personally, I don't use the move-when-complete feature, so this probably won't affect me, but it's always good to know about these things!
mhertz wrote: Wed Sep 29, 2021 10:48 am libtorrent 1.2.x has a new multi-home feature which announces from all your interfaces found pretty much, including localhost etc, which times out. Deluge 2.0.3 shows the last recieved tracker message and if that is an error, then list said torrent as in error status.
Well, I'm not even shown an error message. The status just freezes at "announce sent". There is no status message like "tracker error" or "timeout" or "invalid argument" or anything like that...
But in order to rule out the multi-home feature, I used ltConfig to set libtorrent's listen interface to my Wifi interface (only one connected to the internet).
However, that didn't have any effect. So it's probably not a timeout on the loopback interface.
mhertz wrote: Wed Sep 29, 2021 10:48 am I see there is a v1.2.14 in testing [...] it also need other dependencies upgraded etc.
Yeah...I generally don't like to mess with other repos.
The chances to bork up your system are too high. Suddenly everything needs other dependencies and nothing works anymore.
mhertz wrote: Wed Sep 29, 2021 10:48 am You can check debug-logging(see FAQ)
I think you are talking about this?!
Well, tried to do that... and this is where all of this almost gets comical: my logging is broken.
Literally the only entry I got when logging to file was this line: (multiple times)

Code: Select all

20:59:35 [CRITICAL][twisted                       :154 ] Unhandled error in Deferred:
In terminal I also got a message about a TypeError that was raised in the file "twisted/internet/defer.py".
So I went ahead and updated Twisted to the latest version available on pip.
And now I get this, when I log to file:

Code: Select all

22:07:07 [CRITICAL][twisted                       :147 ] Unhandled error in Deferred:
...at least the number got smaller, I guess?! :lol:
I tried different log levels; same result.

So, ATM I just can't log what's wrong with Deluge/libtorrent/tracker connections because the logging itself is broken. *fail*

Also; new issue:
I noticed the keyboard shortcuts for moving torrents up & down the queue (Ctrl+Alt+Up/Down) are semi-broken.
They actually move the torrent by 2 positions instead of just 1.
The toolbar buttons and the entries in the context menu to change queue position are working correctly though...
Either the kb shortcuts are handled differently or the shortcut is triggered twice for some reason. Maybe once on key press and once on key release?!
Also, Ctrl+Alt isn't even needed. The shortcut also works as just Ctrl+Up/Down or just Alt+Up/Down for me (so only one of the two modifier keys is required).
I've tracked the shortcuts down to the file "torrentview.py" with the functions "keypress_up" and "keypress_down".
Both functions rely on "CTRL_ALT_MASK" which is specified at the beginning of the file. I guess this mask is not working as intended?!
I'm not a programmer, so I don't exactly know how an appropriate fix might look like.
But I managed to fix it - for my personal(!) use - by removing the mask entirely and replacing the

Code: Select all

if event.get_state() & CTRL_ALT_MASK:
in both functions
with two separate, nested if-statements, like so:

Code: Select all

if event.get_state() & ModifierType.CONTROL_MASK:
	if event.get_state() & ModifierType.SHIFT_MASK:
Also, as you can see, I took the opportunity to change the shortcut from Ctrl+Alt to Ctrl+Shift.
(I also changed the functions, so that the move-to-top/bottom shortcuts (Ctrl+Alt+Shift+Up/Down) remain the same.)
With that fix, it's not enough to just use either Ctrl or Alt (Shift), but both modifier keys are required (as intended).
...Still, the 2-positions-jumping remains unfixed...
As far as I can tell, this one might be a little beyond my "programming" skills.
mhertz
Moderator
Moderator
Posts: 1288
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Fixing lost decimal places in the GTK-UI (2.0.3)

Post by mhertz »

Sorry yes that FAQ.

Hmm, that's really strange and never seen such before reported. Did you try debug level also, which is best imho, for better context. If yes, then i'm affraid I have no idea unfortunetly. (Edit: There's a couple logging fixes from deluge develop branch which helps the logging, though usually helps in reducing error spamming of log, and not missing log entirely, or almost, as in your case, but just in case, then here's a previous post of mine with two command-lines posted for such, if interrested: viewtopic.php?p=233869#p233869 - Edit: Only second fix needed from that post, as first fix already included/backported in latest stable Debian deluge release, I see from there changelog)

About the queue, then good job finding and fixing the issue :) It's a pretty complex subject imho, atleast for me to wrap my head around, i.e. bitfields, bitmasks and binary operators acting upon bits in such etc. Initially I just thought the CTRL_ALT_MASK defined should be changed from '|' to '&', but that isn't how works after testing and reading up on it. Anyway, just for full reference, then can also be fixed by changing the keypress_up/down functions of torrentview.py, lines 911 and 897, from:

Code: Select all

if event.get_state() & CTRL_ALT_MASK:
Into:
'

Code: Select all

if event.get_state() & CTRL_ALT_MASK == CTRL_ALT_MASK
For the key-double-moving issue, then that was strange to me because the keys-function of torrentview.py and toolbar-buttons of toolbar.py uses exact same queue_up/down() function of core.py, just the toolbar function goes through an extra function in torrentmanager.py to get selected torrents, so I added some prints for debugging to see output of some vars, and noticed you where indeed correct in that all keys, even arrow alone keys, where running twise in the 'for' loop, but not the buttons in toolbar, and then found the on_key_press() function in torrentview.py was "double-booked", one for key-press and another for key-release events, just like you theorized :) The commenting above this "double-booking", states it's for catching menu key and displaying torrent_menu, but I believe that's not needed an extra binding for that, as works fine in the first keypress binding, i.e. name of pressed key is retrieved, lowercased, prepended with 'keypress_' and that is the function-name to open i.e. here keypress_menu(), as when menu key pressed. I don't have a menu key on my keyboard, but pretty sure will work without that double-binding, atleast does when changing to other key than menu and without the double-binding.

Anyway, here's a line commenting the key-release event "double-booking" out to fix, I know you do it manually(line 434 of torrentview.py) but just to make it easy for others possibly interessted:

Code: Select all

sudo find / -path "*/python*/*/deluge/ui/gtk3/torrentview.py" -exec sed -i "s/self.treeview.connect('key-release/#self.treeview.connect('key-release/" {} \;
I'm not a programmer neither btw, just pretend to be :D
Post Reply