Skip to content

Commit

Permalink
Add support for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
pschillinger committed Jul 24, 2020
1 parent aa61ea9 commit 6e9372c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
11 changes: 9 additions & 2 deletions bin/test_report
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/usr/bin/env python
#!/bin/bash
if "true" : '''\'
then
python${ROS_PYTHON_VERSION:-} "${BASH_SOURCE[0]}" $*
exit
fi
'''
# flake8: noqa
import yaml
import unittest
Expand All @@ -18,7 +25,7 @@ class TestReport(unittest.TestCase):
def test_report(self):
try:
with open("/tmp/flexbe_app_report.log", 'r') as f:
report = yaml.load(f)
report = yaml.safe_load(f)
except IOError:
return # skip test since there is no report to evaluate
for test_type, tests in report.items():
Expand Down
3 changes: 2 additions & 1 deletion src/io/io_stateparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ IO.StateParser = new (function() {
var that = this;
var os = require('os');
var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');
var crypto = require('crypto');
var md5 = str => crypto.createHash('md5').update(str).digest('hex');

Expand Down Expand Up @@ -70,7 +71,7 @@ for data in iter(sys.stdin.readline, ""):
var parseCallbacks = [];

var spawnLoader = function() {
loader = spawn('python', ['-c', impl]);
loader = spawn(python, ['-c', impl]);
loader.stdout.on('data', (data) => {
buffer += data;
var try_parse = true;
Expand Down
5 changes: 3 additions & 2 deletions src/ros/ros.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ROS = new (function() {
var os = require('os');
var sys = require('sys');
var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');

////////////////////////////////
// BEGIN Python implementation
Expand All @@ -25,7 +26,7 @@ rospy.spin()
var ros_proc = undefined;

that.init = function(callback) {
ros_proc = spawn('python', ['-c', init_impl]);
ros_proc = spawn(python, ['-c', init_impl]);
ros_proc.stdout.on('data', data => {
data = String(data);
if (data.endsWith("connected")) {
Expand Down Expand Up @@ -104,7 +105,7 @@ rospy.spin()
callback(python_path);
});
} else {
var proc = spawn('python', ['-c', `import importlib; print(importlib.import_module('` + package_name + `').__path__[-1])`]);
var proc = spawn(python, ['-c', `import importlib; print(importlib.import_module('` + package_name + `').__path__[-1])`]);
var path_data = '';
proc.stdout.on('data', data => {
path_data += data;
Expand Down
3 changes: 2 additions & 1 deletion src/ros/ros_actionclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ROS.ActionClient = function(topic, action_type) {
var os = require('os');
var sys = require('sys');
var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');

var feedback_cb = undefined;
var result_cb = undefined;
Expand Down Expand Up @@ -64,7 +65,7 @@ while not rospy.is_shutdown():
// END Python implementation
//////////////////////////////

var client = spawn('python', ['-c', impl, topic, action_type]);
var client = spawn(python, ['-c', impl, topic, action_type]);

var buffer = "";

Expand Down
3 changes: 2 additions & 1 deletion src/ros/ros_publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ROS.Publisher = function(topic, msg_type, latched=false) {
var os = require('os');
var sys = require('sys');
var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');

var LATCHED = "latched";
////////////////////////////////
Expand Down Expand Up @@ -43,7 +44,7 @@ while not rospy.is_shutdown():
// END Python implementation
//////////////////////////////

var pub = spawn('python', ['-c', impl, topic, msg_type, latched? LATCHED : "_"]);
var pub = spawn(python, ['-c', impl, topic, msg_type, latched? LATCHED : "_"]);

pub.stdout.on('data', (data) => {
T.logInfo('[PUB:'+topic+'] ' + data);
Expand Down
3 changes: 2 additions & 1 deletion src/ros/ros_subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ROS.Subscriber = function(topic, msg_type, callback) {
var that = this;
var sys = require('sys');
var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');

////////////////////////////////
// BEGIN Python implementation
Expand Down Expand Up @@ -34,7 +35,7 @@ rospy.spin()
// END Python implementation
//////////////////////////////

var sub = spawn('python', ['-c', impl, topic, msg_type]);
var sub = spawn(python, ['-c', impl, topic, msg_type]);

var buffer = "";

Expand Down

0 comments on commit 6e9372c

Please sign in to comment.