Jump to content


Photo

assign choice s1-s2 in configlist


  • Please log in to reply
11 replies to this topic

#1 pzanone

  • Senior Member
  • 202 posts

+10
Neutral

Posted 31 October 2017 - 20:11

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

 

;) 
 

 

 

 

 

 

 



Re: assign choice s1-s2 in configlist #2 pzanone

  • Senior Member
  • 202 posts

+10
Neutral

Posted 2 November 2017 - 17:08

ok friends
no answer for me, asking too hard, I just wanted to understand how to do so not to restart the gui.
Since the server restarted when the GUI restarted.
where can i find how to, about the config load - save etc. ?
regards



Re: assign choice s1-s2 in configlist #3 zeros

  • PLi® Contributor
  • 1,635 posts

+61
Good

Posted 2 November 2017 - 20:49

I used on my one school project in a such way:

def have_internet():
conn = httplib.HTTPConnection("www.google.com", timeout=5)
try:
conn.request("HEAD", "/")
conn.close()
return True
except:
conn.close()
return False

try:
import httplib
except:
import http.client as httplib
print(have_internet())
if have_internet() == True:
print("Connection OK")
else:
print("NO connection")
import sys
from sys import exit
exit(0) # Successful exit

DM920UHD DVB-S2X TRIPLE tuner + Triple M.S tuner DVB-S2X, DVB-T2/T, QboxHD, QboxHD Mini, Icecrypt T2300HD,
Qviart Lunix3 4K, Raspberry Pi 4 Model B 4GB & 8GB

Vertex 4K60 4:4:4 600MHz


Re: assign choice s1-s2 in configlist #4 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 2 November 2017 - 20:53

For first question i can not follow exactly may be post full code if possible but asking for what are using
Global server instead server='SERVER1'
Also i see in create setup used different config from your used in your code so always you code take the first the default value
Mean you should use config.plugins.MYPLUGIN.server in create setuo

Edited by mfaraj57, 2 November 2017 - 20:56.


Re: assign choice s1-s2 in configlist #5 pzanone

  • Senior Member
  • 202 posts

+10
Neutral

Posted 2 November 2017 - 20:58

thanks @zeros very util

 

@Mfaraj57

 

Thanks so much for the reply, so myfile is not assigned when I save configuration (in config menu)?

I thought that like other parameters of folders etc. you could also assign it to an Internet address. So you can change the server according to your needs.

so at the exit of the config I always have the same server and I have to restart the GUI to have the SERVER2

 

Regards



Re: assign choice s1-s2 in configlist #6 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 2 November 2017 - 21:01

For loading settings not always needed to restart enigma just you can reload settings but i do not have the exacf syntax now may post later

Re: assign choice s1-s2 in configlist #7 zeros

  • PLi® Contributor
  • 1,635 posts

+61
Good

Posted 2 November 2017 - 21:13

You can first check out what servers are online and then have to choose, which kind of person wishes to use. If everything is down, then the corresponding notification.

DM920UHD DVB-S2X TRIPLE tuner + Triple M.S tuner DVB-S2X, DVB-T2/T, QboxHD, QboxHD Mini, Icecrypt T2300HD,
Qviart Lunix3 4K, Raspberry Pi 4 Model B 4GB & 8GB

Vertex 4K60 4:4:4 600MHz


Re: assign choice s1-s2 in configlist #8 pzanone

  • Senior Member
  • 202 posts

+10
Neutral

Posted 2 November 2017 - 21:23

You can first check out what servers are online and then have to choose, which kind of person wishes to use. If everything is down, then the corresponding notification.

yes very useful for your example, I thought of a check but it was more complicated.
I'm not very experienced, so I read a lot, but I can not learn because I forget easily. but I like to try it

 

:)



Re: assign choice s1-s2 in configlist #9 pzanone

  • Senior Member
  • 202 posts

+10
Neutral

Posted 5 November 2017 - 10:42

For loading settings not always needed to restart enigma just you can reload settings but i do not have the exacf syntax now may post later

@mfaraj57

if I do not mind, can I ask you if I can retrieve this command?
in config I can also do a server check during the selection?
have a nice Sunday

:)
 



Re: assign choice s1-s2 in configlist #10 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 5 November 2017 - 11:40

from enigma import  eDVBDB
eDVBDB.getInstance().reloadServicelist()
eDVBDB.getInstance().reloadBouquets() 

This code for reload settings



Re: assign choice s1-s2 in configlist #11 pzanone

  • Senior Member
  • 202 posts

+10
Neutral

Posted 5 November 2017 - 11:47

thanks for the reply, but this is not for settings e2?
I wondered if there was a command for the configlist,
in the plugin, in the config menu
configfile.save ()

but I have to restart to have the second server in the plugin
For example, if I save a path to config, I do not need to restart the gui

:)

load file /etc/enigma2/settings ?


Edited by pzanone, 5 November 2017 - 11:48.


Re: assign choice s1-s2 in configlist #12 pzanone

  • Senior Member
  • 202 posts

+10
Neutral

Posted 6 January 2018 - 10:24

would I renew the question if possible?
to avoid rebooting the box, how can you load the / etc / enigma2 / setting file after saving the configuration from a plugin?

unfortunately after saving the configuration, and returning to the Main schemata, the plugin does not detect the new saved data

 

regards




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users