[Rhythmbox-devel] python plugin not found



Hi,

I am trying to write a rythmbox plugin that registers a global hotkey
and deletes the currently played file when the hotkey is pressed (to get
quickly rid of music I want to sort out of my collection).
I'm new to python programming and this is my first plugin ever.

-------

This is the folder i have put the plugin into:
/home/<user>/.gnome2/rhythmbox/plugins/DeleteFile/

-- There is a deletefile.rb-plugin:

[RB Plugin]
Loader=python
Module=deletefile
IAge=1
Name=Delete current song from harddisk
Description=Deletes the current song when ALT+UP is pressed.
Authors=gsubes gmail com
Copyright=Copyright © 2009 subes
Website=https://sourceforge.net/users/subes

-- And there is a __init__.py:

import rb
import os
from Xlib import X
from Xlib import Display
from IPython.Extensions.ipy_synchronize_with import sleep

class DeleteFilePlugin (rb.Plugin):
    # ALT+UP
    delete_key = 111
    delete_mask = 0x8

    shell
    display
    root
    doListen = false
    listening = false

    # init plugin and tell X that we want keyrelease events
    def __init__(self):
        rb.Plugin.__init__(self)
        self.display = Display()
        self.root = display.screen().root
        self.root.change_attributes(event_mask = X.KeyReleaseMask)

    # register hotkey and start listening
    def activate(self, shell):
        self.shell = shell
        registerHotkey()
        self.doListen = true
        listen()

    # stop listening, unregister hotkey and clean up
    def deactivate(self, shell):
        self.doListen = false
        while(self.listening):
            sleep(100)
        unregisterHotkey()
        self.display.close()
        del shell
        del display
        del root
        del doListen
        del listening

    # register the hotkey
    def register_hotkey(self):
        self.grab_key(delete_key, X.AnyModifier, 1, X.GrabModeAsync,
X.GrabModeAsync)


    def unregister_hotkey(self):
        self.root.ungrab_key(delete_key, X.AnyModifier)

    def listen(self):
        self.listening = true
        while(self.doListen):
            # sleep as long as no event was found
            while(root.display.pending_events() == 0 and self.doListen):
                sleep(100)
            if(not self.doListen):
                break

            # handle event
            event = self.root.display.next_event()
            if event.type == X.KeyRelease and event.detail ==
delete_key:
                mask = event.state & delete_mask
                if mask == delete_mask:
                    delete()
        self.listening = false

    def delete(self):
        file = self.shell.props.shell_player.get_playing_path()
        self.shell.props.shell_player.do_next()
        os.remove(file)
        notify = "notify-send Gel\xc3scht "+file
        os.system(notify)

-------

When I start rhythmbox, the plugin is shown but when I try to enable it,
the rhythmbox debug output tells me the following:

(16:21:47) [0x2241040] [rb_python_module_init] rb-python-module.c:420:
Init of python module
ImportError: No module named deletefile

(rhythmbox:19790): Rhythmbox-WARNING **: Could not load plugin
deletefile

(16:21:48) [0x2241040] [rb_python_module_finalize]
rb-python-module.c:427: Finalizing python module (null)

(rhythmbox:19790): Rhythmbox-WARNING **: Error, impossible to activate
plugin 'Delete current song from harddisk'
(16:21:48) [0x2241040] [plugin_manager_set_active]
rb-plugin-manager.c:301: Could not activate Delete current song from
harddisk.

-------

Testing the file with python __init__.py fails with the following (so
atleast no syntax errors):

Traceback (most recent call last):
  File "__init__.py", line 1, in <module>
    import rb
ImportError: No module named rb

-------

Is there some way to properly debug plugins?
Maybe you have an idea why the plugin cannot be enabled?

Best regards,
subes




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]