Skip to content

Commit

Permalink
Fix detection of new packages
Browse files Browse the repository at this point in the history
  • Loading branch information
pschillinger committed Mar 4, 2020
1 parent d45efc7 commit 6bbfed1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
5 changes: 2 additions & 3 deletions src/io/io_packageparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ IO.PackageParser = new (function() {
var add_behaviors = [];

ROS.getPackageList((pkg_list) => {
pkg_cache.forEach(entry => { pkg_list.remove(entry); });
pkg_list = pkg_list.filter(entry => pkg_cache.findElement(cached => cached['name'] == entry['name']) == undefined);
var pkg_count = pkg_list.length;
if (pkg_count > 0) {
//T.logInfo("Checking "+pkg_count+" newly detected ROS packages for states and behaviors...");
T.logInfo("Checking "+pkg_count+" ROS packages for states and behaviors...");
T.logInfo("Checking "+pkg_count+" ROS packages for states and behaviors ("+pkg_cache.length+" in cache)...");
} else {
T.logInfo("No new ROS packages detected ("+pkg_cache.length+" in cache).");
}
Expand Down
54 changes: 27 additions & 27 deletions src/ros/ros.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,35 +99,35 @@ rospy.spin()
break;
}
}
});
if (python_path !== undefined) {
process.nextTick(() => {
callback(python_path);
});
} else {
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;
});
proc.stderr.on('data', data => {
console.log(package_name+" failed to import: "+data);
});
proc.on('close', (code) => {
if (path_data != "") {
python_path = path_data.replace(/\n/g, '');
for (var i=0; i<package_cache.length; i++) {
if (package_cache[i]['name'] == package_name) {
package_cache[i]['python_path'] = python_path;
break;
if (python_path !== undefined) {
process.nextTick(() => {
callback(python_path);
});
} else {
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;
});
proc.stderr.on('data', data => {
console.log(package_name+" failed to import: "+data);
});
proc.on('close', (code) => {
if (path_data != "") {
python_path = path_data.replace(/\n/g, '');
for (var i=0; i<package_cache.length; i++) {
if (package_cache[i]['name'] == package_name) {
package_cache[i]['python_path'] = python_path;
break;
}
}
callback(python_path);
} else {
callback(undefined);
}
callback(python_path);
} else {
callback(undefined);
}
});
}
});
}
});
}

// that.getParam = function(name, callback) {
Expand Down

0 comments on commit 6bbfed1

Please sign in to comment.