HOW-TO write GUI settings for XBMC python plugins and scripts (addons)

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
teshephe Offline
Senior Member
Posts: 107
Joined: Dec 2009
Reputation: 0
Post: #61
I am trying to use a script within my plugin to prepopulate items in the settings based on the local host, the script itself works up to the point of actually putting the returned data into the designated setting I have specified.

Here is my code:

Oo
Code:
import subprocess, platform
            ipaddr=''
            
            arg='ip route list'    
            p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
            data = p.communicate()
            sdata = data[0].split()
            ipaddr = sdata[ sdata.index('src')+1 ]
            #netdev = sdata[ sdata.index('dev')+1 ]
            localhost = '' + ipaddr
        self.settings.setSetting(id="localhost", value=""+localhost+"" )


Help would be appreciated. Thanks!Big Grin

Enjoy OpenSource! :nod:
MY SETUP: XBMC 12 Frodo RC3, Multiple Asus EB1501's throughout the Home for XBMC based STB's
find quote
amet Offline
How do ya like them apples?
Posts: 4,099
Joined: Jul 2009
Reputation: 39
Location: Novi Sad / Dubai
Post: #62
Code:
import subprocess, platform
            ipaddr=''
            
            arg='ip route list'    
            p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
            data = p.communicate()
            sdata = data[0].split()
            ipaddr = sdata[ sdata.index('src')+1 ]
            #netdev = sdata[ sdata.index('dev')+1 ]
            #localhost = '' + ipaddr
        self.settings.setSetting(id="localhost", value=ipaddr)

should work fine, if not post the debug log


Always read the XBMC_Online_Manual,Frequently_Asked_Questions and search the forum before posting.
For troubleshooting and bug reporting use -> Log_file.
find quote
teshephe Offline
Senior Member
Posts: 107
Joined: Dec 2009
Reputation: 0
Post: #63
Amet Wrote:should work fine, if not post the debug log

Nope:

This is what I get:

Code:
15:06:30 T:139681446573840 M:3015421952   ERROR: Traceback (most recent call last):
                                              File "/home/tshepherd/.xbmc/addons/plugin.program.multiroomaudio/default.py", line 20, in ?
                                                plugin.Main()
                                              File "/home/tshepherd/.xbmc/addons/plugin.program.multiroomaudio/resources/lib/multiroomaudio_plugin.py", line 60, in __init__
                                                self._get_localhostip()
                                              File "/home/tshepherd/.xbmc/addons/plugin.program.multiroomaudio/resources/lib/multiroomaudio_plugin.py", line 1068, in _get_localhostip
                                                data = p.communicate()
                                              File "/usr/lib/xbmc/system/python/python24.zip/subprocess.py", line 1083, in communicate
                                                self.wait()
                                              File "/usr/lib/xbmc/system/python/python24.zip/subprocess.py", line 1007, in wait
                                                pid, sts = os.waitpid(self.pid, 0)
                                            OSError: (10, 'No child processes')
15:06:30 T:139681446573840 M:3015421952    INFO: -->End of Python script error report<--
Confused

Enjoy OpenSource! :nod:
MY SETUP: XBMC 12 Frodo RC3, Multiple Asus EB1501's throughout the Home for XBMC based STB's
find quote
amet Offline
How do ya like them apples?
Posts: 4,099
Joined: Jul 2009
Reputation: 39
Location: Novi Sad / Dubai
Post: #64
you said it worked up to the point of putting it in to the setting, obviously not


Always read the XBMC_Online_Manual,Frequently_Asked_Questions and search the forum before posting.
For troubleshooting and bug reporting use -> Log_file.
find quote
teshephe Offline
Senior Member
Posts: 107
Joined: Dec 2009
Reputation: 0
Post: #65
Amet Wrote:you said it worked up to the point of putting it in to the setting, obviously not

Strange, it does if I run it in a python shell but does not in XBMC, Any Ideas??

Enjoy OpenSource! :nod:
MY SETUP: XBMC 12 Frodo RC3, Multiple Asus EB1501's throughout the Home for XBMC based STB's
find quote
amet Offline
How do ya like them apples?
Posts: 4,099
Joined: Jul 2009
Reputation: 39
Location: Novi Sad / Dubai
Post: #66
teshephe Wrote:Strange, it does if I run it in a python shell but does not in XBMC, Any Ideas??

what is the IP address from? the machine running xbmc?

Code:
import xbmc
self.settings.setSetting(id="localhost", value=xbmc.getIPAddress())


Always read the XBMC_Online_Manual,Frequently_Asked_Questions and search the forum before posting.
For troubleshooting and bug reporting use -> Log_file.
(This post was last modified: 2010-09-09 21:50 by amet.)
find quote
teshephe Offline
Senior Member
Posts: 107
Joined: Dec 2009
Reputation: 0
Post: #67
Amet Wrote:what is the IP address from? the machine running xbmc?

Yes, all local.Nerd

Enjoy OpenSource! :nod:
MY SETUP: XBMC 12 Frodo RC3, Multiple Asus EB1501's throughout the Home for XBMC based STB's
find quote
amet Offline
How do ya like them apples?
Posts: 4,099
Joined: Jul 2009
Reputation: 39
Location: Novi Sad / Dubai
Post: #68
teshephe Wrote:Yes, all local.Nerd

Code:
import xbmc
self.settings.setSetting(id="localhost", value=xbmc.getIPAddress())


Always read the XBMC_Online_Manual,Frequently_Asked_Questions and search the forum before posting.
For troubleshooting and bug reporting use -> Log_file.
find quote
chippyash Offline
Senior Member
Posts: 130
Joined: Jan 2010
Reputation: 0
Location: Northants, UK
Post: #69
@amet
made changes you suggest, still same error in debug

Code:
DEBUG: OnKey: 61453 pressed, action is Select
DEBUG: ------ Window Deinit (DialogContextMenu.xml) ------
DEBUG: ADDON: cpluff: 'Could not return information about unknown plug-in .'

What else can I try to track down reason for error - is there some extra debugging I can use?

System info: Asrock ION330HT-BD (Intel Atom 330 4 core i686) connected to Sony KDL-Z5800 TV using hdmi via Onkyo TX-SR507 AV Amp. [Old Config Ubuntu 12.04. (Linux 3.2.0-32-generic-pae ) XBMCBuntu (Eden 11.0 Git:unknown Compiled Mar 24 2012). OpenGL 3.3.0 NVIDIA 280.13] New Config unknown - no working XBMC at moment!
find quote
amet Offline
How do ya like them apples?
Posts: 4,099
Joined: Jul 2009
Reputation: 39
Location: Novi Sad / Dubai
Post: #70
chippyash Wrote:@amet
made changes you suggest, still same error in debug

Code:
DEBUG: OnKey: 61453 pressed, action is Select
DEBUG: ------ Window Deinit (DialogContextMenu.xml) ------
DEBUG: ADDON: cpluff: 'Could not return information about unknown plug-in .'

What else can I try to track down reason for error - is there some extra debugging I can use?

dont worry about that error, its harmless Smile I must have about million of them in my log


Always read the XBMC_Online_Manual,Frequently_Asked_Questions and search the forum before posting.
For troubleshooting and bug reporting use -> Log_file.
find quote
teshephe Offline
Senior Member
Posts: 107
Joined: Dec 2009
Reputation: 0
Post: #71
Amet Wrote:what is the IP address from? the machine running xbmc?

Code:
import xbmc
self.settings.setSetting(id="localhost", value=xbmc.getIPAddress())

Thanks! I had to change it a little to Addon.setSetting(id="localhost", value=xbmc.getIPAddress()) though.

You rock!! Now how about that font question (bump)? Big Grin

Enjoy OpenSource! :nod:
MY SETUP: XBMC 12 Frodo RC3, Multiple Asus EB1501's throughout the Home for XBMC based STB's
find quote
amet Offline
How do ya like them apples?
Posts: 4,099
Joined: Jul 2009
Reputation: 39
Location: Novi Sad / Dubai
Post: #72
teshephe Wrote:Thanks! I had to change it a little to Addon.setSetting(id="localhost", value=xbmc.getIPAddress()) though.

yeah, copy/paste can be a bitch Smile

teshephe Wrote:You rock!! Now how about that font question (bump)? Big Grin

no way to set a different font for settings atm, sry Sad


Always read the XBMC_Online_Manual,Frequently_Asked_Questions and search the forum before posting.
For troubleshooting and bug reporting use -> Log_file.
find quote
chippyash Offline
Senior Member
Posts: 130
Joined: Jan 2010
Reputation: 0
Location: Northants, UK
Post: #73
Amet Wrote:dont worry about that error, its harmless Smile I must have about million of them in my log

yeah but the settings dialog still doesn't show up!

System info: Asrock ION330HT-BD (Intel Atom 330 4 core i686) connected to Sony KDL-Z5800 TV using hdmi via Onkyo TX-SR507 AV Amp. [Old Config Ubuntu 12.04. (Linux 3.2.0-32-generic-pae ) XBMCBuntu (Eden 11.0 Git:unknown Compiled Mar 24 2012). OpenGL 3.3.0 NVIDIA 280.13] New Config unknown - no working XBMC at moment!
find quote
amet Offline
How do ya like them apples?
Posts: 4,099
Joined: Jul 2009
Reputation: 39
Location: Novi Sad / Dubai
Post: #74
chippyash Wrote:yeah but the settings dialog still doesn't show up!

works just fine here, what does it look like? any errors?


Always read the XBMC_Online_Manual,Frequently_Asked_Questions and search the forum before posting.
For troubleshooting and bug reporting use -> Log_file.
find quote
chippyash Offline
Senior Member
Posts: 130
Joined: Jan 2010
Reputation: 0
Location: Northants, UK
Post: #75
Amet Wrote:works just fine here, what does it look like? any errors?
Only the error that I am showing you in the debug (cpluff error). The dialog simply doesn't display as I expect when I click on Addon Settings from the context menu.

I also ran the addon on my production XBMC server which is Ubuntu. Same problem

Also, can you point me to the up to date documentation for settings, I'd like to include it in the new documentation I'm writing - I think JM cc'd you in on the issue trac ticket

Thanks
Ashley

System info: Asrock ION330HT-BD (Intel Atom 330 4 core i686) connected to Sony KDL-Z5800 TV using hdmi via Onkyo TX-SR507 AV Amp. [Old Config Ubuntu 12.04. (Linux 3.2.0-32-generic-pae ) XBMCBuntu (Eden 11.0 Git:unknown Compiled Mar 24 2012). OpenGL 3.3.0 NVIDIA 280.13] New Config unknown - no working XBMC at moment!
find quote
Post Reply