|
|
|
Re: Python script from Kura [message #1705906 is a reply to message #1692605] |
Wed, 19 August 2015 23:11 |
|
I know this is an old post but just to give an update for other users in need, one can use Eclipse Kura's Inbuilt Feature of executing a Process. Eclipse Kura Core Bundle has classes to execute Process in a separate thread.
Eg.
SafeProcess process = null;
BufferedReader br = null;
final String[] command = { CMD_PYTHON, CMD_PYTHON_ARG };
try {
process = ProcessUtil.exec(command);
br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
if (line.contains("command not found")) {
LOGGER.error("Resetting Command Not Found");
throw new KuraException(KuraErrorCode.OPERATION_NOT_SUPPORTED);
}
}
LOGGER.info("Executing process...Done");
} catch (final Exception e) {
LOGGER.error(Throwables.getStackTraceAsString(e));
} finally {
try {
LOGGER.debug("Closing Buffered Reader and destroying Process", process);
br.close();
process.destroy();
} catch (final IOException e) {
LOGGER.error("Error closing read buffer", Throwables.getStackTraceAsString(e));
}
}
Amit Kumar Mondal
Email: admin@amitinside.com
Skype: arsenalnerk Blog: blog.amitinside.com
|
|
|
Powered by
FUDForum. Page generated in 0.05069 seconds