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

Fix the create-config and create-rtorrent-rc commands #27

Closed vamega closed 1 year ago

vamega commented 1 year ago

Previously they would fail as if the config files did not already exist.

Running pyroadmin config --create-rtorrent-rc would result in a stack trace like:

Traceback (most recent call last):
  File "/nix/store/nqyha84673a4950hgk0b2c81mvbahvqc-python3.10-pyrosimple-2.6.1/lib/python3.10/site-packages/pyrosimple/scripts/base.py", line 170, in run
    self.get_options()
  File "/nix/store/nqyha84673a4950hgk0b2c81mvbahvqc-python3.10-pyrosimple-2.6.1/lib/python3.10/site-packages/pyrosimple/scripts/base.py", line 243, in get_options
    self.engine = rtorrent.RtorrentEngine()
  File "/nix/store/nqyha84673a4950hgk0b2c81mvbahvqc-python3.10-pyrosimple-2.6.1/lib/python3.10/site-packages/pyrosimple/torrent/rtorrent.py", line 643, in __init__
    config.autoload_scgi_url()
  File "/nix/store/nqyha84673a4950hgk0b2c81mvbahvqc-python3.10-pyrosimple-2.6.1/lib/python3.10/site-packages/pyrosimple/config.py", line 124, in autoload_scgi_url
    raise error.UserError(f"rTorrent RC file '{rcfile}' doesn't exist!")
pyrosimple.error.UserError: rTorrent RC file '/home/madiath/.rtorrent.rc' doesn't exist!

From what I can tell, the commands here don't need the config version of the base class. They create their own engine instance, and don't rely on the engine created in ScriptBaseWithConfig

kannibalox commented 1 year ago

Thanks! There is a little bit of magic involved in handling -U aliases that will have to be duplicated, but this is much better than the hacks that would be needed to make things work with ScriptBaseWithConfig.