Using xbmcaddon.Addon().getSetting()
#1
Ok im trying to check if this setting has not been set yet:

settings.xml
Code:
<setting id="TVRageLocation" type="folder" source="video" label="30009" visible="eq(-1,1)" default="" />

I have tried this
Code:
self.varStreamLocation = xbmcaddon.Addon('script.tv.promos').getSetting("TVRageLocation")
if self.varStreamLocation == None:
...

and this
Code:
self.varStreamLocation = xbmcaddon.Addon('script.tv.promos').getSetting("TVRageLocation")
if self.varStreamLocation == '':
...

neither one is working.. I had it send a notification of:

Code:
util.notify("L" + self.varStreamLocation + "L")

and it comes back as LL

so I believe its sending back nothing. I would think None should work... any ideas?
Reply
#2
==""
Use print statement to see what's setting value
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#3
sorry I only started learning python a little over a week ago, and xbmc as well..

when I use print it doesn't do anything

and I cant run it from IDLE because it errors out on import of anything xbmc related..

EDIT:::::

just found out it prints to log lol

ok here is the code:
Code:
print "TV Promos -" + self.varStreamLocation + "-"

and the result:
Code:
16:50:16 T:6072  NOTICE: TV Promos --
Reply
#4
ok I switched to == "" then back to == '' and now both work.. I have no idea why but at least now I know how to print to xbmc log so I will just have that print a line also just in case...

thank you
Reply
#5
XBMC ignores empty prints into the logfile.

If you do
Code:
print None
print ""
print some_empty_variable
you should see nothing (not even an empty line) in the log file.

If you always want to see something in the log use the "repr()" function:

Code:
print repr(some_empty_variable)
Should print you the representation of the value this variable has, e.g. "" for an empty string.

Also, the Python coding guidelines say that you always should use the python "if" expression without any compare value:
Code:
self.varStreamLocation = xbmcaddon.Addon('script.tv.promos').getSetting("TVRageLocation")
if not self.varStreamLocation:
    # do something because this setting isn't set
    pass

Another Python No-Go is comparing to "None" via "if foo == None" - if you really have a good reason to check if a value is None, use "if foo is None".
My GitHub. My Add-ons:
Image
Reply
#6
Thanks sphere.. quick question if im not supposed to use the if expression with comparison

how would I go about something like this?

If varSetting == 'Youtube':

Edit:::::

Sorry or were you saying if the value is blank thats how it should be used sorry its early here.
Reply
#7
(2013-08-24, 15:07)karrade Wrote: Thanks sphere.. quick question if im not supposed to use the if expression with comparison

how would I go about something like this?

If varSetting == 'Youtube':

Edit:::::

Sorry or were you saying if the value is blank thats how it should be used sorry its early here.

Yes, the empty if expression should of course only be used if you want to compare against empty, None, empty-list etc.
If you want to compare against any specific value, you should do so Wink
My GitHub. My Add-ons:
Image
Reply



Logout Mark Read Team Forum Stats Members Help
Using xbmcaddon.Addon().getSetting()0
This forum uses Lukasz Tkacz MyBB addons.