1313import javafx .beans .binding .Bindings ;
1414import javafx .beans .property .BooleanProperty ;
1515import javafx .fxml .FXML ;
16- import javafx .scene .control .*;
16+ import javafx .scene .control .Label ;
17+ import javafx .scene .control .ProgressIndicator ;
18+ import javafx .scene .control .TextArea ;
19+ import javafx .scene .control .TextField ;
1720import net .schmizz .sshj .SSHClient ;
1821import net .schmizz .sshj .common .StreamCopier ;
1922import net .schmizz .sshj .connection .channel .direct .Session ;
4245 */
4346public class DeployController {
4447 private final static String GRIP_JAR = "grip.jar" ;
48+ private final static String GRIP_WRAPPER = "grip" ;
4549 private final static String PROJECT_FILE = "project.grip" ;
4650 private final static String LOCAL_GRIP_JAR = URLDecoder .decode (
4751 Project .class .getProtectionDomain ().getCodeSource ().getLocation ().getPath ());
@@ -152,9 +156,12 @@ public StreamCopier.Listener file(String name, long size) {
152156 StringWriter projectWriter = new StringWriter ();
153157 project .save (projectWriter );
154158
155- // Upload the GRIP core JAR and the serialized project to the robot
156- scp .upload (new StringInMemoryFile (PROJECT_FILE , projectWriter .toString ()), deployDir .getText () + "/" );
157- scp .upload (new FileSystemFile (LOCAL_GRIP_JAR ), deployDir .getText () + "/" + GRIP_JAR );
159+ // Upload the GRIP core JAR, a wrapper script to run it, and the serialized project to the robot
160+ final String commandStr = command .getText ();
161+ final String pathStr = deployDir .getText () + "/" ;
162+ scp .upload (new FileSystemFile (LOCAL_GRIP_JAR ), pathStr + GRIP_JAR );
163+ scp .upload (new StringInMemoryFile (GRIP_WRAPPER , "echo \" " + commandStr + "\" \n " + commandStr , 0755 ), pathStr );
164+ scp .upload (new StringInMemoryFile (PROJECT_FILE , projectWriter .toString ()), pathStr );
158165
159166 // Stop the pipeline before running it remotely, so the two instances of GRIP don't try to publish to the
160167 // same NetworkTables keys.
@@ -165,8 +172,7 @@ public StreamCopier.Listener file(String name, long size) {
165172 Session session = ssh .startSession ();
166173 session .allocateDefaultPTY ();
167174
168- logger .info ("Executing " + command .getText ());
169- Session .Command cmd = session .exec (command .getText ());
175+ Session .Command cmd = session .exec (String .format ("'%s/%s'" , pathStr , GRIP_WRAPPER ));
170176
171177 LineReader inputReader = new LineReader (new InputStreamReader (cmd .getInputStream ()));
172178 while (isNotCanceled ()) {
0 commit comments