Page 1 of 1

Error starting Deluge with Applescript

Posted: Thu Dec 02, 2010 7:09 am
by halfthelaw
Thanks so much, the above steps worked like a charm!

Now,I'm trying to launch deluge-gtk with a simple AppleScript:

Code: Select all

do shell script "/opt/local/bin/deluge-gtk-2.6"
However, when I try to do this I get the most hideous error:

Code: Select all

error "Traceback (most recent call last):
  File \"/opt/local/bin/deluge-gtk-2.6\", line 9, in <module>
    load_entry_point('deluge==1.3.1', 'gui_scripts', 'deluge-gtk')()
  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/deluge/ui/gtkui/gtkui.py\", line 107, in start
    Gtk().start()
  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/deluge/ui/gtkui/gtkui.py\", line 104, in start
    GtkUI(self.args)
  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/deluge/ui/gtkui/gtkui.py\", line 193, in __init__
    self.config = deluge.configmanager.ConfigManager(\"gtkui.conf\", DEFAULT_PREFS)
  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/deluge/configmanager.py\", line 122, in ConfigManager
    return _configmanager.get_config(config, defaults)
  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/deluge/configmanager.py\", line 114, in get_config
    self.config_files[config_file] = Config(config_file, defaults, self.config_directory)
  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/deluge/config.py\", line 150, in __init__
    self.set_item(key, value)
  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/deluge/config.py\", line 192, in set_item
    value = deluge.common.utf8_encoded(value)
  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/deluge/common.py\", line 594, in utf8_encoded
    s = decode_string(s, locale.getpreferredencoding())
  File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/deluge/common.py\", line 578, in decode_string
    s = s.decode(encoding).encode(\"utf8\", \"ignore\")
LookupError: unknown encoding: " number 1
Any ideas on how to fix?

Re: Error starting Deluge with Applescript

Posted: Thu Dec 02, 2010 2:49 pm
by Cas
I have split this from the original thread, as it was not directly related to the topic.

You have not said whether deluge runs fine from the command line.

Re: Error starting Deluge with Applescript

Posted: Fri Dec 03, 2010 7:15 pm
by CSB
The script works for me if I execute it using osascript, however not with the apple script editor, or any other method.
Edit:

Code: Select all

tell application "Terminal" to do script "/bin/bash -c 'deluge-gtk-2.6 &> /dev/null &' ;  exit 0 ; exit 0"/code]

Does the job on my end. Who the hell knows why you need such a kludge to do it. 
Actually, each hacky bit explained:
sh is the default shell applescript uses, so you need to call bash.
getting rid of all of the barf that deluge might spit up will probably be necessary, so redirect it to /dev/null
the first exit 0 tells applescript everything is ok
the second exit 0 gets rid of the terminal window all this happened in

oh yeah, and you have to tell terminal to do it otherwise deluge gets killed for godknowswhy.

Re: Error starting Deluge with Applescript

Posted: Thu Dec 23, 2010 10:19 pm
by jaychow
I successfully installed Deluge 1.3.1 and Python 2.6.6 on Mac OS X 10.6.5 in their default locations. But I got tired of typing in Terminal "deluged-2.6 &" and "deluge-2.6 &". So, after some search on this forum, I wrote an AppleScript:

do shell script "/opt/local/bin/deluged-2.6 & /opt/local/bin/deluge-2.6"

and saved as an application. I don't like to asymmetry of the Deluge logo, so I updated it in icongrapher and applied it to the app.

Please let me know how it works for you.