OK so I am lost and can't get it to work for me, just a lot of crashes.
This is what I am trying to achieve.
My config file is on a web server and gets loaded into a list when a button is pressed. The contents of the file is names of icons:
icon1
icon4
icon5
icon7
icon9
The file can list up to 36 icons
my settings file currently contains:
config.plugins.test.icon1=false
config.plugins.test.icon3=false
config.plugins.test.icon5=false
config.plugins.test.icon9=false
I download this file and save it locally. I save it into a tmp folder so I can delete it when I am finished. This forces a new download the next time the plugin runs.
target = 'http://www.webserver.co.uk/foldername/configfile.txt'configfile = urllib.URLopener()
configfile.retrieve(target + target_url, "/usr/lib/enigma2/python/Plugins/Extensions/test/tmp/configfile.txt") # having a local copy here allows me to delete it aferwards forcing a new file load next time
I now read the file into a list
data = /usr/lib/enigma2/python/Plugins/Extensions/test/tmp/configfile.txt"list = []file = open(data, 'r') for line in file: list.append(line) listcount = len(list)
now this is where I get completely stuck and don't know what I I am doing. Even trying with one value not in a list I cannot get it to work.
from Components.config import config, ConfigSubsection, ConfigSelection, ConfigDirectory, ConfigYesNo, ConfigOnOff, Config, ConfigInteger, ConfigSubList, ConfigText, getConfigListEntry, configfile
config.plugins = ConfigSubsection()config.plugins.test = ConfigSubList()
From here I get lost.
What I need to happen is:
Anything that is in the configfile gets added to the settings file
config.plugins.test.icon1=false
config.plugins.test.icon4=false
config.plugins.test.icon5=false
config.plugins.test.icon7=false
config.plugins.test.icon9=false
Anything that is no longer in the configfile gets removed from settings
config.plugins.test.icon5=false
config.plugins.test.icon9=false
The settings file then gets saved
configfile.save()
To remove them I think I would need to loop from 1 - 36. This would be before adding the new ones.
x = 0while x < 36: config.plugins.test.icon[x] = false # find every entry and remove x += 1
I am at a loss. I am sorry if it simple for you, but this really has me beaten.
Thanks in advance again.
PS, the code window is joining my lines together for some reason. I have not coded it like that.