Skip to content

Commit 2d9f159

Browse files
committed
Add .venv to 3routers, 8routers and 8routers-isis-ipv6 topologies
1 parent ededeee commit 2d9f159

File tree

8 files changed

+71
-2
lines changed

8 files changed

+71
-2
lines changed

nets/3routers/.venv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/root/.mininet-venv

nets/3routers/ospf3r.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
#!/usr/bin/python
22

33
import os
4+
5+
# Activate virtual environment if a venv path has been specified in .venv
6+
# This must be executed only if this file has been executed as a
7+
# script (instead of a module)
8+
if __name__ == '__main__':
9+
# Check if .venv file exists
10+
if os.path.exists('.venv'):
11+
with open('.venv', 'r') as venv_file:
12+
# Get virtualenv path from .venv file
13+
venv_path = venv_file.read()
14+
# Get path of the activation script
15+
venv_path = os.path.join(venv_path, 'bin/activate_this.py')
16+
if not os.path.exists(venv_path):
17+
print('Virtual environment path specified in .venv '
18+
'points to an invalid path\n')
19+
exit(-2)
20+
with open(venv_path) as f:
21+
# Read the activation script
22+
code = compile(f.read(), venv_path, 'exec')
23+
# Execute the activation script to activate the venv
24+
exec(code, {'__file__': venv_path})
25+
426
import shutil
527
from mininet.topo import Topo
628
from mininet.node import Host

nets/8r-1c-in-band-isis/isis8d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44

5-
# Activate virtual environment
5+
# Activate virtual environment if a venv path has been specified in .venv
66
# This must be executed only if this file has been executed as a
77
# script (instead of a module)
88
if __name__ == '__main__':

nets/8r-1c-out-band-isis/isis8d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44

5-
# Activate virtual environment
5+
# Activate virtual environment if a venv path has been specified in .venv
66
# This must be executed only if this file has been executed as a
77
# script (instead of a module)
88
if __name__ == '__main__':

nets/8routers-isis-ipv6/.venv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/root/.mininet-venv

nets/8routers-isis-ipv6/isis8d.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
#!/usr/bin/python
22

33
import os
4+
5+
# Activate virtual environment if a venv path has been specified in .venv
6+
# This must be executed only if this file has been executed as a
7+
# script (instead of a module)
8+
if __name__ == '__main__':
9+
# Check if .venv file exists
10+
if os.path.exists('.venv'):
11+
with open('.venv', 'r') as venv_file:
12+
# Get virtualenv path from .venv file
13+
venv_path = venv_file.read()
14+
# Get path of the activation script
15+
venv_path = os.path.join(venv_path, 'bin/activate_this.py')
16+
if not os.path.exists(venv_path):
17+
print('Virtual environment path specified in .venv '
18+
'points to an invalid path\n')
19+
exit(-2)
20+
with open(venv_path) as f:
21+
# Read the activation script
22+
code = compile(f.read(), venv_path, 'exec')
23+
# Execute the activation script to activate the venv
24+
exec(code, {'__file__': venv_path})
25+
426
import shutil
527
from mininet.topo import Topo
628
from mininet.node import Host

nets/8routers/.venv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/root/.mininet-venv

nets/8routers/ospf8r.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
#!/usr/bin/python
22

33
import os
4+
5+
# Activate virtual environment if a venv path has been specified in .venv
6+
# This must be executed only if this file has been executed as a
7+
# script (instead of a module)
8+
if __name__ == '__main__':
9+
# Check if .venv file exists
10+
if os.path.exists('.venv'):
11+
with open('.venv', 'r') as venv_file:
12+
# Get virtualenv path from .venv file
13+
venv_path = venv_file.read()
14+
# Get path of the activation script
15+
venv_path = os.path.join(venv_path, 'bin/activate_this.py')
16+
if not os.path.exists(venv_path):
17+
print('Virtual environment path specified in .venv '
18+
'points to an invalid path\n')
19+
exit(-2)
20+
with open(venv_path) as f:
21+
# Read the activation script
22+
code = compile(f.read(), venv_path, 'exec')
23+
# Execute the activation script to activate the venv
24+
exec(code, {'__file__': venv_path})
25+
426
import shutil
527
from mininet.topo import Topo
628
from mininet.node import Host

0 commit comments

Comments
 (0)