Skip to content
Snippets Groups Projects
Commit 87305935 authored by legoc's avatar legoc
Browse files

Added logs transfer Cameo app

parent 990c0d63
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadgui</artifactId>
<version>4.0.127</version>
<version>4.0.128-SNAPSHOT</version>
<name>NomadGUI</name>
<description>Graphical user interface for Nomad</description>
<scm>
......
package fr.ill.ics.apps;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.Application.This;
public class LogsTransfer {
public static void main(String[] args) {
This.init(args);
try {
String logsPath = args[0];
// Executing the command in the nomadgui-release directory.
String command = "zip -r /tmp/logs.zip " + logsPath;
String[] commandList = command.split(" ");
ProcessBuilder builder = new ProcessBuilder(commandList);
try {
Process scriptProcess = builder.start();
scriptProcess.waitFor();
}
catch (IOException e) {
e.printStackTrace();
}
catch (InterruptedException e) {
}
// Reading the resulting file.
byte[] fileContent = Files.readAllBytes(FileSystems.getDefault().getPath("/tmp/logs.zip"));
// Set the result.
This.setResult(fileContent);
System.out.println("Logs sent in result " + fileContent.length);
}
catch (IOException e) {
e.printStackTrace();
}
finally {
// Do not forget to terminate This.
Application.This.terminate();
}
}
}
package fr.ill.ics.apps;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.Application.Instance;
import fr.ill.ics.cameo.Application.This;
import fr.ill.ics.cameo.Server;
public class LogsTransferCaller {
public static void main(String[] args) {
This.init(args);
if (args.length < 1) {
System.out.println("Usage: <server endpoint>");
System.exit(1);
}
try {
// Get the Cameo server.
Server server = null;
// The server endpoint is the first argument.
server = new Server(args[0]);
// Start the app.
Instance app = server.start("logstransfer");
app.waitFor();
System.out.println("Application finished");
System.out.println("Application has result: " + app.hasResult());
byte[] fileContent = app.getBinaryResult();
System.out.println("Got file content " + fileContent.length);
// Write the file content.
File file = new File("/tmp/nomadlogs.zip");
Files.write(file.toPath(), fileContent);
System.out.println("Wrote file /tmp/nomadlogs.zip");
server.terminate();
}
catch (IOException e) {
e.printStackTrace();
}
finally {
// Do not forget to terminate This.
Application.This.terminate();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment