Skip to content

Commit

Permalink
Merge pull request #37 from asebak/percentage-reporting
Browse files Browse the repository at this point in the history
Percentage reporting
  • Loading branch information
asebak committed Jun 9, 2015
2 parents dbe3c3c + 6c32b29 commit 43a528c
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 66 deletions.
13 changes: 11 additions & 2 deletions META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
<idea-plugin version="2">
<id>com.atsebak.raspberrypi</id>
<name>Embedded Linux JVM Debugger (Raspberry Pi, Intel x86, ARM processors)</name>
<version>0.35</version>
<version>0.40</version>
<vendor email="[email protected]" url="http://www.atsebak.com">At Sebak</vendor>

<description><![CDATA[
<p>Embedded Linux Java Debugger for Embedded Systems</p>
<p>Java Debugger for Embedded Systems that run on Embedded Linux</p>
]]></description>

<change-notes><![CDATA[
<b>Version 0.40</b>
<ul>
<li>
Fixed the way java process gets terminated on remote target.
</li>
<li>
Better Check for SSH Connection
</li>
</ul>
<b>Version 0.35</b>
<ul>
<li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 8 additions & 2 deletions src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SFTPListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}

Expand Down
42 changes: 20 additions & 22 deletions src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SSHHandlerTarget.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}

/**
Expand All @@ -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"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -37,7 +37,7 @@ protected EmbeddedLinuxJVMRunConfiguration(final Project project, final Configur
@NotNull
@Override
public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
return new RaspberryPIRunConfigurationEditor(getProject());
return new RunConfigurationEditor(getProject());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.atsebak.embeddedlinuxjvm.ui.RaspberryPIRunConfigurationEditor">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.atsebak.embeddedlinuxjvm.ui.RunConfigurationEditor">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
Expand All @@ -8,7 +8,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="6bda6" binding="myGenericPanel" layout-manager="GridLayoutManager" row-count="8" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="6bda6" binding="myGenericPanel" layout-manager="GridLayoutManager" row-count="8" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="5" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
Expand All @@ -18,7 +18,7 @@
<children>
<component id="d4bb4" class="com.intellij.openapi.ui.LabeledComponent" binding="myMainClass" custom-create="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<grid row="2" column="0" row-span="1" col-span="6" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="20"/>
</grid>
</constraints>
Expand All @@ -29,7 +29,7 @@
</component>
<component id="ac4fc" class="com.intellij.openapi.ui.LabeledComponent" binding="myModule">
<constraints>
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="6" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentClass value="javax.swing.JComboBox"/>
Expand All @@ -40,21 +40,21 @@
</component>
<vspacer id="46a07">
<constraints>
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<grid row="3" column="0" row-span="1" col-span="6" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="10"/>
</grid>
</constraints>
</vspacer>
<vspacer id="e41af">
<constraints>
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<grid row="6" column="0" row-span="1" col-span="6" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="10"/>
</grid>
</constraints>
</vspacer>
<vspacer id="a3e4">
<constraints>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="6" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="9f70b" class="javax.swing.JButton" binding="validateConnection">
Expand All @@ -75,7 +75,7 @@
</component>
<component id="bb6fa" class="com.intellij.ui.RawCommandLineEditor" binding="vmParameters">
<constraints>
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="5" column="2" row-span="1" col-span="4" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
Expand All @@ -89,10 +89,18 @@
</component>
<component id="831f7" class="com.intellij.ui.RawCommandLineEditor" binding="programArguments">
<constraints>
<grid row="7" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="7" column="2" row-span="1" col-span="4" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="78ee8" class="javax.swing.JLabel" binding="sshStatus">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
</children>
</grid>
<component id="3f3eb" class="javax.swing.JLabel">
Expand Down
Loading

0 comments on commit 43a528c

Please sign in to comment.