Help with a Python Script (set_save_path)

General support for problems installing or using Deluge
srt75
Member
Member
Posts: 24
Joined: Tue Sep 25, 2012 9:29 pm

Help with a Python Script (set_save_path)

Post by srt75 »

Hi All,

Using the "Torrent Complete" Execute function I would like to be able to do the following

A - Copy completed Torrent files/directory to local Hard Drive (I can do this with a Bash script no probs)

B - When the Copy above has completed I want to set the path to the new copied location.
I've come accross this Python Function "set_save_path(save_path)" in the Wiki, but have no clue about
how to use it or write the code. (Can someone help me here please)

C - Remove the original downloaded files/folder (I can do this with a Bash script)


Reason I don't want to use the "Move Completed" function is that I want to continue seeding until the copying
has finished, using the "Move Completed" function pauses the download, for which I dont want.

Also I'm downloading straight to RAM initially as this is really really quick, but obviously limited by it's size.

Hope you can help, obviously if it's even possible :-)


SRT.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Help with a Python Script (set_save_path)

Post by Cas »

You can actually use the Copy Completed plugin and there is an TorrentCopiedEvent that could be utilized in a script however what you are trying to attempt in 'Step B' will require extra steps. This is because when using move_storage (set_save_path is something different) it will not move the files if the folder exists already which is what will happen in your case.

To achieve what you are asking it will require pausing the torrent, deleting the original location, using move_storage and then resume the torrent again.
srt75
Member
Member
Posts: 24
Joined: Tue Sep 25, 2012 9:29 pm

Re: Help with a Python Script (set_save_path)

Post by srt75 »

Cas, just to confirm what you are saying:

Copy Folder/File > Pause Torrent > Delete from RAM Drive > Use move_storage > Resume Torrent

This would work?

On the assumption (Yes Mother of all lol) the above works, can someone please help me write the above code or at least provide an example, roughly reflecting some of what I require.

Cas, you've been a great help today for which I thank you.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Help with a Python Script (set_save_path)

Post by Cas »

It was quite straightforward to just extend the CopyCompleted plugin to now also move after the copy. I need to tidy up the code and add a UI option.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Help with a Python Script (set_save_path)

Post by Cas »

Ok I have uploaded a new version to my github: https://github.com/cas--/deluge-copycompleted

For now there is no webui option for 'move to' but there is a new gtk ui which has the option.
srt75
Member
Member
Posts: 24
Joined: Tue Sep 25, 2012 9:29 pm

Re: Help with a Python Script (set_save_path)

Post by srt75 »

Hi Cas,

Thank You for sparing the time to write this this for me (lol here is the but), but there is two things that aren't working with it.

Firstly it's not removing any folders including sub folders, although it does remove the files.

Secondly and I guess more importantly it doesn't continue to seed from the moved location. I get a "No such file or directory:" within the status on the details tab, it's still points to the Ram-Drive location.

FYI, When I set the umask to 777 the Ram-Drive retained all files and folders, when set as 000 (set now) the above happens, either setting the copy works.

SRT.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Help with a Python Script (set_save_path)

Post by Cas »

srt75 wrote:Firstly it's not removing any folders including sub folders, although it does remove the files.
Hmm that didn't show up in my testing however I had considered this could happen and can add code to deal with it. The remaining empty folders will most likely contribute to your second issue.
srt75 wrote:FYI, When I set the umask to 777 the Ram-Drive retained all files and folders, when set as 000 (set now) the above happens, either setting the copy works.
The umask is only for creating the destination folder so would have no effect on original location.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Help with a Python Script (set_save_path)

Post by Cas »

Ok I've updated it, hopefully this works better. I have done only a little testing so let me know if any other issues.
srt75
Member
Member
Posts: 24
Joined: Tue Sep 25, 2012 9:29 pm

Re: Help with a Python Script (set_save_path)

Post by srt75 »

Almost there Cas, the folder and or files now delete, but Deluge still reports seeding from the Ram drive, Error still being "No such file or directory: ..."

Copying still working as expected.

Thanks for the continued effort.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Help with a Python Script (set_save_path)

Post by Cas »

Can you ensure that it is the newer version plugin loading, usually requires restart of deluged.

If you enable debug logging it might help me to track the issue.
Post Reply