From 6702a5ae441740c4c14e1cac8da0c040c11e4cac Mon Sep 17 00:00:00 2001 From: ahmadsebak Date: Fri, 5 Jun 2015 04:56:29 -0400 Subject: [PATCH 1/4] improved ssh validation check --- .../EmbeddedLinuxJVMBundle.properties | 5 +- .../protocol/ssh/SSHConnectionValidator.java | 15 ++--- .../EmbeddedLinuxJVMRunConfiguration.java | 4 +- ...ditor.form => RunConfigurationEditor.form} | 26 ++++++--- ...ditor.java => RunConfigurationEditor.java} | 57 ++++++++++++------- 5 files changed, 67 insertions(+), 40 deletions(-) rename src/com/atsebak/embeddedlinuxjvm/ui/{RaspberryPIRunConfigurationEditor.form => RunConfigurationEditor.form} (89%) rename src/com/atsebak/embeddedlinuxjvm/ui/{RaspberryPIRunConfigurationEditor.java => RunConfigurationEditor.java} (72%) diff --git a/src/com/atsebak/embeddedlinuxjvm/localization/EmbeddedLinuxJVMBundle.properties b/src/com/atsebak/embeddedlinuxjvm/localization/EmbeddedLinuxJVMBundle.properties index 9b1cb6f..f150594 100644 --- a/src/com/atsebak/embeddedlinuxjvm/localization/EmbeddedLinuxJVMBundle.properties +++ b/src/com/atsebak/embeddedlinuxjvm/localization/EmbeddedLinuxJVMBundle.properties @@ -15,15 +15,18 @@ pi.deployment.finished=Finished Deploying Java Application On The Embedded Targe pi.deployment.build=>>>>>>>>> You're Building on Embedded Linux <<<<<<<< pi.deployment.command=Executing Command \: pi.ssh.connection.error=SSH Connection Error -pi.ssh.remote.error=Could not connect to remote target pi.packagename=Base Package pi.connection.notsetup=Click on the run configuration settings to setup the remote connection for the raspberry pi. pi.connection.required=Remote Connection Not Setup Yet. pi.runner.name=Run Raspberry PI pi.validationconection=Validate Connection ssh.connection.success=Connection Success +ssh.remote.error=Could not connect to remote target pi.connection.success.title=Remote Connection Made pi.upload=Uploading\n\r pi.deploy=Deploying to remote target pi.closingsession=Terminating Debug Session on Remote Target pi.validatingconnection=Validating SSH Connection +ssh.tryingtoconnect=Trying to contact remote target... +app.vmoptions=VM Options +app.programargs=Program Arguments diff --git a/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SSHConnectionValidator.java b/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SSHConnectionValidator.java index d0866b3..9b936a2 100644 --- a/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SSHConnectionValidator.java +++ b/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SSHConnectionValidator.java @@ -1,8 +1,6 @@ package com.atsebak.embeddedlinuxjvm.protocol.ssh; -import com.atsebak.embeddedlinuxjvm.localization.EmbeddedLinuxJVMBundle; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; import lombok.Builder; import net.schmizz.sshj.SSHClient; import org.jetbrains.annotations.NotNull; @@ -29,21 +27,20 @@ public boolean canConnectToHostname(int timeout) { } } + /** - * See if user can connect to remote target - * + * Can connect to remote target * @param client * @param project - * @throws IOException + * @return status */ - public void checkSSHConnection(SSHClient client, @NotNull Project project) throws IOException { + public boolean checkSSHConnection(SSHClient client, @NotNull Project project) { try { client.connect(ip); client.authPassword(username, password); - Messages.showInfoMessage(project, EmbeddedLinuxJVMBundle.getString("ssh.connection.success"), EmbeddedLinuxJVMBundle.getString("pi.connection.success.title")); + return true; } catch (Exception e) { - Messages.showErrorDialog(project, EmbeddedLinuxJVMBundle.getString("pi.ssh.remote.error"), - EmbeddedLinuxJVMBundle.getString("pi.ssh.connection.error")); + return false; } } diff --git a/src/com/atsebak/embeddedlinuxjvm/runner/conf/EmbeddedLinuxJVMRunConfiguration.java b/src/com/atsebak/embeddedlinuxjvm/runner/conf/EmbeddedLinuxJVMRunConfiguration.java index 862f82d..3b74dc4 100644 --- a/src/com/atsebak/embeddedlinuxjvm/runner/conf/EmbeddedLinuxJVMRunConfiguration.java +++ b/src/com/atsebak/embeddedlinuxjvm/runner/conf/EmbeddedLinuxJVMRunConfiguration.java @@ -3,7 +3,7 @@ import com.atsebak.embeddedlinuxjvm.commandline.AppCommandLineState; import com.atsebak.embeddedlinuxjvm.runner.data.EmbeddedLinuxJVMRunConfigurationRunnerParameters; import com.atsebak.embeddedlinuxjvm.runner.data.EmbeddedLinuxJVMRunnerValidator; -import com.atsebak.embeddedlinuxjvm.ui.RaspberryPIRunConfigurationEditor; +import com.atsebak.embeddedlinuxjvm.ui.RunConfigurationEditor; import com.intellij.execution.ExecutionException; import com.intellij.execution.Executor; import com.intellij.execution.configurations.*; @@ -37,7 +37,7 @@ protected EmbeddedLinuxJVMRunConfiguration(final Project project, final Configur @NotNull @Override public SettingsEditor getConfigurationEditor() { - return new RaspberryPIRunConfigurationEditor(getProject()); + return new RunConfigurationEditor(getProject()); } /** diff --git a/src/com/atsebak/embeddedlinuxjvm/ui/RaspberryPIRunConfigurationEditor.form b/src/com/atsebak/embeddedlinuxjvm/ui/RunConfigurationEditor.form similarity index 89% rename from src/com/atsebak/embeddedlinuxjvm/ui/RaspberryPIRunConfigurationEditor.form rename to src/com/atsebak/embeddedlinuxjvm/ui/RunConfigurationEditor.form index e9c2ee2..1221755 100644 --- a/src/com/atsebak/embeddedlinuxjvm/ui/RaspberryPIRunConfigurationEditor.form +++ b/src/com/atsebak/embeddedlinuxjvm/ui/RunConfigurationEditor.form @@ -1,5 +1,5 @@ -
+ @@ -8,7 +8,7 @@ - + @@ -18,7 +18,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -40,21 +40,21 @@ - + - + - + @@ -75,7 +75,7 @@ - + @@ -89,10 +89,18 @@ - + + + + + + + + + diff --git a/src/com/atsebak/embeddedlinuxjvm/ui/RaspberryPIRunConfigurationEditor.java b/src/com/atsebak/embeddedlinuxjvm/ui/RunConfigurationEditor.java similarity index 72% rename from src/com/atsebak/embeddedlinuxjvm/ui/RaspberryPIRunConfigurationEditor.java rename to src/com/atsebak/embeddedlinuxjvm/ui/RunConfigurationEditor.java index 9879f4e..d74a8ea 100644 --- a/src/com/atsebak/embeddedlinuxjvm/ui/RaspberryPIRunConfigurationEditor.java +++ b/src/com/atsebak/embeddedlinuxjvm/ui/RunConfigurationEditor.java @@ -1,5 +1,6 @@ package com.atsebak.embeddedlinuxjvm.ui; +import com.atsebak.embeddedlinuxjvm.localization.EmbeddedLinuxJVMBundle; import com.atsebak.embeddedlinuxjvm.protocol.ssh.SSH; import com.atsebak.embeddedlinuxjvm.protocol.ssh.SSHConnectionValidator; import com.atsebak.embeddedlinuxjvm.runner.conf.EmbeddedLinuxJVMRunConfiguration; @@ -10,6 +11,8 @@ import com.intellij.execution.ui.ConfigurationModuleSelector; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SettingsEditor; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.LabeledComponent; import com.intellij.psi.JavaCodeFragment; @@ -24,11 +27,11 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.IOException; -public class RaspberryPIRunConfigurationEditor extends SettingsEditor implements PanelWithAnchor { +public class RunConfigurationEditor extends SettingsEditor implements PanelWithAnchor { private final ConfigurationModuleSelector myModuleSelector; private final Project myProject; private LabeledComponent myMainClass; @@ -43,6 +46,7 @@ public class RaspberryPIRunConfigurationEditor extends SettingsEditor Date: Tue, 9 Jun 2015 00:21:04 -0400 Subject: [PATCH 2/4] fixes #30 --- .../protocol/ssh/SFTPListener.java | 10 ++++- .../protocol/ssh/SSHHandlerTarget.java | 42 +++++++++---------- .../ui/RunConfigurationEditor.java | 2 - 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SFTPListener.java b/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SFTPListener.java index 36391cc..9123aae 100644 --- a/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SFTPListener.java +++ b/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SFTPListener.java @@ -40,10 +40,16 @@ public TransferListener directory(String name) { */ public StreamCopier.Listener file(String name, final long size) { consoleView.print(EmbeddedLinuxJVMBundle.getString("pi.upload"), ConsoleViewContentType.SYSTEM_OUTPUT); +// StatusBar statusBar = WindowManager.getInstance().getStatusBar(consoleView.getProject()); +// final StatusBarProgress statusBarProgress = new StatusBarProgress(); +// statusBarProgress.start(); return new StreamCopier.Listener() { + @Override public void reportProgress(long transferred) throws IOException { -// long percent = (transferred * 100) / size; -// consoleView.print(String.format("%s% \n\r", percent), ConsoleViewContentType.SYSTEM_OUTPUT); +// statusBarProgress.setText("test"); +// float percent = (float) (transferred * 100) / size; +// statusBarProgress.setFraction(percent); +// consoleView.print(String.format("%s%%", percent), ConsoleViewContentType.SYSTEM_OUTPUT); } }; } diff --git a/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SSHHandlerTarget.java b/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SSHHandlerTarget.java index 3fce42d..f53181b 100644 --- a/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SSHHandlerTarget.java +++ b/src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SSHHandlerTarget.java @@ -1,10 +1,10 @@ package com.atsebak.embeddedlinuxjvm.protocol.ssh; import com.atsebak.embeddedlinuxjvm.commandline.LinuxCommand; -import com.atsebak.embeddedlinuxjvm.runner.data.EmbeddedLinuxJVMRunConfigurationRunnerParameters; -import com.atsebak.embeddedlinuxjvm.utils.FileUtilities; import com.atsebak.embeddedlinuxjvm.console.EmbeddedLinuxJVMConsoleView; import com.atsebak.embeddedlinuxjvm.localization.EmbeddedLinuxJVMBundle; +import com.atsebak.embeddedlinuxjvm.runner.data.EmbeddedLinuxJVMRunConfigurationRunnerParameters; +import com.atsebak.embeddedlinuxjvm.utils.FileUtilities; import com.intellij.execution.configurations.RuntimeConfigurationException; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.notification.Notification; @@ -58,12 +58,14 @@ private void forceCreateDirectories(String path) throws IOException, RuntimeConf SSHClient ssh = this.ssh.toClient(); connect(ssh); final Session session = ssh.startSession(); - String cmd = LinuxCommand.builder() - .commands(Arrays.asList( + String cmd = LinuxCommand.builder().commands( + Arrays.asList( String.format("mkdir -p %s", path), String.format("cd %s", path), "rm -rf *" - )).build().toString(); + )) + .build() + .toString(); consoleView.print(EmbeddedLinuxJVMBundle.getString("pi.deployment.command") + cmd + NEW_LINE, ConsoleViewContentType.SYSTEM_OUTPUT); session.exec(cmd); @@ -102,24 +104,20 @@ private void runJavaApp(String path, String cmd) throws IOException, RuntimeConf connect(sshClient); final Session session = sshClient.startSession(); - - String jarCmd = LinuxCommand.builder() - .commands(Arrays.asList( - "sudo killall java", //todo fix, kills all java processes but we only need the current one with the same port killed process + String jarCmd = LinuxCommand.builder().commands + (Arrays.asList( + String.format("sudo kill -9 $(ps -efww | grep \"%s\"| grep -v grep | tr -s \" \"| cut -d\" \" -f2)", piRunnerParameters.getMainclass()), String.format("cd %s", path), String.format("tar -xvf %s.tar", consoleView.getProject().getName()), "rm *.tar", - cmd - )).build().toString(); - session.setAutoExpand(true); - try { - consoleView.print(EmbeddedLinuxJVMBundle.getString("pi.deployment.command") + jarCmd + NEW_LINE, ConsoleViewContentType.SYSTEM_OUTPUT); - Session.Command exec = session.exec(jarCmd); - consoleView.setCommand(exec); - new StreamCopier(exec.getInputStream(), System.out).spawn("stdout"); - new StreamCopier(exec.getErrorStream(), System.err).spawn("stderr"); - } finally { - } + cmd)) + .build() + .toString(); + consoleView.print(EmbeddedLinuxJVMBundle.getString("pi.deployment.command") + jarCmd + NEW_LINE, ConsoleViewContentType.SYSTEM_OUTPUT); + Session.Command exec = session.exec(jarCmd); + consoleView.setCommand(exec); + new StreamCopier(exec.getInputStream(), System.out).spawn("stdout"); + new StreamCopier(exec.getErrorStream(), System.err).spawn("stderr"); } /** @@ -137,10 +135,10 @@ private void connect(SSHClient client) throws IOException, RuntimeConfigurationE if (!client.isAuthenticated() && !client.isConnected()) { final Notification notification = new Notification( com.atsebak.embeddedlinuxjvm.utils.Notifications.GROUPDISPLAY_ID, - EmbeddedLinuxJVMBundle.getString("pi.ssh.connection.error"), EmbeddedLinuxJVMBundle.getString("pi.ssh.remote.error"), + EmbeddedLinuxJVMBundle.getString("pi.ssh.connection.error"), EmbeddedLinuxJVMBundle.getString("ssh.remote.error"), NotificationType.ERROR); Notifications.Bus.notify(notification); - throw new RuntimeConfigurationException(EmbeddedLinuxJVMBundle.getString("pi.ssh.remote.error")); + throw new RuntimeConfigurationException(EmbeddedLinuxJVMBundle.getString("ssh.remote.error")); } } } diff --git a/src/com/atsebak/embeddedlinuxjvm/ui/RunConfigurationEditor.java b/src/com/atsebak/embeddedlinuxjvm/ui/RunConfigurationEditor.java index d74a8ea..58fbecd 100644 --- a/src/com/atsebak/embeddedlinuxjvm/ui/RunConfigurationEditor.java +++ b/src/com/atsebak/embeddedlinuxjvm/ui/RunConfigurationEditor.java @@ -66,7 +66,6 @@ public void run() { progressIndicator.setText(EmbeddedLinuxJVMBundle.getString("ssh.tryingtoconnect")); progressIndicator.setIndeterminate(true); } - validateConnection.setEnabled(false); boolean success = SSHConnectionValidator .builder() .ip(hostName.getText()) @@ -76,7 +75,6 @@ public void run() { .connectionTimeout(10000) .timeout(10000) .build().toClient(), project); - validateConnection.setEnabled(true); sshStatus.setVisible(true); if (success) { sshStatus.setText(EmbeddedLinuxJVMBundle.getString("ssh.connection.success")); From ef9005bd7f0d4d1ef1437bb438583b35b8b1c32e Mon Sep 17 00:00:00 2001 From: ahmadsebak Date: Tue, 9 Jun 2015 00:23:12 -0400 Subject: [PATCH 3/4] update release version --- META-INF/plugin.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml index ead5511..092f670 100644 --- a/META-INF/plugin.xml +++ b/META-INF/plugin.xml @@ -1,14 +1,20 @@ com.atsebak.raspberrypi Embedded Linux JVM Debugger (Raspberry Pi, Intel x86, ARM processors) - 0.35 + 0.40 At Sebak Embedded Linux Java Debugger for Embedded Systems

+

Java Debugger for Embedded Systems that run on Embedded Linux

]]>
Version 0.40 +
    +
  • + Fixed the way java process gets terminated on remote target. +
  • +
Version 0.35
  • From 6c32b2973fb640c2312ba06a5af7567005c845d3 Mon Sep 17 00:00:00 2001 From: ahmadsebak Date: Tue, 9 Jun 2015 00:24:36 -0400 Subject: [PATCH 4/4] more release notes --- META-INF/plugin.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml index 092f670..cf45c77 100644 --- a/META-INF/plugin.xml +++ b/META-INF/plugin.xml @@ -14,6 +14,9 @@
  • Fixed the way java process gets terminated on remote target.
  • +
  • + Better Check for SSH Connection +
Version 0.35