Skip to content
This repository was archived by the owner on Jun 27, 2018. It is now read-only.

Commit 1f3c091

Browse files
committed
Decouple backend exec from python
Current backends (pox, ryu) are python-based, so executing them through python works, but it ties the frontend and backend to the same python version. This change should make it easier to move pyretic to python3 independent of the backend python version.
1 parent 2aacf97 commit 1f3c091

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

pyretic.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,22 +197,28 @@ def log_writer(queue, log_level):
197197
if backend_path is None:
198198
print 'Error: {} not found in PYTHONPATH'.format(backend_client)
199199
sys.exit(1)
200-
backend_exec = os.path.join(backend_path,'pox.py')
200+
# Pox is still py2-only
201+
if sys.version_info[0] == 2:
202+
python = sys.executable
203+
else:
204+
python = which("python2")
205+
if not python:
206+
print "Error: Could not find 'python2' in path."
207+
sys.exit(1)
208+
backend_exec = [python, os.path.join(backend_path, 'pox.py'), backend_client]
201209
elif options.backend == 'ryu':
202210
backend_client = 'of_client.ryu_shim'
203-
backend_exec = which('ryu-manager')
204-
if not backend_exec:
211+
ryu_exec = which('ryu-manager')
212+
if not ryu_exec:
205213
print "Error: Could not find 'ryu-manager' in path. Is ryu installed?"
214+
backend_exec = [ryu_exec, backend_client]
206215
else:
207216
print "Error: Invalid backend '{}' specified".format(options.backend)
208217
sys.exit(1)
209218

210-
python=sys.executable
211219
# TODO(josh): pipe backend stdout to subprocess.PIPE or
212220
# other log file descriptor if necessary
213-
of_client = subprocess.Popen([python,
214-
backend_exec,
215-
backend_client ],
221+
of_client = subprocess.Popen(backend_exec,
216222
stdout=sys.stdout,
217223
stderr=subprocess.STDOUT)
218224

0 commit comments

Comments
 (0)