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 unittest
......@@ -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():
......
......@@ -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');
......@@ -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;
......
......@@ -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
......@@ -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")) {
......@@ -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;
......
......@@ -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;
......@@ -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 = "";
......
......@@ -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";
////////////////////////////////
......@@ -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);
......
......@@ -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
......@@ -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 = "";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment