Skip to content

Commit 853035d

Browse files
committed
Add .venv to 8r-1c-srv6-pm
1 parent 86592ef commit 853035d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

nets/8r-1c-srv6-pm/.venv

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

nets/8r-1c-srv6-pm/isis8d.py

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

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

0 commit comments

Comments
 (0)