Differenze tra le versioni 1 e 2
⇤ ← Versione 1 del 2007-07-01 14:58:08
Dimensione: 921
Commento:
|
← Versione 2 del 2008-03-18 17:27:55 ⇥
Dimensione: 921
Commento: converted to 1.6 markup
|
Nessuna differenza riscontrata. |
Questo script si utilizza con il dot_draw plugin di olsrd. Esempio:
./dumpolsrdot.py | dot -Tpng | display -
Codice:
1 #!/usr/bin/env python
2
3 #dumps the current OLSR topology in dot format (using the dot_draw plugin) to standard output
4
5 import telnetlib
6 import sys
7
8 def readfromdotplugin(host='127.0.0.1',port='2004',timeout=120, exitonerror=True):
9 try:
10 dotcon=telnetlib.Telnet(host,port)
11 except:
12 sys.stderr.write("Error. Can't connect to %s:%s.\n" % (host,port))
13 if exitonerror:
14 sys.exit(2)
15 else:
16 return ""
17 dotoutput=""
18 dotoutput=dotcon.read_until('}',timeout)
19 dotoutput+='\n'
20 dotcon.close()
21 return dotoutput
22 #readfromdotplugin
23
24 if __name__=="__main__":
25 print readfromdotplugin()