-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubstitui_router_contramedida.py
executable file
·50 lines (38 loc) · 1.78 KB
/
substitui_router_contramedida.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
# encoding: utf-8
# Juliano Fischer Naves
# 23 de Outubro de 2013
import os,sys
def procura_no_arquivo(absolute_path):
list = []
f = open(absolute_path,'r')
lines = f.read().splitlines()
for line in lines:
new_line = line
if "EpidemicRouter" in line and "Scenario.name" not in line:
new_line = line.split("EpidemicTTLAttackRouter")[0] #+ "EpidemicBlackHoleRouter\n"
elif "ProphetRouter" in line and "Scenario.name" not in line:
new_line = line.split("ProphetTTLAttackRouter")[0] #+ "ProphetBlakcHoleMRouter\n"
if "SprayAndWaitRouter" in line and "Scenario.name" not in line:
new_line = line.split("SprayAndWaitTTLAttackRouter")[0] #+ "SprayAndWaitBlackHoleRouter\n"
if "EpidemicTTLAttackRouter" in line and "Scenario.name" not in line:
new_line = line.split("EpidemicTTLAttackRouter")[0] + "EpidemicBlackHoleRouter\n"
elif "ProphetTTLAttackRouter" in line and "Scenario.name" not in line:
new_line = line.split("ProphetTTLAttackRouter")[0] + "ProphetBlakcHoleMRouter\n"
if "SprayAndWaitTTLAttackRouter" in line and "Scenario.name" not in line:
new_line = line.split("SprayAndWaitTTLAttackRouter")[0] + "SprayAndWaitBlackHoleRouter\n"
#if "Report.reportDir" in line:
# line = line.split('cenarioblackhole')
# new_line = line[0]+"cenarioblackhole/comcontramedida"+line[1]
list.append(new_line)
f = open(absolute_path,'w')
for l in list:
f.write(l)
f.write('\n')
f.flush()
f.close()
if __name__ == '__main__':
for root, dirs, files in os.walk('.'):
for file in files:
f = os.path.abspath(root) + "/" + file
procura_no_arquivo(os.path.abspath(f))