diff --git a/gestion/gest_crans.py b/gestion/gest_crans.py index 92060d1e..c1f02ef5 100755 --- a/gestion/gest_crans.py +++ b/gestion/gest_crans.py @@ -1147,6 +1147,7 @@ def set_wifi(machine): * Puissance * Position GPS * Variables nvram + * hotspot """ if not isadm: #ça ne devrait jamais arriver mais on n'est jamais trop prudent @@ -1164,10 +1165,16 @@ def set_wifi(machine): # Borne wifi arg += u'"Canaux :" 1 1 "%s" 1 14 10 0 ' % machine.canal(None, False) arg += u'"Puissance :" 2 1 "%s" 2 14 4 0 ' % machine.puissance() - arg += u'"Position N :" 3 1 "%s" 3 14 12 0 ' % machine.position()[0] - arg += u'"Position E :" 3 29 "%s" 3 42 12 0 ' % machine.position()[1] - arg += u'"Nvram (la valeur none supprime la variable) :" 4 1 "%s" 5 1 50 0 ' % ', '.join(machine.nvram()) - + try: + arg += u'"Position N :" 3 1 "%s" 3 14 12 0 ' % machine.position()[0] + arg += u'"Position E :" 3 29 "%s" 3 42 12 0 ' % machine.position()[1] + except: + arg += u'"Position N :" 3 1 "%s" 3 14 12 0 ' % "" + arg += u'"Position E :" 3 29 "%s" 3 42 12 0 ' % "" + + arg += u'"Hotspot :" 4 1 "%s" 4 10 5 0 ' % (machine.hotspot() and 'oui' or 'non') + arg += u'"Nvram (cf wiki) :" 5 1 "%s" 6 1 50 0 ' % ', '.join(machine.nvram()) + # Affichage annul, result = dialog(arg) if annul: return 1 @@ -1176,21 +1183,36 @@ def set_wifi(machine): err = '' try: machine.canal(result[0]) except ValueError, c: err += c.args[0] + '\n' + try: machine.puissance(result[1]) except ValueError, c: err += c.args[0] + '\n' - try: machine.position((result[2].strip(),result[3].strip())) - except ValueError, c: err += c.args[0] + '\n' + try: - for nvram in result[4].split(','): + #On n'enregistre pas une position vide + if result[2].strip() and result[3].strip(): + machine.position((result[2].strip(),result[3].strip())) + except ValueError, c: err += c.args[0] + '\n' + + if result[4].lower().strip() == "oui": + machine.hotspot(True) + elif result[4].lower().strip() == "non": + machine.hotspot(False) + else: + err += "Les valeurs possibles pour le parametre hotspot\n sont \"oui\" ou \"non\"\n" + + try: + #On vérifie toutes les variables avant de sauvegarder + for nvram in result[5].split(','): if len(nvram.strip()): #On évite les variables vides if not '=' in nvram: - err += "Une variable nvram doit etre de la forme : 'variable=valeur'\n" - else : - variable = nvram.split('=')[0].strip() - valeur = nvram.split('=')[1].strip() - if valeur.lower() == "none": - valeur=None - machine.nvram(variable, valeur) + raise ValueError("Une variable nvram doit etre de la forme : 'variable=valeur'\n") + for nvram in result[5].split(','): + if len(nvram.strip()): #On évite les variables vides + variable = nvram.split('=')[0].strip() + valeur = nvram.split('=')[1].strip() + if valeur.lower() == "none": + valeur=None + machine.nvram(variable, valeur) except ValueError, c: err += c.args[0] + '\n' # Des erreurs ? if err: