Deluge.app (Current version: 1.3.11)

Support for Deluge on Apple Mac OS
Harsesis
Member
Member
Posts: 10
Joined: Fri Apr 06, 2012 9:40 pm

Re: Deluge.app (Latest version: 1.3.5)

Post by Harsesis »

Is it possible to get open folder to work? (when you right click a torrent)

I get the following error when I try:

Code: Select all

Unhandled error in Deferred:
Unhandled Error
Traceback (most recent call last):
  File "twisted/internet/gtk2reactor.pyc", line 270, in run
    
  File "/Applications/Deluge.app/Contents/Resources/lib/python2.7/deluge-1.3.5-py2.7.egg/deluge/ui/gtkui/menubar.py", line 312, in on_menuitem_open_folder_activate
    component.get("SessionProxy").get_torrent_status(torrent_id, ["save_path"]).addCallback(_on_torrent_status)
  File "twisted/internet/defer.pyc", line 297, in addCallback
    	'
  File "twisted/internet/defer.pyc", line 286, in addCallbacks
    chaining (associating two Deferreds with each other such that one
--- <exception caught here> ---
  File "twisted/internet/defer.pyc", line 542, in _runCallbacks
    
  File "/Applications/Deluge.app/Contents/Resources/lib/python2.7/deluge-1.3.5-py2.7.egg/deluge/ui/gtkui/menubar.py", line 310, in _on_torrent_status
    deluge.common.open_file(status["save_path"])
  File "/Applications/Deluge.app/Contents/Resources/lib/python2.7/deluge-1.3.5-py2.7.egg/deluge/common.py", line 245, in open_file
    subprocess.Popen(["xdg-open", "%s" % path])
  File "subprocess.pyc", line 679, in __init__
    N(RbR?R[(RR?((ssubprocess.pycR??scCs|jtj?dS(s/Terminate the process with SIGTERM
  File "subprocess.pyc", line 1228, in _execute_child
    
exceptions.OSError: [Errno 2] No such file or directory
carbncl
Leecher
Leecher
Posts: 92
Joined: Sun Nov 28, 2010 7:36 pm

Re: Deluge.app (Latest version: 1.3.5)

Post by carbncl »

Ah nice catch, as usual, using Deluge with a remote server, never noticed that one (which is disabled&hidden when using a remote server)
I guess it would be easy to do by calling OSX "open" instead of linux "xdg-open"... Yup that's it, works on my laptop. Fix will be in next release.

Waiting for this, you can edit /Applications/Deluge.app/Contents/Resources/lib/python2.7/deluge-1.3.5-py2.7.egg/deluge/common.py by replacing "xdg-open" by "open".
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Deluge.app (Latest version: 1.3.5)

Post by Cas »

Weird this wasn't noticed before but the fix should be applied to Deluge source so does this work:

Code: Select all

@@ -241,6 +241,8 @@ def open_file(path):
     """
     if windows_check():
         os.startfile("%s" % path)
+    elif osx_check():
+        subprocess.Popen(["open", "%s" % path])
     else:
         subprocess.Popen(["xdg-open", "%s" % path])
carbncl
Leecher
Leecher
Posts: 92
Joined: Sun Nov 28, 2010 7:36 pm

Re: Deluge.app (Latest version: 1.3.5)

Post by carbncl »

Funny, that's exactly the patch I wrote ;) , tested, works.

Code: Select all

diff --git a/deluge/common.py b/deluge/common.py
index 4881d16..29c37e8 100644
--- a/deluge/common.py
+++ b/deluge/common.py
@@ -241,6 +241,8 @@ def open_file(path):
     """
     if windows_check():
         os.startfile("%s" % path)
+    elif osx_check():
+        subprocess.Popen(["open", "%s" % path])
     else:
         subprocess.Popen(["xdg-open", "%s" % path])
Harsesis
Member
Member
Posts: 10
Joined: Fri Apr 06, 2012 9:40 pm

Re: Deluge.app (Latest version: 1.3.5)

Post by Harsesis »

Cool. Thanks for the fix. I was wondering if there was a way of passing the file or folder to the open command instead of the download dir. Subsequently on osx when you call open you can specify -R arg to highlight the file you've asked for.

I modified the open to look like this in my common.py

Code: Select all

subprocess.Popen(["open", "-R","%s" % path])
If we could get the open folder menu item to pass the actual file/dir to the open command it would be awesome.

menuitem_open_folder looks like the code that passed the path to the open_file function:

Code: Select all

 deluge.common.open_file(status["save_path"]) 
How do I add the torrents folder/file path?
Harsesis
Member
Member
Posts: 10
Joined: Fri Apr 06, 2012 9:40 pm

Re: Deluge.app (Latest version: 1.3.5)

Post by Harsesis »

I tried

Code: Select all

 
    def on_menuitem_open_folder_activate(self, data=None):
        log.debug("on_menuitem_open_folder")
        def _on_torrent_status(status):
            deluge.common.open_file(status["save_path"] + "/" + status["name"])
        for torrent_id in component.get("TorrentView").get_selected_torrents():
            component.get("SessionProxy").get_torrent_status(torrent_id, ["name","save_path"]).addCallback(_on_torrent_status)
I'm not sure what else i've broken by changing this but that works for me. I'm not sure how to handle a trailing / in the save path if there is one.

Can you let me know if I'm heading in the right direction please? I want to help aswell as point out problems :D
carbncl
Leecher
Leecher
Posts: 92
Joined: Sun Nov 28, 2010 7:36 pm

Re: Deluge.app (Latest version: 1.3.5)

Post by carbncl »

I think you are, but I guess something like os.path.join(status["save_path"], status["name"]) might be preferable than + '/'
Harsesis
Member
Member
Posts: 10
Joined: Fri Apr 06, 2012 9:40 pm

Re: Deluge.app (Latest version: 1.3.5)

Post by Harsesis »

Excellent thanks. I had to import os and it worked fine.

Edit: By the way do you think the change or something similar could be included in the code? The behaviour is the same for many osx applications.

Possibly with an osx_check() if statement to ensure other OS don't have an issue with the change.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Deluge.app (Latest version: 1.3.5)

Post by Cas »

If you modify open_file it will affect opening files directly from File Tabs, I have created a ticket for this issue: http://dev.deluge-torrent.org/ticket/2098
Harsesis
Member
Member
Posts: 10
Joined: Fri Apr 06, 2012 9:40 pm

Re: Deluge.app (Latest version: 1.3.5)

Post by Harsesis »

File and folders both work on osx open. Open from a torrent tab and open folder from the torrent list. The open command doesn't seem to care.

Thanks for creating the ticket. I'll edit mine manually until the change gets added to the src properly :)
Post Reply