kannibalox / pyrosimple

An overhauled fork of the pyrocore tools for rTorrent
https://kannibalox.github.io/pyrosimple/
GNU General Public License v3.0
48 stars 5 forks source link

Command "d.timestamp.last_active" does not exist. #22

Closed MrBamse closed 1 year ago

MrBamse commented 1 year ago

First off, thank you so much for this port and all the work you've put into it, it really works super great! :)

I do apologize if this has been brought up before but I just couldn't find it in any of the corners of the internet.

The error I get the following error when trying to use the filter "active" (e.g. rtcontrol -s active -/5 completed=+5d)

Traceback (most recent call last):
  File "/home/mrbamse/.local/lib/python3.9/site-packages/pyrosimple/torrent/rtorrent.py", line 840, in items
    raw_items = multi_call(*tuple(multi_args))
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
    return self.__send(self.__name, args)
  File "/home/mrbamse/.local/lib/python3.9/site-packages/pyrosimple/util/rpc.py", line 244, in __request
    return self.__request_switch(methodname, params)
  File "/home/mrbamse/.local/lib/python3.9/site-packages/pyrosimple/util/rpc.py", line 265, in __request_switch
    raise exc
  File "/home/mrbamse/.local/lib/python3.9/site-packages/pyrosimple/util/rpc.py", line 257, in __request_switch
    return self.__request_xml(methodname, params)
  File "/home/mrbamse/.local/lib/python3.9/site-packages/pyrosimple/util/rpc.py", line 145, in __request_xml
    response = self.__transport.request(
  File "/home/mrbamse/.local/lib/python3.9/site-packages/pyrosimple/io/scgi.py", line 141, in request
    return self.parse_response(io.BytesIO(response))
  File "/home/mrbamse/.local/lib/python3.9/site-packages/pyrosimple/io/scgi.py", line 57, in parse_response
    return super().parse_response(response)
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1348, in parse_response
    return u.close()
  File "/usr/lib/python3.9/xmlrpc/client.py", line 662, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault -503: 'Command "d.timestamp.last_active" does not exist.'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mrbamse/.local/lib/python3.9/site-packages/pyrosimple/scripts/base.py", line 184, in run
    self.mainloop()
  File "/home/mrbamse/.local/lib/python3.9/site-packages/pyrosimple/scripts/rtcontrol.py", line 739, in mainloop
    matches = futures[url].get()
  File "/usr/lib/python3.9/multiprocessing/pool.py", line 771, in get
    raise self._value
  File "/usr/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/mrbamse/.local/lib/python3.9/site-packages/pyrosimple/scripts/rtcontrol.py", line 730, in fetch
    matches = list(e.items(view=view, prefetch=prefetch))
  File "/home/mrbamse/.local/lib/python3.9/site-packages/pyrosimple/torrent/rtorrent.py", line 864, in items
    raise error.EngineError(
pyrosimple.error.EngineError: While getting download items from RtorrentEngine connected to wireguard:1 [rTorrent 0.13.8/0.9.8, up 7h 11m] via 'scgi+unix:///home/mrbamse/rtorrent.sock': <Fault -503: 'Command "d.timestamp.last_active" does not exist.'>

Settings And these are my settings from .rtorrent.rc (copied straight from https://kannibalox.github.io/pyrosimple/rtorrent-config/)

# active
method.insert = d.last_xfer.is_active, simple,"or={pyro._last_xfer_check_min_rate=$d.up.rate=,pyro._last_xfer_check_min_rate=$d.down.rate=}"
method.insert = d.timestamp.last_xfer, simple, "if=$d.last_xfer.is_active=,$cat=$system.time=,$d.custom=last_xfer"
schedule2 = pyro_update_last_xfer, 33, 17,"d.multicall2=active,\"branch=$d.last_xfer.is_active=,pyro._last_xfer_update=\""

# last_xfer
method.insert.value = pyro.last_xfer.min_rate, 5000
method.insert = pyro._last_xfer_check_min_rate, simple|private,"greater=argument.0=,pyro.last_xfer.min_rate="
method.insert = pyro._last_xfer_update, simple|private,"d.custom.set=last_xfer,$cat=$system.time= ; branch=argument.0=,d.save_resume="
schedule2 = pyro_update_last_xfer, 33, 17,"d.multicall2=active,\"branch=$d.last_xfer.is_active=,pyro._last_xfer_update=\""

Goal I'm trying to setup a filter where the five completed items that were the opposite of last to do any transfers are listed. Another option, preferably, would be a filter that lists every item that has not seeded for X days.

Conclusion

Thank you so much, and again; great job! :)

kannibalox commented 1 year ago

Try this instead of the current active section:

# active
method.insert = d.timestamp.last_active, simple, "if=$d.peers_connected=,$cat=$system.time=,$d.custom=last_active"
method.insert = d.timestamp.last_active.update, simple|private,\
    "d.custom.set=last_active,$cat=$system.time= ; branch=argument.0=,d.save_resume="

schedule2 = pyro_update_last_active, 24, 42,\
    "d.multicall2=started,\"branch=$d.peers_connected=,d.timestamp.last_active.update=\""

method.set_key = event.download.resumed, !last_active,\
    "branch=\"or={d.peers_connected=,not=$d.custom=last_active}\", d.timestamp.last_active.update=1"
method.set_key = event.download.finished, !last_active, "d.timestamp.last_active.update=1"

However, if you're actually looking for d.timestamp.last_xfer, the last_xfer field should function as-is.

The longer story is that jesec/rtorrent implements d.timestamp.last_active natively so I missed this issue in my own testing. I'll test it on my own as well against vanilla before I add it back to the docs.

MrBamse commented 1 year ago

Works like a charm! You are a real star my friend! Thank you thank you thank you! :)

So if I understood you correctly, is it a correct assumption that the following accomplish the same result (it did in my env but not sure if that's a coincidence):

/usr/bin/docker exec rtorrent rtcontrol -s xfer -/5 completed=+5d
/usr/bin/docker exec rtorrent rtcontrol -s last_xfer -/5 completed=+5d
/usr/bin/docker exec rtorrent rtcontrol -s active -/5 completed=+5d
/usr/bin/docker exec rtorrent rtcontrol -s custom_KEY=d.timestamp.last_xfer -/5 completed=+5d

Btw, if there's somehow I can contribute/help out just let me know. What you are doing is of great service to a lot of ppl and many of us appreciate it, if although in silence.

kannibalox commented 1 year ago

It's pretty much coincidence. Sorting goes from low to high, and for most of those fields, if the torrent has never been active those values will be 0 or empty. If you have at least 5 torrents that have never been active, they'll consistently show up as the first 5 for the first 3 queries. Try adding -r to reverse the sort order. I know it's bit counter-intuitive, but it's kept that way for historical reasons.

rtcontrol -s custom_KEY=d.timestamp.last_xfer -/5 completed=+5d

This is probably not doing what you're expecting, it's fetching the value of the custom key KEY=d.timestamp.last_xfer (which will be empty) and sorting on that. The working command is custom_last_xfer, but that field is the same exact value as last_xfer but in string format. I'd recommend just using last_xfer instead.

Also note that active and last_xfer are nearly identical: active is the last time a peer was connected, and last_xfer was the last time a peer connected and transferred data.

Just reporting things like this is a great help, there's a lot of features and use cases packed in here and it's long road to getting them into automated testing.

MrBamse commented 1 year ago

Thank you so much for getting back to me, and an extra big thanks for taking the time to explain the different variables, it's greatly appreciated and reduces the headscratching here by a factor of ten. ;P

We really appreciate the effort you put into this so let me know if you set up a donation or something, you definitely deserve at least a few beers for the help you've given me! ;)

Have an awesome day (and weekend) Take care my friend! ;)

kannibalox commented 1 year ago

No problem, I don't plan to ever take donations but if it's really burning a hole in your pocket archive.org is a worthy cause.