Quantcast
Channel: [EN] OpenPLi Third-Party Development
Viewing all articles
Browse latest Browse all 1690

assign choice s1-s2 in configlist

$
0
0

a small question for you experts.
I can not assign the configured server configured to config

es.

 

 

In configlist

.............
sessions = []
config.plugins.MYPLUGIN = ConfigSubsection()

config.plugins.MYPLUGIN.server = ConfigSelection(default='SERVER1', choices=[('SERVER', _('SERVER1')), ('SERVER2', _('SERVER2'))])

 

............

global server

if config.plugins.MYPLUGIN.server.value == 'SERVER1' :
    server = 'http://forum.openpli.org'
if config.plugins.MYPLUGIN.server.value == 'SERVER2' :
    server = 'http://server.fake.fake'

myfile = ('%smyfile.txt' % server)

 

............................................

 

class Server(screen):

.............

.............

 

    def checkmyfile(self):
        url = myfilet
        getPage(url).addCallback(self.CheckOK).addErrback(self.CheckNOK)

 

    def CheckOK(self, data):
        try:
            self['text'].setText('ok')
        except:
            self['text'].setText('No OK')

    def CheckNOK(self, error):
        self['text'].setText_('Server Off')

 

 

########################

 

class Config(Screen, ConfigListScreen):

............

.........

....

 

    def createSetup(self):
        self.editListEntry = None
        self.list = []
        self.list.append(getConfigListEntry(_('Server:'), config.plugins.fReE_iPtV_pAnDa_SaT_tEaM.server))
        self['config'].list = self.list
        self["config"].setList(self.list)

 

 

    def save(self):
        if self['config'].isChanged():
            for x in self['config'].list:
                x[1].save()
            configfile.save()
            self.mbox = self.session.open(MessageBox, _('Settings saved'), MessageBox.TYPE_INFO, timeout=5)
            self.close()
        else:
            self.close()

 

 

 

######################

 

the problem is that if server1 or server2 (fake-no-connection) is always found with server1 and myfile is downloaded (in this case the message is always checkOk)
What escapes me ..

of course i checked in etc / enigma2 / setting is the selected Server is saved.
even leaving the plugin and coming back is the same.

 

sorry for my google english
thanks for the answer if it's not the right place as well, I'll see how to fix it

 

;) 
 

 

 

 

 

 

 


Viewing all articles
Browse latest Browse all 1690

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>