Request: Command line controls

Suggestions and discussion of future versions
Juewy
New User
New User
Posts: 5
Joined: Sun Sep 02, 2007 8:13 pm

Request: Command line controls

Post by Juewy »

Hi all

I just installed deluge and its going great :D but I was wondering, I do a lot of work on a different pc and leave this one on all the time for various things and i manage it remotely, can you add command line options to pause all the downloads and resume them that way i only have to run deluge --pause-transfers remotely sort of thing?

I know it sounds lazy but it saves me walking up the stairs every time i want to use the net :oops:

Keep up the fab work!

Juewy
Keiji
Member
Member
Posts: 17
Joined: Sat Sep 01, 2007 12:47 pm

Re: Request: Command line controls

Post by Keiji »

I think it would definitely be useful if you could run a terminal command to show the statistics of torrents and also manage the torrents (such as pause/resume, update tracker, add, remove and clear finished), because I also frequently use other computers, and if that feature existed, I could easily use ssh to do that.
renier
New User
New User
Posts: 5
Joined: Thu Sep 06, 2007 5:08 pm

Re: Request: Command line controls

Post by renier »

I am resantly writing such a Plugin that opens a Telnet Server interface, to remotly (mainly used local) connect to deluge.

Here is what i got so far. Its NOT finished but its easy to add new command methods to it.
Add a python method that end with Command to the RequestHandler thats all.
Attachments
TelnetServer.tar.gz
Telnet Server Plugin
(3.45 KiB) Downloaded 243 times
Juewy
New User
New User
Posts: 5
Joined: Sun Sep 02, 2007 8:13 pm

Re: Request: Command line controls

Post by Juewy »

Its looking good :D if only i knew python :( it looks easy enough so I'll try and add some more bits to it when i get chance, can you point me in the right direction of how to find out what i need to type for the deluge stuff, i dont know how to word it exactly but you use self.server.core.unique_IDs for the torrent list command, im guessing its the same as java classes but how do i find out what i can use eg self.server.core.stop_all sort of thing.

Hope that makes a bit of sense

EDIT: I just upgraded deluge to 0.5.5 and when i have this plugin on it goes to 100% cpu usage :o
renier
New User
New User
Posts: 5
Joined: Thu Sep 06, 2007 5:08 pm

Re: Request: Command line controls

Post by renier »

For the 100% CPU
Edit the telnetserver.py file and remove the 'else:' in line 48. Put the next line (sleep) in front of the if.
It should look like:

Code: Select all

                while not self.stopthread.isSet():
                    readySocket = select.select([self.socket], [], [self.socket], 0)

                    if readySocket[0] or readySocket[2] :
                        if threading.activeCount() < self.threadLimit:
                            self.handle_request()
                    time.sleep(0.5)
                print 'server stopped'
For the self.server.core you can call every method (def) on the core you like. just take a look into the core.py file to see whats there.
renier
New User
New User
Posts: 5
Joined: Thu Sep 06, 2007 5:08 pm

Re: Request: Command line controls

Post by renier »

Here is an updated Version with preference dialog to setuo host and port.
The issues from above are also fixed.
Attachments
TelnetServer.tar.gz
Plugin update, now with preference dialog
(4.46 KiB) Downloaded 277 times
Juewy
New User
New User
Posts: 5
Joined: Sun Sep 02, 2007 8:13 pm

Re: Request: Command line controls

Post by Juewy »

I should of thought about looking for a core.py file, so if i used self.server.common i could use any function in common.py?

I tried adding this to telnetserver.py after the download command:

Code: Select all

def pauseallCommand(self, ignored):
    "Pause all torrents."
    self.privateMessage('Pausing all torrents.')
    self.server.core.pause_all()
But when i type help into the telnet server the pauseall command doesn't appear and it doesnt work when i type pauseall, any ideas?

Thx
renier
New User
New User
Posts: 5
Joined: Thu Sep 06, 2007 5:08 pm

Re: Request: Command line controls

Post by renier »

1.) No you can not just user all other classes (files) from deluge by just typing self.server.XYZ only core is there.

2.) depend where you put this method. You have to add it into to the RequestHandler class in telnetserver.py
best is you add it where the helpCommand and all other methods are.

I tried your method and it worked for me.
Juewy
New User
New User
Posts: 5
Joined: Sun Sep 02, 2007 8:13 pm

Re: Request: Command line controls

Post by Juewy »

This is very strange, i have tried adding my method into telnetserver.py between prompt and helpCommand, just below helpCommand and in between most of the other methods with no success, the only thing i have changed from what you posted is the server is 127.0.0.1 instead of localhost since localhost gave the error "Server not startet: (99, 'Cannot assign requested address')" ... any ideas?

Also does it take about 20-30 seconds to connect to the telnet server, im guessing its just telnet but im just wondering
renier
New User
New User
Posts: 5
Joined: Thu Sep 06, 2007 5:08 pm

Re: Request: Command line controls

Post by renier »

Don't know about your method worked well.
You have to reinstall deluge 'sudo make install' so the script copies all needed files in the right dir.
Post Reply