2015-08-11, 11:16
Hi.
I am currently modding the re-Touched skin to execute a (hardware-specific) Linux binary by pressing buttons. The program is C code I Have written and compiled for Linux and embedded in OpenELEC. So far so good.
The program is invoked with different arguments depending on what skin button is pressed. It also relies upon stdout to return information to the caller. [I don't know why] I couldn't run the program with arguments using System.Exec() or System.ExecWait(). I could make it work running a wrapper shell script without any arguments. So I am currently heading towards wrapping my calls with some Python scripting.
My question is: from a skin, (how) can I call functions defined in an XBMC python library addon (i.e. extension point="xbmc.python.library")?
EDIT: Here's how I'd like my script/library to look like:
Why a library? The addon doesn't appear under the Program Addons and that suits me well.
I am currently modding the re-Touched skin to execute a (hardware-specific) Linux binary by pressing buttons. The program is C code I Have written and compiled for Linux and embedded in OpenELEC. So far so good.
The program is invoked with different arguments depending on what skin button is pressed. It also relies upon stdout to return information to the caller. [I don't know why] I couldn't run the program with arguments using System.Exec() or System.ExecWait(). I could make it work running a wrapper shell script without any arguments. So I am currently heading towards wrapping my calls with some Python scripting.
My question is: from a skin, (how) can I call functions defined in an XBMC python library addon (i.e. extension point="xbmc.python.library")?
EDIT: Here's how I'd like my script/library to look like:
Code:
#!/usr/bin/env python
import xbmc
import xbmcgui
import xbmcaddon
__ADDON__ = xbmcaddon.Addon()
__ADDONNAME__ = __ADDON__.getAddonInfo('name')
__ICON__ = __ADDON__.getAddonInfo('icon')
import os, sys
import subprocess
def notify(message, delay):
xbmc.executebuiltin('Notification(%s, "%s", %d, %s)'%(__ADDONNAME__, message, delay, __ICON__))
def k8090(*args):
try:
p = subprocess.Popen(["k8090", "-c", "/etc/k8090/config"] + list(args), stdout=subprocess.PIPE)
stdout, stderr = p.communicate()
if stderr:
notify( stderr, 3000 )
return stdout
except OSError, e:
notify( repr(e), 5000 )
def switchVideoSource():
k8090("--timer=1", "video-source")
...
Why a library? The addon doesn't appear under the Program Addons and that suits me well.