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

Commit

Permalink
Decouple backend exec from python
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JamesGuthrie committed May 26, 2015
1 parent 2aacf97 commit 1f3c091
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pyretic.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,28 @@ def log_writer(queue, log_level):
if backend_path is None:
print 'Error: {} not found in PYTHONPATH'.format(backend_client)
sys.exit(1)
backend_exec = os.path.join(backend_path,'pox.py')
# Pox is still py2-only
if sys.version_info[0] == 2:
python = sys.executable
else:
python = which("python2")
if not python:
print "Error: Could not find 'python2' in path."
sys.exit(1)
backend_exec = [python, os.path.join(backend_path, 'pox.py'), backend_client]
elif options.backend == 'ryu':
backend_client = 'of_client.ryu_shim'
backend_exec = which('ryu-manager')
if not backend_exec:
ryu_exec = which('ryu-manager')
if not ryu_exec:
print "Error: Could not find 'ryu-manager' in path. Is ryu installed?"
backend_exec = [ryu_exec, backend_client]
else:
print "Error: Invalid backend '{}' specified".format(options.backend)
sys.exit(1)

python=sys.executable
# TODO(josh): pipe backend stdout to subprocess.PIPE or
# other log file descriptor if necessary
of_client = subprocess.Popen([python,
backend_exec,
backend_client ],
of_client = subprocess.Popen(backend_exec,
stdout=sys.stdout,
stderr=subprocess.STDOUT)

Expand Down

0 comments on commit 1f3c091

Please sign in to comment.