Hi all,
I'm developing a script to keep listening if the database updated.
I found that xbmc.Monitor has a method onDatabaseUpdated
Here is my code:
Quote:import xbmc
import xbmcgui
import os
class MyMonitor(xbmc.Monitor):
def __init__( self, *args, **kwargs ):
xbmc.Monitor.__init__( self )
def onDatabaseUpdated( self ):
xbmc.log( "Database Updated!" )
monitor = MyMonitor()
And here is the xbmc logs error:
Quote:02:57:07 T:6108 ERROR: EXCEPTION: access_voilation
02:57:07 T:6108 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.RuntimeError'>
Error Contents: access_voilation
Traceback (most recent call last):
File "C:\Users\Sultan\AppData\Roaming\XBMC\scripts\yazeeddbupdated.py", line 48, in <module>
monitor = MyMonitor()
RuntimeError: access_voilation
-->End of Python script error report<--
Any help please?
I tried it. the same error
Here is the log:
Quote:10:18:26 T:10884 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.RuntimeError'>
Error Contents: access_voilation
Traceback (most recent call last):
File "C:\Users\Sultan\AppData\Roaming\XBMC\scripts\yazeeddbupdated.py", line 59, in <module>
monitor = MyMonitor()
RuntimeError: access_voilation
-->End of Python script error report<--
First of all make sure that when indenting the code, you use either spaces or tabs. Don't mix them because that can lead to funny errors. I use 4 spaces myself.
Change
Code:
def onDatabaseUpdated( self ):
to
Code:
def onDatabaseUpdated( self, database ):
If that does not work try the following addon (this works for me).
Create a service.dbupdate directory in your addon directory and add the following files:
addon.xml:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.dbupdate"
name="DBUpdate"
version="0.1.0"
provider-name="yourname">
<requires>
<import addon="xbmc.python" version="2.14.0"/>
</requires>
<extension point="xbmc.service" library="service.py" start="startup"/>
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<summary lang="en">Log when the database is updated.</summary>
<description>Log when the database is updated.</description>
<license>GPL 2.0</license>
</extension>
</addon>
service.py:
Code:
import os
import xbmc
class MyMonitor(xbmc.Monitor):
def onDatabaseUpdated(self, database):
xbmc.log("service.dbupdate: onDatabaseUpdated()")
if (__name__ == "__main__"):
xbmc.log("service.dbupdate: Starting: DBUpdate v0.1.0")
monitor = MyMonitor()
while (not xbmc.abortRequested):
xbmc.sleep(1000)
del monitor
xbmc.log("service.dbupdate: Stopped: DBUpdate v0.1.0")
After starting XBMC and updating the library:
Quote:~/.xbmc/temp$ tail -F xbmc.log |grep service.dbupdate
tail: ‘xbmc.log’ has been replaced; following end of new file
18:06:57 T:140218510325504 NOTICE: service.dbupdate: Starting: DBUpdate v0.1.0
18:07:08 T:140218510325504 NOTICE: service.dbupdate: onDatabaseUpdated()
18:07:16 T:140218510325504 NOTICE: service.dbupdate: Stopped: DBUpdate v0.1.0
It worked leechguy :-)
Thank you so much,
I think the problem is that I was trying to access xbmc.Monitor via scripts. I didn't defined my script as addon.
Thank you again guys for the awesome help.
Cool
Good luck with your add-on!
Hi,
I've tried the service.dbupdate example as i have a problem with xbmc.Monitor in Jarvis (Debian (16.1 Debian package version: 16.1+dfsg1-2). Platform: Linux x86 64-bit)
When you enable/disable the service the whole kodi interface get stuck.
Any idea of an other way to kill the xbmc.Monitor thread ?
pci.
Finally i found it.
I've got another service that "attach" an xbmcaddon.Addon() object in the xbmc.Monitor child class.
If think it create a lock.
I think when i tried to enable/disable the service.dbupdate my kodi instance was in bad condition due to the other service doing weird things.
An example of thing to avoid:
class AnotherMonitor(xbmc.Monitor):
def __init__(self):
self.myaddon=xbmcaddon.Addon() <-- This is a really bad idea