Page 1 of 2

SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 9th, 2008, 12:58 am
by joncfoo
Image                    Image                    Image

A little info about this project:
I needed a simple monitoring tray app for SABnzbd+ but I couldn't find one that ran on linux...so I wrote one ;D

Download:
Source: http://icicled.net/sabnzbd-tray/sabnzbd-tray.tar.gz

Requirements:
Python 2.5 (it should work with 2.4 and 2.3 I would think, please let me know!)
Elementtree module (provided by python 2.5) for 2.4 you will have to install the cElementTree module
Feedparser module
PyGtk
pynotify (optional)

I have only tested this on Linux but it should work with any unix variant (let me know how it goes). It might work on Windows if you installed Python and PyGtk but I'm not sure.

If you are running a Debian variant (e.g. Ubuntu) run this to make sure you have everything installed:

Code: Select all

aptitude install python-notify python-celementtree python-gtk2 python-feedparser
Configuration:
Edit sabmon.py & set the hostname, port, apikey, username, & password properties to what you need

Comments:
I definitely think there are areas for improvement so try it out and let me know what you think!
Suggestions, comments, code critiques are welcome (this is my first time writing a gtk app in python)
Patches for features & bugfixes are most certainly welcome :)

Changes
- added update for API Key & Authentication
- added open menu item (opens SABnzbd+ in your default browser)
- now pulls completion status from RSS
- fixed bug which would cause to prolong updating the status
- changed Class() to Class: for python 2.4 compatibility
- received patch from switch@sabnzbd to use different colored icons to indicate SABnzbd+ status

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 9th, 2008, 7:17 am
by jcfp
Works fine here (on current Ubuntu), nice work!

Minor issue: with a semi-transparent taskbar on kde(3), the icon looks like having a gray background (while the actual png image has a transparent background).
Image

A quick suggestion: make the default settings match sabnzbd+ defaults (port number?)

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 9th, 2008, 12:37 pm
by switch
pair of dimes wrote: Looks cool, maybe this will help:
http://sabnzbd.org/icon
It already uses a transparent png.

Tried this in windows, but unfortunately the right click menu doesn't seem to work for the taskbar in gtk on windows.

Looks great though, I would recommend using the RSS feed sabnzbd provides for the history to do notifications instead of just detecting change in the top item.

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 9th, 2008, 12:43 pm
by joncfoo
@jcfp:

I installed kde in order to re-create the problem but this is what I got:
Image

I also ran another pygtk app in there called gajim & it's icon showed up just fine too.
I read on gajim's dev. page that installing gnome-python-extras (under ubuntu the package is called python-gnome2-extras) solves the problem. I also read somewhere else that the Gtk theme is responsible for drawing the backgrounds for the tray icons properly, so try changing it. Let me know if either one works for you.

@switch

Thanks for the hint, I'll take a look at that. What would be the benefit of reading from the rss?

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 9th, 2008, 12:52 pm
by switch
I haven't tested the notification of your app, but from the code I guessed that it will announce a file has been downloaded when the file is deleted, or moved to a different part in the queue. I could be wrong, only briefly looked over that part.

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 9th, 2008, 12:56 pm
by joncfoo
@switch

Wow, I hadn't thought of that before (moving the file around in the queue). Nice catch! I'll fix it up today and update.

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 9th, 2008, 1:01 pm
by switch
You could also maybe add a button to launch the sabnzbd url in your browser.

from SAB:

Code: Select all

    import webbrowser
    try:
        webbrowser.open(url, 2, 1)
    except:
        # Python 2.4 does not support parameter new=2
        try:
            webbrowser.open(url, 1, 1)
        except:
            logging.warning("Cannot launch the browser, probably not found")

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 9th, 2008, 4:40 pm
by joncfoo
@switch: Thanks for the input, I've updated it as follows:

Changes
- added open menu item (opens SABnzbd+ in your default browser)
- now pulls completion status from RSS

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 9th, 2008, 5:58 pm
by switch
I changed the icon depending on whether it is downloading/paused/idle:
http://sabnzbd.org/switch/misc/sabnzbd-tray-mod1.zip

Possible extras: Change to grey if sabnzbd not started, make selecting pause/resume from the menu change the icon instantly too. change the default port to 8080 so the majority of people don't need to change it.

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 10th, 2008, 10:42 am
by Shadowtester
I installed the requirements from the first post and then extracted the modified tray monitor. I edited the file from 'localhost' to the ip of my NAS server '192.168.0.120' and changed the port to '8090' which is what I have SABnzbd+ using. I am running Debian Etch 4.0r4 on my NAS server and Kubuntu 8.04 on the machine I am trying to run the tray monitor on. This is the output I get in the terminal when I run the application

root@Shuttle:/usr/src/sabnzbd-tray-mod1# ./sabnzbd-tray.py
libnotify-Message: Unable to get session bus: Failed to execute dbus-launch to autolaunch D-Bus session

The tray monitor icon shows up in the system tray but it indicates that SABnzbd+ is idle when it its actually downloading I can use the menu to open SABnzbd+ and it will open the browser to SABnzbd+ web ui.

But it does not show the status of SABnzbd+ in the system tray any ideas?

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 10th, 2008, 11:46 am
by joncfoo
Shadowtester wrote: I installed the requirements from the first post and then extracted the modified tray monitor. I edited the file from 'localhost' to the ip of my NAS server '192.168.0.120' and changed the port to '8090' which is what I have SABnzbd+ using. I am running Debian Etch 4.0r4 on my NAS server and Kubuntu 8.04 on the machine I am trying to run the tray monitor on. This is the output I get in the terminal when I run the application

root@Shuttle:/usr/src/sabnzbd-tray-mod1# ./sabnzbd-tray.py
libnotify-Message: Unable to get session bus: Failed to execute dbus-launch to autolaunch D-Bus session

The tray monitor icon shows up in the system tray but it indicates that SABnzbd+ is idle when it its actually downloading I can use the menu to open SABnzbd+ and it will open the browser to SABnzbd+ web ui.

But it does not show the status of SABnzbd+ in the system tray any ideas?
libnotify is the library that is used to show the balloon pop-ups. It seems that it can't get a hold of the dbus session that is supposed to exist every time you have a desktop session open. It is most likely not working because you are trying to run it while temporarily logged in as root which is a terrible idea (what if I had 'rm -rf /' in my script!). Run it as a regular user and let me know what happens.

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 10th, 2008, 12:09 pm
by Shadowtester
Here you go looks like the exact same problem.

shadowtester@Shuttle:/usr/src/sabnzbd-tray-mod1$ ls
CREDITS  sabnzbd-green.png  sabnzbd.png  sabnzbd-red.png  sabnzbd-tray.py
shadowtester@Shuttle:/usr/src/sabnzbd-tray-mod1$ ./sabnzbd-tray.py
libnotify-Message: Unable to get session bus: Failed to execute dbus-launch to autolaunch D-Bus session

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 10th, 2008, 12:27 pm
by joncfoo
Shadowtester wrote: Here you go looks like the exact same problem.

shadowtester@Shuttle:/usr/src/sabnzbd-tray-mod1$ ls
CREDITS  sabnzbd-green.png  sabnzbd.png  sabnzbd-red.png  sabnzbd-tray.py
shadowtester@Shuttle:/usr/src/sabnzbd-tray-mod1$ ./sabnzbd-tray.py
libnotify-Message: Unable to get session bus: Failed to execute dbus-launch to autolaunch D-Bus session
1. What version of SABnzbd+ are you using?
2. Can you capture the output of the following?

Code: Select all

ps aux | grep dbus
ls -l /usr/src/sabnzbd-tray-mod1

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 10th, 2008, 12:46 pm
by jcfp
joncfoo, thanks for looking into the kde stuff. That extra package was already installed, and with a newly created test user the issue remains. Guess it's something specific to my system or it's gtk theme settings then :(

By the way, with python 2.4 the program fails to start:

Code: Select all

$ python2.4 sabnzbd-tray.py
  File "sabnzbd-tray.py", line 141
    class SABnzbdController():
                            ^
SyntaxError: invalid syntax

Re: SABnzbd+ Tray Monitor for linux/unix, (windows maybe?)

Posted: August 10th, 2008, 1:07 pm
by joncfoo
jcfp wrote: joncfoo, thanks for looking into the kde stuff. That extra package was already installed, and with a newly created test user the issue remains. Guess it's something specific to my system or it's gtk theme settings then :(

By the way, with python 2.4 the program fails to start:

Code: Select all

$ python2.4 sabnzbd-tray.py
  File "sabnzbd-tray.py", line 141
    class SABnzbdController():
                            ^
SyntaxError: invalid syntax
I made some changes so d/l & try it again. It should now work with python 2.4 (at least over here on my machine it does :))