Jump to content


Photo

catching specific events in python plugin


  • Please log in to reply
3 replies to this topic

#1 malakudi

  • Senior Member
  • 1,449 posts

+69
Good

Posted 17 December 2013 - 16:25

Is it possible to "catch" specific events in enigma2 python plugin? I want to create a plugin that will gather statistics when for example:

- User changes channel

- User switches volume up/down

- User starts recording

- User puts the box in standby/out of standby

and various similar stuff. Is this somehow possible? Is there any example?

 



Re: catching specific events in python plugin #2 MiLo

  • PLi® Core member
  • 14,049 posts

+298
Excellent

Posted 17 December 2013 - 17:03

Start recording has events you can subscribe to, see the Trashcan for an example.

For things that don't have notifications, you can always "hook" up something extra:

Code should look something like this:
class MyHooker:
    def __init__(self, other):
        self.counter = 0
        self.original = other.some_method
        other.some_method = self.my_method
    def my_method(self):
        self.counter += 1
        self.original()
Untested, so probably needs some extra tuning to get it to work.
Real musicians never die - they just decompose

Re: catching specific events in python plugin #3 radxnl

  • Senior Member
  • 1,527 posts

+57
Good

Posted 17 December 2013 - 17:05

yes should be all possible, some quick examples ( not all, but if you search enigma2 / enigma2-plugins or such you should be fine )

 

standby:

config.misc.standbyCounter.addNotifier(self.StandbyCallback, initial_call = False)

change channel could be monitored by the evStart, maybe you need to check if it's a live channel or media but thats up to you ;)
 

        self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
        {
            iPlayableService.evStart: self.evStartCallback
        })

for recording should be simular to this, please check it

 

volume you probably need to hook to the volume keys ( see i.e. the multiquickbutton or something like that )

 

also the plugin needs to autostart ( so it is activated when enigma2 starts ), find some examples, they are plenty

 

hope this helps...



Re: catching specific events in python plugin #4 littlesat

  • PLi® Core member
  • 56,376 posts

+692
Excellent

Posted 17 December 2013 - 17:26

Is it also possible to induce an evStart event?

WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users