From e936aaee7923ae255707279acf6e615b1d67b6b2 Mon Sep 17 00:00:00 2001 From: glondu Date: Tue, 12 Dec 2006 00:32:39 +0100 Subject: [PATCH] Mise en forme, souplesse dans les programmes multithreads. darcs-hash:20061211233239-68412-69ad7e1c5c87531fd725df075e3b5d2d7fd15433.gz --- gestion/tools/locate-mac.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gestion/tools/locate-mac.py b/gestion/tools/locate-mac.py index 53b154be..7352d12b 100755 --- a/gestion/tools/locate-mac.py +++ b/gestion/tools/locate-mac.py @@ -42,17 +42,17 @@ class interroge_switch (threading.Thread) : # Retourne les infos sur la machine (l'équivalent d'un whos, mais renvoie la # chaîne de caractères) def info_machine(mac): - s = u"" + s = [] db = crans_ldap() machines = db.search("mac=%s" % mac)['machine'] for m in machines: r = whos.machine_details(m) # On supprime les couleurs r = sre.sub('\x1b\[1;([0-9]|[0-9][0-9])m', '', r) - s += r + s.append(r) if len(machines) == 0: - s = u"Recherche LDAP de la MAC %s : aucune machine trouvée\n" % mac - return s + s.append(u"Recherche LDAP de la MAC %s : aucune machine trouvée\n" % mac) + return u"\n".join(s) # interrogation des switchs en parallele @@ -62,8 +62,8 @@ def trace_machine(mac): for switch in ['backbone'] + all_switchs(): tableau.append(interroge_switch(switch, mac)) - while len(threading.enumerate()) > 1 : - sleep(1) + for t in tableau: + t.join() resultat = u'Traçage de %s...\n' % mac