File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change
1
+ /root/.mininet-venv
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/python
2
2
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
+
4
24
import shutil
5
25
from mininet .topo import Topo
6
26
from mininet .node import Host , OVSBridge
You can’t perform that action at this time.
0 commit comments