RunScript problems when called from action in the configuration window ...
#1
Hello! Sorry for the automatic translation, I'll try to bring my thoughts. You can somehow solve the problem of resetting settings in the current tab of the plugin configuration window after running RunScript if the script has xbmcaddon.Addon (). SetSetting ()? It's probably better by example. If we change from the configuration window param2 or param3, and then run RunScript, the values of param2 and param3 will reset to the saved values in settings.xml, but we need to save the changed values.
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.system.testrunscript"
       name="testrunscript"
       version="0.0.0"
       provider-name="--">
  <requires>
    <import addon="xbmc.python" version="2.1.0"/>

  </requires>
  <extension point="xbmc.service" library="service.py">
    <provides></provides>
  </extension>  
  <extension point="xbmc.addon.metadata">
    <summary></summary>
    <description>

    </description>
    <disclaimer>

    </disclaimer>
    <platform>all</platform>
    <news>
    </news>
    <assets>
      <icon></icon>
      <fanart></fanart>

    </assets>
  </extension>
</addon>
script.py
Code:
import xbmcaddon

def script():    
    xbmcaddon.Addon('service.system.testrunscript').setSetting('param1', '12345678900987654321')

if __name__ == '__main__':
    script()
service.py
Code:
import subprocess
import xbmc
import xbmcaddon

class Monitor(xbmc.Monitor):

   def __init__(self, *args, **kwargs):
      xbmc.Monitor.__init__(self)
      self.id = xbmcaddon.Addon().getAddonInfo('id')

   def onSettingsChanged(self):
      subprocess.call(['systemctl', 'restart', self.id])


if __name__ == "__main__":
   Monitor().waitForAbort()
settings.xml
Code:
<?xml version="1.0" encoding="UTF-8"  standalone="yes"?>
<settings>
   <category label="category 1">
        <setting label="RunScript" type="action" action="RunScript(special://home/addons/service.system.testrunscript/script.py)" />
        <setting label="12345678900987654321" type="text" id="param1" default="00000000000000000" enable="false" />
        <setting id="param2" label="param2" type="labelenum" values="0|1" />        
        <setting default="100" id="param3" label="param3" type="number" />
    </category>
    <category label="category 2">
        <setting default="true" id="param4" label="param4" type="bool" />        
    </category>    
</settings>
Reply
#2
i don't think there is a solution for that.
settings are only saved when you close the settings dialog.

when you run your addon while the settings screen is open, it will load the saved values
and as such, you'll loose any pending changes.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
edit: perhaps you can test with Kodi v18, we recently changed the settings system for addons and i think (not 100% sure) settings are saved instantly now.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#4
Thanks for the advice, but Kodi v18 is not yet on the list, but I think it's very good that it will be the way you wrote it. The problem solved when put RunScript in a separate tab. Certainly not beautiful, but it works.
Once again, sorry for the online translation, I hope everyone understands.
Reply
#5
sure loud and clear ;-)

glad you've found a way to work around the problem!
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply

Logout Mark Read Team Forum Stats Members Help
RunScript problems when called from action in the configuration window ...0