Skip to content
Snippets Groups Projects
Commit 6e9372c0 authored by Philipp Schillinger's avatar Philipp Schillinger
Browse files

Add support for python3

parent aa61ea9e
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python #!/bin/bash
if "true" : '''\'
then
python${ROS_PYTHON_VERSION:-} "${BASH_SOURCE[0]}" $*
exit
fi
'''
# flake8: noqa
import yaml import yaml
import unittest import unittest
...@@ -18,7 +25,7 @@ class TestReport(unittest.TestCase): ...@@ -18,7 +25,7 @@ class TestReport(unittest.TestCase):
def test_report(self): def test_report(self):
try: try:
with open("/tmp/flexbe_app_report.log", 'r') as f: with open("/tmp/flexbe_app_report.log", 'r') as f:
report = yaml.load(f) report = yaml.safe_load(f)
except IOError: except IOError:
return # skip test since there is no report to evaluate return # skip test since there is no report to evaluate
for test_type, tests in report.items(): for test_type, tests in report.items():
......
...@@ -2,6 +2,7 @@ IO.StateParser = new (function() { ...@@ -2,6 +2,7 @@ IO.StateParser = new (function() {
var that = this; var that = this;
var os = require('os'); var os = require('os');
var spawn = require('child_process').spawn; 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 crypto = require('crypto');
var md5 = str => crypto.createHash('md5').update(str).digest('hex'); var md5 = str => crypto.createHash('md5').update(str).digest('hex');
...@@ -70,7 +71,7 @@ for data in iter(sys.stdin.readline, ""): ...@@ -70,7 +71,7 @@ for data in iter(sys.stdin.readline, ""):
var parseCallbacks = []; var parseCallbacks = [];
var spawnLoader = function() { var spawnLoader = function() {
loader = spawn('python', ['-c', impl]); loader = spawn(python, ['-c', impl]);
loader.stdout.on('data', (data) => { loader.stdout.on('data', (data) => {
buffer += data; buffer += data;
var try_parse = true; var try_parse = true;
......
...@@ -4,6 +4,7 @@ ROS = new (function() { ...@@ -4,6 +4,7 @@ ROS = new (function() {
var os = require('os'); var os = require('os');
var sys = require('sys'); var sys = require('sys');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');
//////////////////////////////// ////////////////////////////////
// BEGIN Python implementation // BEGIN Python implementation
...@@ -25,7 +26,7 @@ rospy.spin() ...@@ -25,7 +26,7 @@ rospy.spin()
var ros_proc = undefined; var ros_proc = undefined;
that.init = function(callback) { that.init = function(callback) {
ros_proc = spawn('python', ['-c', init_impl]); ros_proc = spawn(python, ['-c', init_impl]);
ros_proc.stdout.on('data', data => { ros_proc.stdout.on('data', data => {
data = String(data); data = String(data);
if (data.endsWith("connected")) { if (data.endsWith("connected")) {
...@@ -104,7 +105,7 @@ rospy.spin() ...@@ -104,7 +105,7 @@ rospy.spin()
callback(python_path); callback(python_path);
}); });
} else { } 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 = ''; var path_data = '';
proc.stdout.on('data', data => { proc.stdout.on('data', data => {
path_data += data; path_data += data;
......
...@@ -3,6 +3,7 @@ ROS.ActionClient = function(topic, action_type) { ...@@ -3,6 +3,7 @@ ROS.ActionClient = function(topic, action_type) {
var os = require('os'); var os = require('os');
var sys = require('sys'); var sys = require('sys');
var spawn = require('child_process').spawn; 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 feedback_cb = undefined;
var result_cb = undefined; var result_cb = undefined;
...@@ -64,7 +65,7 @@ while not rospy.is_shutdown(): ...@@ -64,7 +65,7 @@ while not rospy.is_shutdown():
// END Python implementation // END Python implementation
////////////////////////////// //////////////////////////////
var client = spawn('python', ['-c', impl, topic, action_type]); var client = spawn(python, ['-c', impl, topic, action_type]);
var buffer = ""; var buffer = "";
......
...@@ -3,6 +3,7 @@ ROS.Publisher = function(topic, msg_type, latched=false) { ...@@ -3,6 +3,7 @@ ROS.Publisher = function(topic, msg_type, latched=false) {
var os = require('os'); var os = require('os');
var sys = require('sys'); var sys = require('sys');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');
var LATCHED = "latched"; var LATCHED = "latched";
//////////////////////////////// ////////////////////////////////
...@@ -43,7 +44,7 @@ while not rospy.is_shutdown(): ...@@ -43,7 +44,7 @@ while not rospy.is_shutdown():
// END Python implementation // 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) => { pub.stdout.on('data', (data) => {
T.logInfo('[PUB:'+topic+'] ' + data); T.logInfo('[PUB:'+topic+'] ' + data);
......
...@@ -2,6 +2,7 @@ ROS.Subscriber = function(topic, msg_type, callback) { ...@@ -2,6 +2,7 @@ ROS.Subscriber = function(topic, msg_type, callback) {
var that = this; var that = this;
var sys = require('sys'); var sys = require('sys');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var python = 'python' + (process.env.ROS_PYTHON_VERSION != undefined? process.env.ROS_PYTHON_VERSION : '');
//////////////////////////////// ////////////////////////////////
// BEGIN Python implementation // BEGIN Python implementation
...@@ -34,7 +35,7 @@ rospy.spin() ...@@ -34,7 +35,7 @@ rospy.spin()
// END Python implementation // END Python implementation
////////////////////////////// //////////////////////////////
var sub = spawn('python', ['-c', impl, topic, msg_type]); var sub = spawn(python, ['-c', impl, topic, msg_type]);
var buffer = ""; var buffer = "";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment