Mercurial > hg > FederatedLinda
comparison tools/python-PE/CompactRouting/occurs/line010.py @ 8:6c40056777be
Initial revision
author | fuchita |
---|---|
date | Sat, 16 Feb 2008 13:18:02 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7:1809e2b05824 | 8:6c40056777be |
---|---|
1 import re | |
2 import sys | |
3 import string | |
4 import time | |
5 | |
6 sys.path.append('../modules') | |
7 | |
8 import FederatedLinda | |
9 | |
10 ROUTING_HEADER_FORMAT = "!I" | |
11 TUPLE_ID_LINKCONFIG = 1 | |
12 TUPLE_ID_ROUTING = 2 | |
13 | |
14 ROUTING_COMMAND_CONNECT = 1 | |
15 ROUTING_COMMAND_DISCONNECT = 2 | |
16 ROUTING_COMMAND_TRANSFER = 3 | |
17 ROUTING_COMMAND_UPDATE_TABLE = 4 | |
18 | |
19 testxml = \ | |
20 """<graph name = "Graf"> | |
21 <node label = "Node009" tsid = "ant015.cs.ie.u-ryukyu.ac.jp:10009"> | |
22 <destination label = "Node008"/> | |
23 </node> | |
24 <node label = "Node008" tsid = "ant014.cs.ie.u-ryukyu.ac.jp:10008"> | |
25 <destination label = "Node009"/> | |
26 <destination label = "Node007"/> | |
27 </node> | |
28 <node label = "Node007" tsid = "ant013.cs.ie.u-ryukyu.ac.jp:10007"> | |
29 <destination label = "Node008"/> | |
30 <destination label = "Node006"/> | |
31 </node> | |
32 <node label = "Node006" tsid = "ant012.cs.ie.u-ryukyu.ac.jp:10006"> | |
33 <destination label = "Node007"/> | |
34 <destination label = "Node000"/> | |
35 </node> | |
36 <node label = "Node005" tsid = "ant011.cs.ie.u-ryukyu.ac.jp:10005"> | |
37 <destination label = "Node004"/> | |
38 </node> | |
39 <node label = "Node004" tsid = "ant005.cs.ie.u-ryukyu.ac.jp:10004"> | |
40 <destination label = "Node003"/> | |
41 <destination label = "Node005"/> | |
42 </node> | |
43 <node label = "Node003" tsid = "ant004.cs.ie.u-ryukyu.ac.jp:10003"> | |
44 <destination label = "Node002"/> | |
45 <destination label = "Node004"/> | |
46 </node> | |
47 <node label = "Node002" tsid = "ant003.cs.ie.u-ryukyu.ac.jp:10002"> | |
48 <destination label = "Node001"/> | |
49 <destination label = "Node003"/> | |
50 </node> | |
51 <node label = "Node001" tsid = "ant002.cs.ie.u-ryukyu.ac.jp:10001"> | |
52 <destination label = "Node000"/> | |
53 <destination label = "Node002"/> | |
54 </node> | |
55 <node label = "Node000" tsid = "ant001.cs.ie.u-ryukyu.ac.jp:10000"> | |
56 <destination label = "Node006"/> | |
57 <destination label = "Node001"/> | |
58 </node> | |
59 </graph> | |
60 """ | |
61 def getFirstTsid(xmltext): | |
62 p = re.compile('(?<=tsid = \").*(?=\")') | |
63 m = p.findall(xmltext) | |
64 return m[0] | |
65 | |
66 | |
67 | |
68 if __name__ == "__main__": | |
69 | |
70 if (len(sys.argv) == 2): | |
71 print " : %s <xmlfilename>" % sys.argv[0] | |
72 xmltext = open(sys.argv[1]).read() | |
73 if xmltext is None: | |
74 sys.exit(1) | |
75 else: | |
76 xmltext = testxml | |
77 | |
78 start = time.time() | |
79 print "start time ",start | |
80 | |
81 firsttsid = getFirstTsid(xmltext) | |
82 | |
83 flinda = FederatedLinda.FederatedLinda() | |
84 | |
85 host, portnum = string.split(firsttsid,':') | |
86 | |
87 linda1 = flinda.open(host, int(portnum)) | |
88 linda1.Out(TUPLE_ID_LINKCONFIG, testxml) | |
89 flinda.sync() | |
90 | |
91 | |
92 |