* Champ position des bornes
* whos -h plus concis darcs-hash:20060313215451-68412-33985b31e41aabeba4f38fad4426029b2d4bf8f8.gz
This commit is contained in:
parent
6604677322
commit
3fe5d7be00
2 changed files with 80 additions and 33 deletions
|
@ -242,7 +242,8 @@ class crans_ldap:
|
||||||
'hostname': 'host',
|
'hostname': 'host',
|
||||||
'mac': 'macAddress',
|
'mac': 'macAddress',
|
||||||
'ip': 'ipHostNumber',
|
'ip': 'ipHostNumber',
|
||||||
'telephone': 'tel'}
|
'telephone': 'tel',
|
||||||
|
'position': 'positionBorne'}
|
||||||
|
|
||||||
# Les différentes classes LDAP de machines
|
# Les différentes classes LDAP de machines
|
||||||
ldap_machines_classes = ['machineFixe', 'machineWifi', 'machineCrans', 'borneWifi']
|
ldap_machines_classes = ['machineFixe', 'machineWifi', 'machineCrans', 'borneWifi']
|
||||||
|
@ -276,7 +277,8 @@ class crans_ldap:
|
||||||
'mailAlias', 'info', 'controle'], \
|
'mailAlias', 'info', 'controle'], \
|
||||||
'machineFixe': non_auto_search_machines_champs,
|
'machineFixe': non_auto_search_machines_champs,
|
||||||
'machineCrans': non_auto_search_machines_champs + ['prise'],
|
'machineCrans': non_auto_search_machines_champs + ['prise'],
|
||||||
'borneWifi': non_auto_search_machines_champs + ['prise', 'puissance', 'canal'],
|
'borneWifi': non_auto_search_machines_champs + \
|
||||||
|
['prise', 'puissance', 'canal', 'hotspot', 'positionBorne'],
|
||||||
'machineWifi': non_auto_search_machines_champs + ['ipsec'] }
|
'machineWifi': non_auto_search_machines_champs + ['ipsec'] }
|
||||||
|
|
||||||
# Profondeur des différentes recherches (scope)
|
# Profondeur des différentes recherches (scope)
|
||||||
|
@ -2671,10 +2673,11 @@ class BorneWifi(Machine):
|
||||||
|
|
||||||
def __init__(self, parent_or_tuple, typ='borne', conn=None):
|
def __init__(self, parent_or_tuple, typ='borne', conn=None):
|
||||||
Machine.__init__(self, parent_or_tuple, typ, conn)
|
Machine.__init__(self, parent_or_tuple, typ, conn)
|
||||||
# Initialisaton par défaut spécifique
|
if not isinstance(parent_or_tuple, tuple):
|
||||||
self._data['canal'] = ['2047']
|
# Initialisaton par défaut spécifique
|
||||||
self._data['puissance'] = ['60']
|
self._data['canal'] = ['2047']
|
||||||
self._data['hotspot'] = ['FALSE']
|
self._data['puissance'] = ['60']
|
||||||
|
self._data['hotspot'] = ['FALSE']
|
||||||
|
|
||||||
def mac2(self):
|
def mac2(self):
|
||||||
""" Retourne l'adresse MAC + 2 """
|
""" Retourne l'adresse MAC + 2 """
|
||||||
|
@ -2767,6 +2770,29 @@ class BorneWifi(Machine):
|
||||||
self._set('puissance', [str(new)])
|
self._set('puissance', [str(new)])
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
def position(self, new=False):
|
||||||
|
"""
|
||||||
|
Attribution ou visualisation de la position d'une borne wifi.
|
||||||
|
Renvoie un couple de coordonnées si elles existent, None sinon.
|
||||||
|
new doit être un couple de coordonnées, None (pour enlever les
|
||||||
|
coordonnées) ou False (retourne les valeurs actuelles).
|
||||||
|
"""
|
||||||
|
if new == False:
|
||||||
|
valeur = (self._data.get('positionBorne') or [''])[0]
|
||||||
|
if valeur:
|
||||||
|
valeur = valeur.split(' ')
|
||||||
|
return (float(valeur[0]), float(valeur[1]))
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
elif new == None:
|
||||||
|
self._set('positionBorne', [])
|
||||||
|
return None
|
||||||
|
|
||||||
|
else:
|
||||||
|
self._set('positionBorne', ['%.6g %.6g' % (new[0], new[1])])
|
||||||
|
return new
|
||||||
|
|
||||||
|
|
||||||
class _fake_proprio(crans_ldap):
|
class _fake_proprio(crans_ldap):
|
||||||
""" Définitions de base d'un propriétaire virtuel """
|
""" Définitions de base d'un propriétaire virtuel """
|
||||||
|
|
|
@ -498,10 +498,14 @@ def machine_details(machine) :
|
||||||
# Borne wifi
|
# Borne wifi
|
||||||
if isinstance(machine, BorneWifi):
|
if isinstance(machine, BorneWifi):
|
||||||
f += coul(u'Hotspot : ', 'gras')
|
f += coul(u'Hotspot : ', 'gras')
|
||||||
if machine.hotspot():
|
f += machine.hotspot() and 'oui' or 'non'
|
||||||
f += 'oui\n'
|
position = machine.position()
|
||||||
|
if position:
|
||||||
|
f += coul(u'\t\t\tCoordonnées : ', 'gras')
|
||||||
|
f += '(%.6g, %.6g)\n' % (position[0], position[1])
|
||||||
else:
|
else:
|
||||||
f += 'non\n'
|
f += '\n'
|
||||||
|
|
||||||
f += coul(u'Puissance : ','gras') + u"%4.d" % int(machine.puissance())
|
f += coul(u'Puissance : ','gras') + u"%4.d" % int(machine.puissance())
|
||||||
f += coul(u'\tCanaux : ', 'gras') + machine.canal()
|
f += coul(u'\tCanaux : ', 'gras') + machine.canal()
|
||||||
f += coul(u'\tÉtat : ', 'gras')
|
f += coul(u'\tÉtat : ', 'gras')
|
||||||
|
@ -821,32 +825,49 @@ def __usage_brief(err='') :
|
||||||
|
|
||||||
def __usage() :
|
def __usage() :
|
||||||
""" Comment ca marche ? """
|
""" Comment ca marche ? """
|
||||||
list = ['']
|
liste = []
|
||||||
for c in base.auto_search_champs.values() :
|
accu = ""
|
||||||
for champ in c :
|
longueur = 0
|
||||||
coul_champ = coul(champ,'bleu')
|
|
||||||
if list[-1] == '' :
|
|
||||||
list[-1] = coul_champ
|
|
||||||
l = len(champ)
|
|
||||||
else :
|
|
||||||
l += len(champ) + 2
|
|
||||||
if l < 80 :
|
|
||||||
list[-1] += ', ' + coul_champ
|
|
||||||
else :
|
|
||||||
list.append(coul_champ)
|
|
||||||
l = len(champ)
|
|
||||||
|
|
||||||
for c in base.non_auto_search_champs.values() :
|
# Champs automatiques
|
||||||
for champ in c :
|
champs = []
|
||||||
l += len(champ) + 2
|
for c in base.auto_search_champs.values():
|
||||||
if l < 80 :
|
for champ in c:
|
||||||
list[-1] += ', ' + champ
|
if champ not in champs:
|
||||||
else :
|
champs.append(champ)
|
||||||
list.append(champ)
|
for champ in champs:
|
||||||
l = len(champ)
|
coul_champ = coul(champ, "bleu")
|
||||||
|
if accu == "":
|
||||||
|
accu = coul_champ
|
||||||
|
longueur = len(champ)
|
||||||
|
elif longueur + 2 + len(champ) < 80:
|
||||||
|
longueur += 2 + len(champ)
|
||||||
|
accu += ", " + coul_champ
|
||||||
|
else:
|
||||||
|
liste.append(accu)
|
||||||
|
accu = coul_champ
|
||||||
|
longueur = len(champ)
|
||||||
|
|
||||||
|
# Champs manuels
|
||||||
|
champs = []
|
||||||
|
for c in base.non_auto_search_champs.values():
|
||||||
|
for champ in c:
|
||||||
|
if champ not in champs:
|
||||||
|
champs.append(champ)
|
||||||
|
for champ in champs:
|
||||||
|
if longueur + 2 + len(champ) < 80:
|
||||||
|
longueur += 2 + len(champ)
|
||||||
|
accu += ", " + champ
|
||||||
|
else:
|
||||||
|
liste.append(accu)
|
||||||
|
accu = champ
|
||||||
|
longueur = len(champ)
|
||||||
|
|
||||||
|
# Dernière ligne
|
||||||
|
liste.append(accu)
|
||||||
|
|
||||||
print __doc__ % { 'prog' : sys.argv[0].split('/')[-1].split('.')[0] ,
|
print __doc__ % { 'prog' : sys.argv[0].split('/')[-1].split('.')[0] ,
|
||||||
'champs_rech' : '\n'.join(list) ,
|
'champs_rech' : '\n'.join(liste) ,
|
||||||
'limit_aff_details' : limit_aff_details ,
|
'limit_aff_details' : limit_aff_details ,
|
||||||
'limit_aff_historique' : limit_aff_historique }
|
'limit_aff_historique' : limit_aff_historique }
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue