All of lore.kernel.org
 help / color / mirror / Atom feed
* [Refactor RFC 0/9] Merging of windows-build with master
@ 2013-06-04 13:25 Ioana Grigoropol
  2013-06-04 13:26 ` [Refactor RFC 1/9] Rename RSEHelper to RemoteHelper to match usages in org.yocto.bc.ui.plugin Ioana Grigoropol
                   ` (9 more replies)
  0 siblings, 10 replies; 20+ messages in thread
From: Ioana Grigoropol @ 2013-06-04 13:25 UTC (permalink / raw)
  To: yocto


Ioana Grigoropol (9):
  Rename RSEHelper to RemoteHelper to match usages in
    org.yocto.bc.ui.plugin
  Add remote tools classes needed for bitbake remote capabilities
  Remove ICommandResponseHandler from plugin and use
    org.yocto.remote.utils implementation
  Remove unused Bitbake Actions
  Remove storing of init script location
  Remove unused method loadInit in Activator
  Remove unused getInitScript from ProjectInfoHelper
  Use URI for storing project locations
  Redirect bitbake environment parsing to file & parse

 plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF       |    7 +-
 plugins/org.yocto.bc.ui/plugin.xml                 |   55 ---
 .../src/org/yocto/bc/bitbake/BBRecipe.java         |   26 +-
 .../src/org/yocto/bc/bitbake/BBSession.java        |   83 ++--
 .../yocto/bc/bitbake/ICommandResponseHandler.java  |   15 -
 .../org/yocto/bc/bitbake/ProjectInfoHelper.java    |   58 +--
 .../src/org/yocto/bc/bitbake/ShellSession.java     |   32 +-
 .../src/org/yocto/bc/ui/Activator.java             |   83 ++--
 .../ui/actions/AbstractBitbakeCommandAction.java   |  199 --------
 .../bc/ui/actions/BitbakeBuildRecipeAction.java    |   24 -
 .../bc/ui/actions/BitbakeCleanRecipeAction.java    |   26 -
 .../yocto/bc/ui/actions/BitbakeImportAction.java   |  106 -----
 .../bc/ui/actions/BitbakeRebuildRecipeAction.java  |   29 --
 .../bc/ui/actions/LaunchVariableWizardAction.java  |   16 +-
 .../bc/ui/editors/bitbake/BBVariableTextHover.java |   16 +-
 .../bc/ui/editors/bitbake/BitBakeFileEditor.java   |   16 +-
 .../bitbake/BitBakeSourceViewerConfiguration.java  |   14 +-
 .../src/org/yocto/bc/ui/filesystem/OEFile.java     |   13 +-
 .../org/yocto/bc/ui/filesystem/OEFileSystem.java   |   24 +-
 .../org/yocto/bc/ui/filesystem/YoctoLocation.java  |   34 ++
 .../src/org/yocto/bc/ui/model/ProjectInfo.java     |   75 ++-
 .../yocto/bc/ui/views/RecipeContentProvider.java   |    2 +-
 .../importProject/ImportYoctoProjectWizard.java    |    7 +-
 .../yocto/bc/ui/wizards/install/InstallWizard.java |   39 +-
 .../BBConfigurationInitializeOperation.java        |    3 +-
 .../newproject/CreateBBCProjectOperation.java      |   20 +-
 .../org.yocto.remote.utils/META-INF/MANIFEST.MF    |    8 +-
 .../yocto/remote/utils/CommandOutputProcessor.java |   33 ++
 .../yocto/remote/utils/CommandResponseHandler.java |   36 ++
 .../org/yocto/remote/utils/CommandRunnable.java    |   34 ++
 .../src/org/yocto/remote/utils/ConsoleHelper.java  |   28 ++
 .../org/yocto/remote/utils/ConsoleRunnable.java    |   37 ++
 .../remote/utils/ICommandResponseHandler.java      |   15 +
 .../org/yocto/remote/utils/OutputProcessor.java    |  102 ++++
 .../yocto/remote/utils/ProcessStreamBuffer.java    |   77 +++
 .../src/org/yocto/remote/utils/RSEHelper.java      |  344 -------------
 .../src/org/yocto/remote/utils/RemoteHelper.java   |  503 ++++++++++++++++++++
 .../src/org/yocto/remote/utils/RemoteMachine.java  |  206 ++++++++
 .../org/yocto/remote/utils/RemoteShellExec.java    |    2 +-
 .../src/org/yocto/remote/utils/Session.java        |  117 +++++
 .../org/yocto/remote/utils/TerminalHandler.java    |    2 +-
 .../src/org/yocto/remote/utils/YoctoCommand.java   |   53 +++
 .../yocto/sdk/remotetools/actions/BaseModel.java   |    6 +-
 .../sdk/remotetools/actions/BaseSettingDialog.java |   12 +-
 44 files changed, 1591 insertions(+), 1046 deletions(-)
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java
 create mode 100755 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/YoctoLocation.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java
 delete mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RSEHelper.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java

-- 
1.7.9.5



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Refactor RFC 1/9] Rename RSEHelper to RemoteHelper to match usages in org.yocto.bc.ui.plugin
  2013-06-04 13:25 [Refactor RFC 0/9] Merging of windows-build with master Ioana Grigoropol
@ 2013-06-04 13:26 ` Ioana Grigoropol
  2013-06-04 13:26 ` [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities Ioana Grigoropol
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Ioana Grigoropol @ 2013-06-04 13:26 UTC (permalink / raw)
  To: yocto

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../src/org/yocto/remote/utils/RSEHelper.java      |  344 --------------------
 .../src/org/yocto/remote/utils/RemoteHelper.java   |  344 ++++++++++++++++++++
 .../org/yocto/remote/utils/RemoteShellExec.java    |    2 +-
 .../org/yocto/remote/utils/TerminalHandler.java    |    2 +-
 .../yocto/sdk/remotetools/actions/BaseModel.java   |    6 +-
 .../sdk/remotetools/actions/BaseSettingDialog.java |   12 +-
 6 files changed, 355 insertions(+), 355 deletions(-)
 delete mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RSEHelper.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java

diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RSEHelper.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RSEHelper.java
deleted file mode 100644
index 201c944..0000000
--- a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RSEHelper.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2013 MontaVista Software, Inc and Others.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Anna Dushistova (MontaVista) - initial API and implementation
- * Lianhao Lu (Intel)			- Modified to add other file operations.
- * Ioana Grigoropol (Intel)     - Separated remote functionality
- ********************************************************************************/
-package org.yocto.remote.utils;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.rse.core.IRSECoreStatusCodes;
-import org.eclipse.rse.core.IRSESystemType;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISubSystemConfigurationCategories;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.services.IService;
-import org.eclipse.rse.services.files.IFileService;
-import org.eclipse.rse.services.shells.HostShellProcessAdapter;
-import org.eclipse.rse.services.shells.IHostShell;
-import org.eclipse.rse.services.shells.IShellService;
-import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
-import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem;
-import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem;
-
-public class RSEHelper {
-	private final static String EXIT_CMD = "exit"; //$NON-NLS-1$
-	private final static String CMD_DELIMITER = ";"; //$NON-NLS-1$
-	
-	public static IHost getRemoteConnectionByName(String remoteConnection) {
-		if (remoteConnection == null)
-			return null;
-		IHost[] connections = RSECorePlugin.getTheSystemRegistry().getHosts();
-		for (int i = 0; i < connections.length; i++)
-			if (connections[i].getAliasName().equals(remoteConnection))
-				return connections[i];
-		return null; // TODO Connection is not found in the list--need to react
-		// somehow, throw the exception?
-
-	}
-
-	public static IService getConnectedRemoteFileService(
-			IHost currentConnection, IProgressMonitor monitor) throws Exception {
-		final ISubSystem subsystem = getFileSubsystem(currentConnection);
-
-		if (subsystem == null)
-			throw new Exception(Messages.ErrorNoSubsystem);
-
-		try {
-			subsystem.connect(monitor, false);
-		} catch (CoreException e) {
-			throw e;
-		} catch (OperationCanceledException e) {
-			throw new CoreException(Status.CANCEL_STATUS);
-		}
-
-		if (!subsystem.isConnected())
-			throw new Exception(Messages.ErrorConnectSubsystem);
-
-		return ((IFileServiceSubSystem) subsystem).getFileService();
-	}
-
-	public static ISubSystem getFileSubsystem(IHost host) {
-		if (host == null)
-			return null;
-		ISubSystem[] subSystems = host.getSubSystems();
-		for (int i = 0; i < subSystems.length; i++) {
-			if (subSystems[i] instanceof IFileServiceSubSystem)
-				return subSystems[i];
-		}
-		return null;
-	}
-
-	public static IService getConnectedShellService(
-			IHost currentConnection, IProgressMonitor monitor) throws Exception {
-		final ISubSystem subsystem = getShellSubsystem(currentConnection);
-
-		if (subsystem == null)
-			throw new Exception(Messages.ErrorNoSubsystem);
-
-		try {
-			subsystem.connect(monitor, false);
-		} catch (CoreException e) {
-			throw e;
-		} catch (OperationCanceledException e) {
-			throw new CoreException(Status.CANCEL_STATUS);
-		}
-
-		if (!subsystem.isConnected())
-			throw new Exception(Messages.ErrorConnectSubsystem);
-
-		return ((IShellServiceSubSystem) subsystem).getShellService();
-	}
-
-	public static ISubSystem getShellSubsystem(IHost host) {
-		if (host == null)
-			return null;
-		ISubSystem[] subSystems = host.getSubSystems();
-		for (int i = 0; i < subSystems.length; i++) {
-			if (subSystems[i] instanceof IShellServiceSubSystem)
-				return subSystems[i];
-		}
-		return null;
-	}
-
-	public static IHost[] getSuitableConnections() {
-
-		//we only get RSE connections with files&cmds subsystem
-		ArrayList <IHost> filConnections = new ArrayList <IHost>(Arrays.asList(RSECorePlugin.getTheSystemRegistry()
-				.getHostsBySubSystemConfigurationCategory(ISubSystemConfigurationCategories.SUBSYSTEM_CATEGORY_FILES))); //$NON-NLS-1$
-
-		ArrayList <IHost> terminalConnections = new ArrayList <IHost>(Arrays.asList(RSECorePlugin.getTheSystemRegistry()
-				.getHostsBySubSystemConfigurationCategory("terminal")));//$NON-NLS-1$
-
-		ArrayList <IHost> shellConnections = new ArrayList <IHost>(Arrays.asList(RSECorePlugin.getTheSystemRegistry()
-				.getHostsBySubSystemConfigurationCategory("shells"))); //$NON-NLS-1$
-
-		Iterator <IHost>iter = filConnections.iterator();
-		while(iter.hasNext()){
-			IHost fileConnection = iter.next();
-			if(!terminalConnections.contains(fileConnection) && !shellConnections.contains(fileConnection)){
-				iter.remove();
-			}
-			IRSESystemType sysType = fileConnection.getSystemType();
-			if (sysType == null || !sysType.isEnabled()) {
-				iter.remove();
-			}
-		}
-
-		return filConnections.toArray(new IHost[filConnections.size()]);
-	}
-
-	public static void putRemoteFileInPlugin(IHost connection, String locaPathInPlugin, String remoteExePath,
-			IProgressMonitor monitor) throws Exception {
-
-		assert(connection != null);
-		monitor.beginTask(Messages.InfoUpload, 100);
-
-		IFileService fileService;
-		try {
-			fileService = (IFileService) getConnectedRemoteFileService(
-							connection,
-							new SubProgressMonitor(monitor, 5));
-			InputStream  inputStream = FileLocator.openStream(
-				    Activator.getDefault().getBundle(), new Path(locaPathInPlugin), false);
-			Path remotePath = new Path(remoteExePath);
-
-			//TODO workaround for now
-			//in case the underlying scp file service doesn't support inputStream upload
-			BufferedInputStream bis = new BufferedInputStream(inputStream);
-			File tempFile = File.createTempFile("scp", "temp"); //$NON-NLS-1$ //$NON-NLS-2$
-			FileOutputStream os = new FileOutputStream(tempFile);
-			BufferedOutputStream bos = new BufferedOutputStream(os);
-			byte[] buffer = new byte[1024];
-			int readCount;
-			while( (readCount = bis.read(buffer)) > 0)
-			{
-				bos.write(buffer, 0, readCount);
-			}
-			bos.close();
-			fileService.upload(tempFile, remotePath.removeLastSegments(1)
-					.toString(), remotePath.lastSegment(), true, null, null,
-					new SubProgressMonitor(monitor, 80));
-			// Need to change the permissions to match the original file
-			// permissions because of a bug in upload
-			remoteShellExec(
-					connection,
-					"", "chmod", "+x " + spaceEscapify(remotePath.toString()), new SubProgressMonitor(monitor, 5)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
-		} finally {
-			monitor.done();
-		}
-		return;
-	}
-
-	public static void getRemoteFile(IHost connection, String localExePath, String remoteExePath,
-			IProgressMonitor monitor) throws Exception {
-
-		assert(connection!=null);
-		monitor.beginTask(Messages.InfoDownload, 100);
-
-		IFileService fileService;
-		try {
-			fileService = (IFileService) getConnectedRemoteFileService(
-							connection,
-							new SubProgressMonitor(monitor, 10));
-			File file = new File(localExePath);
-			file.deleteOnExit();
-			monitor.worked(5);
-			Path remotePath = new Path(remoteExePath);
-			fileService.download(remotePath.removeLastSegments(1).toString(),
-					remotePath.lastSegment(),file,true, null,
-					new SubProgressMonitor(monitor, 85));
-			// Need to change the permissions to match the original file
-			// permissions because of a bug in upload
-			//RemoteApplication p = remoteShellExec(
-			//		config,
-			//		"", "chmod", "+x " + spaceEscapify(remotePath.toString()), new SubProgressMonitor(monitor, 5)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-			//Thread.sleep(500);
-			//p.destroy();
-
-		} finally {
-			monitor.done();
-		}
-		return;
-	}
-
-	public static ITerminalServiceSubSystem getTerminalSubSystem(
-            IHost connection) {
-        ISystemRegistry systemRegistry = RSECorePlugin.getTheSystemRegistry();
-        ISubSystem[] subsystems = systemRegistry.getSubSystems(connection);
-        for (int i = 0; i < subsystems.length; i++) {
-        	if (subsystems[i] instanceof ITerminalServiceSubSystem) {
-                ITerminalServiceSubSystem subSystem = (ITerminalServiceSubSystem) subsystems[i];
-                return subSystem;
-            }
-        }
-        return null;
-    }
-
-	public static String spaceEscapify(String inputString) {
-		if (inputString == null)
-			return null;
-
-		return inputString.replaceAll(" ", "\\\\ "); //$NON-NLS-1$ //$NON-NLS-2$
-	}
-
-	public static Process remoteShellExec(IHost connection,
-			String prelaunchCmd, String remoteCommandPath, String arguments,
-			IProgressMonitor monitor) throws CoreException {
-
-		monitor.beginTask(NLS.bind(Messages.RemoteShellExec_1,
-				remoteCommandPath, arguments), 10);
-		String realRemoteCommand = arguments == null ? spaceEscapify(remoteCommandPath)
-				: spaceEscapify(remoteCommandPath) + " " + arguments; //$NON-NLS-1$
-
-		String remoteCommand = realRemoteCommand + CMD_DELIMITER + EXIT_CMD;
-
-		if(prelaunchCmd != null) {
-			if (!prelaunchCmd.trim().equals("")) //$NON-NLS-1$
-				remoteCommand = prelaunchCmd + CMD_DELIMITER + remoteCommand;
-		}
-
-		IShellService shellService;
-		Process p = null;
-		try {
-			shellService = (IShellService) getConnectedShellService(
-							connection,
-							new SubProgressMonitor(monitor, 7));
-
-			// This is necessary because runCommand does not actually run the
-			// command right now.
-			String env[] = new String[0];
-			try {
-				IHostShell hostShell = shellService.launchShell(
-						"", env, new SubProgressMonitor(monitor, 3)); //$NON-NLS-1$
-				hostShell.writeToShell(remoteCommand);
-				p = new HostShellProcessAdapter(hostShell);
-			} catch (Exception e) {
-				if (p != null) {
-					p.destroy();
-				}
-				abort(Messages.RemoteShellExec_2, e,
-						IRSECoreStatusCodes.EXCEPTION_OCCURRED);
-			}
-		} catch (Exception e1) {
-			abort(e1.getMessage(), e1,
-					IRSECoreStatusCodes.EXCEPTION_OCCURRED);
-		}
-
-		monitor.done();
-		return p;
-	}
-
-	/**
-	 * Throws a core exception with an error status object built from the given
-	 * message, lower level exception, and error code.
-	 *
-	 * @param message
-	 *            the status message
-	 * @param exception
-	 *            lower level exception associated with the error, or
-	 *            <code>null</code> if none
-	 * @param code
-	 *            error code
-	 */
-	public static void abort(String message, Throwable exception, int code) throws CoreException {
-		IStatus status;
-		if (exception != null) {
-			MultiStatus multiStatus = new MultiStatus(Activator.PLUGIN_ID, code, message, exception);
-			multiStatus.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, code, exception.getLocalizedMessage(), exception));
-			status = multiStatus;
-		} else {
-			status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, code, message, null);
-		}
-		throw new CoreException(status);
-	}
-	/**
-	 * Checks whether a IHost associated system's is enabled and not a local one
-	 * @param host
-	 * @return
-	 */
-	public static boolean isHostViable(IHost host) {
-		IRSESystemType sysType = host.getSystemType();
-		if (sysType != null && sysType.isEnabled() && !sysType.isLocal())
-			return true;
-		return false;
-	}
-
-	/**
-	 * Ensures that RSECorePlugin is initialized before performing any actions
-	 */
-	public static void waitForRSEInitCompletition() {
-		if (!RSECorePlugin.isInitComplete(RSECorePlugin.INIT_MODEL))
-			try {
-				RSECorePlugin.waitForInitCompletion(RSECorePlugin.INIT_MODEL);
-			} catch (InterruptedException e) {
-				return;
-			}
-	}
-}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java
new file mode 100644
index 0000000..a1e9a08
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java
@@ -0,0 +1,344 @@
+/********************************************************************************
+ * Copyright (c) 2013 MontaVista Software, Inc and Others.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anna Dushistova (MontaVista) - initial API and implementation
+ * Lianhao Lu (Intel)			- Modified to add other file operations.
+ * Ioana Grigoropol (Intel)     - Separated remote functionality
+ ********************************************************************************/
+package org.yocto.remote.utils;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.rse.core.IRSECoreStatusCodes;
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.ISubSystemConfigurationCategories;
+import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.services.IService;
+import org.eclipse.rse.services.files.IFileService;
+import org.eclipse.rse.services.shells.HostShellProcessAdapter;
+import org.eclipse.rse.services.shells.IHostShell;
+import org.eclipse.rse.services.shells.IShellService;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem;
+import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem;
+
+public class RemoteHelper {
+	private final static String EXIT_CMD = "exit"; //$NON-NLS-1$
+	private final static String CMD_DELIMITER = ";"; //$NON-NLS-1$
+
+	public static IHost getRemoteConnectionByName(String remoteConnection) {
+		if (remoteConnection == null)
+			return null;
+		IHost[] connections = RSECorePlugin.getTheSystemRegistry().getHosts();
+		for (int i = 0; i < connections.length; i++)
+			if (connections[i].getAliasName().equals(remoteConnection))
+				return connections[i];
+		return null; // TODO Connection is not found in the list--need to react
+		// somehow, throw the exception?
+
+	}
+
+	public static IService getConnectedRemoteFileService(
+			IHost currentConnection, IProgressMonitor monitor) throws Exception {
+		final ISubSystem subsystem = getFileSubsystem(currentConnection);
+
+		if (subsystem == null)
+			throw new Exception(Messages.ErrorNoSubsystem);
+
+		try {
+			subsystem.connect(monitor, false);
+		} catch (CoreException e) {
+			throw e;
+		} catch (OperationCanceledException e) {
+			throw new CoreException(Status.CANCEL_STATUS);
+		}
+
+		if (!subsystem.isConnected())
+			throw new Exception(Messages.ErrorConnectSubsystem);
+
+		return ((IFileServiceSubSystem) subsystem).getFileService();
+	}
+
+	public static ISubSystem getFileSubsystem(IHost host) {
+		if (host == null)
+			return null;
+		ISubSystem[] subSystems = host.getSubSystems();
+		for (int i = 0; i < subSystems.length; i++) {
+			if (subSystems[i] instanceof IFileServiceSubSystem)
+				return subSystems[i];
+		}
+		return null;
+	}
+
+	public static IService getConnectedShellService(
+			IHost currentConnection, IProgressMonitor monitor) throws Exception {
+		final ISubSystem subsystem = getShellSubsystem(currentConnection);
+
+		if (subsystem == null)
+			throw new Exception(Messages.ErrorNoSubsystem);
+
+		try {
+			subsystem.connect(monitor, false);
+		} catch (CoreException e) {
+			throw e;
+		} catch (OperationCanceledException e) {
+			throw new CoreException(Status.CANCEL_STATUS);
+		}
+
+		if (!subsystem.isConnected())
+			throw new Exception(Messages.ErrorConnectSubsystem);
+
+		return ((IShellServiceSubSystem) subsystem).getShellService();
+	}
+
+	public static ISubSystem getShellSubsystem(IHost host) {
+		if (host == null)
+			return null;
+		ISubSystem[] subSystems = host.getSubSystems();
+		for (int i = 0; i < subSystems.length; i++) {
+			if (subSystems[i] instanceof IShellServiceSubSystem)
+				return subSystems[i];
+		}
+		return null;
+	}
+
+	public static IHost[] getSuitableConnections() {
+
+		//we only get RSE connections with files&cmds subsystem
+		ArrayList <IHost> filConnections = new ArrayList <IHost>(Arrays.asList(RSECorePlugin.getTheSystemRegistry()
+				.getHostsBySubSystemConfigurationCategory(ISubSystemConfigurationCategories.SUBSYSTEM_CATEGORY_FILES))); //$NON-NLS-1$
+
+		ArrayList <IHost> terminalConnections = new ArrayList <IHost>(Arrays.asList(RSECorePlugin.getTheSystemRegistry()
+				.getHostsBySubSystemConfigurationCategory("terminal")));//$NON-NLS-1$
+
+		ArrayList <IHost> shellConnections = new ArrayList <IHost>(Arrays.asList(RSECorePlugin.getTheSystemRegistry()
+				.getHostsBySubSystemConfigurationCategory("shells"))); //$NON-NLS-1$
+
+		Iterator <IHost>iter = filConnections.iterator();
+		while(iter.hasNext()){
+			IHost fileConnection = iter.next();
+			if(!terminalConnections.contains(fileConnection) && !shellConnections.contains(fileConnection)){
+				iter.remove();
+			}
+			IRSESystemType sysType = fileConnection.getSystemType();
+			if (sysType == null || !sysType.isEnabled()) {
+				iter.remove();
+			}
+		}
+
+		return filConnections.toArray(new IHost[filConnections.size()]);
+	}
+
+	public static void putRemoteFileInPlugin(IHost connection, String locaPathInPlugin, String remoteExePath,
+			IProgressMonitor monitor) throws Exception {
+
+		assert(connection != null);
+		monitor.beginTask(Messages.InfoUpload, 100);
+
+		IFileService fileService;
+		try {
+			fileService = (IFileService) getConnectedRemoteFileService(
+							connection,
+							new SubProgressMonitor(monitor, 5));
+			InputStream  inputStream = FileLocator.openStream(
+				    Activator.getDefault().getBundle(), new Path(locaPathInPlugin), false);
+			Path remotePath = new Path(remoteExePath);
+
+			//TODO workaround for now
+			//in case the underlying scp file service doesn't support inputStream upload
+			BufferedInputStream bis = new BufferedInputStream(inputStream);
+			File tempFile = File.createTempFile("scp", "temp"); //$NON-NLS-1$ //$NON-NLS-2$
+			FileOutputStream os = new FileOutputStream(tempFile);
+			BufferedOutputStream bos = new BufferedOutputStream(os);
+			byte[] buffer = new byte[1024];
+			int readCount;
+			while( (readCount = bis.read(buffer)) > 0)
+			{
+				bos.write(buffer, 0, readCount);
+			}
+			bos.close();
+			fileService.upload(tempFile, remotePath.removeLastSegments(1)
+					.toString(), remotePath.lastSegment(), true, null, null,
+					new SubProgressMonitor(monitor, 80));
+			// Need to change the permissions to match the original file
+			// permissions because of a bug in upload
+			remoteShellExec(
+					connection,
+					"", "chmod", "+x " + spaceEscapify(remotePath.toString()), new SubProgressMonitor(monitor, 5)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+		} finally {
+			monitor.done();
+		}
+		return;
+	}
+
+	public static void getRemoteFile(IHost connection, String localExePath, String remoteExePath,
+			IProgressMonitor monitor) throws Exception {
+
+		assert(connection!=null);
+		monitor.beginTask(Messages.InfoDownload, 100);
+
+		IFileService fileService;
+		try {
+			fileService = (IFileService) getConnectedRemoteFileService(
+							connection,
+							new SubProgressMonitor(monitor, 10));
+			File file = new File(localExePath);
+			file.deleteOnExit();
+			monitor.worked(5);
+			Path remotePath = new Path(remoteExePath);
+			fileService.download(remotePath.removeLastSegments(1).toString(),
+					remotePath.lastSegment(),file,true, null,
+					new SubProgressMonitor(monitor, 85));
+			// Need to change the permissions to match the original file
+			// permissions because of a bug in upload
+			//RemoteApplication p = remoteShellExec(
+			//		config,
+			//		"", "chmod", "+x " + spaceEscapify(remotePath.toString()), new SubProgressMonitor(monitor, 5)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			//Thread.sleep(500);
+			//p.destroy();
+
+		} finally {
+			monitor.done();
+		}
+		return;
+	}
+
+	public static ITerminalServiceSubSystem getTerminalSubSystem(
+            IHost connection) {
+        ISystemRegistry systemRegistry = RSECorePlugin.getTheSystemRegistry();
+        ISubSystem[] subsystems = systemRegistry.getSubSystems(connection);
+        for (int i = 0; i < subsystems.length; i++) {
+        	if (subsystems[i] instanceof ITerminalServiceSubSystem) {
+                ITerminalServiceSubSystem subSystem = (ITerminalServiceSubSystem) subsystems[i];
+                return subSystem;
+            }
+        }
+        return null;
+    }
+
+	public static String spaceEscapify(String inputString) {
+		if (inputString == null)
+			return null;
+
+		return inputString.replaceAll(" ", "\\\\ "); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	public static Process remoteShellExec(IHost connection,
+			String prelaunchCmd, String remoteCommandPath, String arguments,
+			IProgressMonitor monitor) throws CoreException {
+
+		monitor.beginTask(NLS.bind(Messages.RemoteShellExec_1,
+				remoteCommandPath, arguments), 10);
+		String realRemoteCommand = arguments == null ? spaceEscapify(remoteCommandPath)
+				: spaceEscapify(remoteCommandPath) + " " + arguments; //$NON-NLS-1$
+
+		String remoteCommand = realRemoteCommand + CMD_DELIMITER + EXIT_CMD;
+
+		if(prelaunchCmd != null) {
+			if (!prelaunchCmd.trim().equals("")) //$NON-NLS-1$
+				remoteCommand = prelaunchCmd + CMD_DELIMITER + remoteCommand;
+		}
+
+		IShellService shellService;
+		Process p = null;
+		try {
+			shellService = (IShellService) getConnectedShellService(
+							connection,
+							new SubProgressMonitor(monitor, 7));
+
+			// This is necessary because runCommand does not actually run the
+			// command right now.
+			String env[] = new String[0];
+			try {
+				IHostShell hostShell = shellService.launchShell(
+						"", env, new SubProgressMonitor(monitor, 3)); //$NON-NLS-1$
+				hostShell.writeToShell(remoteCommand);
+				p = new HostShellProcessAdapter(hostShell);
+			} catch (Exception e) {
+				if (p != null) {
+					p.destroy();
+				}
+				abort(Messages.RemoteShellExec_2, e,
+						IRSECoreStatusCodes.EXCEPTION_OCCURRED);
+			}
+		} catch (Exception e1) {
+			abort(e1.getMessage(), e1,
+					IRSECoreStatusCodes.EXCEPTION_OCCURRED);
+		}
+
+		monitor.done();
+		return p;
+	}
+
+	/**
+	 * Throws a core exception with an error status object built from the given
+	 * message, lower level exception, and error code.
+	 *
+	 * @param message
+	 *            the status message
+	 * @param exception
+	 *            lower level exception associated with the error, or
+	 *            <code>null</code> if none
+	 * @param code
+	 *            error code
+	 */
+	public static void abort(String message, Throwable exception, int code) throws CoreException {
+		IStatus status;
+		if (exception != null) {
+			MultiStatus multiStatus = new MultiStatus(Activator.PLUGIN_ID, code, message, exception);
+			multiStatus.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, code, exception.getLocalizedMessage(), exception));
+			status = multiStatus;
+		} else {
+			status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, code, message, null);
+		}
+		throw new CoreException(status);
+	}
+	/**
+	 * Checks whether a IHost associated system's is enabled and not a local one
+	 * @param host
+	 * @return
+	 */
+	public static boolean isHostViable(IHost host) {
+		IRSESystemType sysType = host.getSystemType();
+		if (sysType != null && sysType.isEnabled() && !sysType.isLocal())
+			return true;
+		return false;
+	}
+
+	/**
+	 * Ensures that RSECorePlugin is initialized before performing any actions
+	 */
+	public static void waitForRSEInitCompletition() {
+		if (!RSECorePlugin.isInitComplete(RSECorePlugin.INIT_MODEL))
+			try {
+				RSECorePlugin.waitForInitCompletion(RSECorePlugin.INIT_MODEL);
+			} catch (InterruptedException e) {
+				return;
+			}
+	}
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteShellExec.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteShellExec.java
index a7fe221..711088c 100644
--- a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteShellExec.java
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteShellExec.java
@@ -82,7 +82,7 @@ public class RemoteShellExec {
 
 		reset();
 		argument = (argument == null ? RETURN_VALUE_CMD : argument + RETURN_VALUE_CMD);
-		remoteShellProcess = RSEHelper.remoteShellExec(this.host, prelaunchCmd, this.command, argument, monitor);
+		remoteShellProcess = RemoteHelper.remoteShellExec(this.host, prelaunchCmd, this.command, argument, monitor);
 		fInStream = remoteShellProcess.getInputStream();
 		fOutStream = remoteShellProcess.getOutputStream();
 		fErrStream = remoteShellProcess.getErrorStream();
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/TerminalHandler.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/TerminalHandler.java
index 1eed7e9..cd89fea 100644
--- a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/TerminalHandler.java
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/TerminalHandler.java
@@ -90,7 +90,7 @@ abstract public class TerminalHandler extends AbstractHandler {
 
 	public void execute(IHost host) throws ExecutionException {
 
-		final ITerminalServiceSubSystem terminalSubSystem = RSEHelper.getTerminalSubSystem(host);
+		final ITerminalServiceSubSystem terminalSubSystem = RemoteHelper.getTerminalSubSystem(host);
 
 		if (terminalSubSystem != null) {
 			TerminalsUI terminalsUI = TerminalsUI.getInstance();
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseModel.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseModel.java
index dacd192..b98abd3 100644
--- a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseModel.java
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseModel.java
@@ -18,7 +18,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.rse.core.model.IHost;
-import org.yocto.remote.utils.RSEHelper;
+import org.yocto.remote.utils.RemoteHelper;
 import org.yocto.remote.utils.RemoteShellExec;
 
 abstract public class BaseModel implements IRunnableWithProgress {
@@ -49,7 +49,7 @@ abstract public class BaseModel implements IRunnableWithProgress {
 	public void preProcess(IProgressMonitor monitor) throws InvocationTargetException,	InterruptedException{
 		//upload script to remote
 		try {
-			RSEHelper.putRemoteFileInPlugin(host, localScript, remoteExec, monitor);
+			RemoteHelper.putRemoteFileInPlugin(host, localScript, remoteExec, monitor);
 		}catch (InterruptedException e){
 			throw e;
 		}catch (InvocationTargetException e) {
@@ -103,7 +103,7 @@ abstract public class BaseModel implements IRunnableWithProgress {
 	}
 
 	protected void getDataFile(IProgressMonitor monitor) throws Exception {
-		RSEHelper.getRemoteFile( host, localFile, remoteFile, monitor);
+		RemoteHelper.getRemoteFile( host, localFile, remoteFile, monitor);
 	}
 	protected void runRemoteShellExec(IProgressMonitor monitor, String args, boolean cancelable) throws Exception {
 		try {
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java
index 7845959..24f4c23 100644
--- a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java
+++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java
@@ -21,7 +21,7 @@
 
 package org.yocto.sdk.remotetools.actions;
 
-import org.yocto.remote.utils.RSEHelper;
+import org.yocto.remote.utils.RemoteHelper;
 import org.yocto.sdk.remotetools.Messages;
 import org.yocto.sdk.remotetools.SWTFactory;
 import org.eclipse.jface.dialogs.Dialog;
@@ -140,7 +140,7 @@ public class BaseSettingDialog extends Dialog {
 			button.setEnabled(false);
 		IHost currentConnectionSelected = getCurrentConnection();
 		if (currentConnectionSelected != null) {
-			if (RSEHelper.isHostViable(currentConnectionSelected) && button != null){
+			if (RemoteHelper.isHostViable(currentConnectionSelected) && button != null){
 					button.setEnabled(true);
 					ret=true;
 			}
@@ -151,7 +151,7 @@ public class BaseSettingDialog extends Dialog {
 	protected void updateCurConn() {
 		IHost currentConnectionSelected = getCurrentConnection();
 		if (currentConnectionSelected != null) {
-			if (RSEHelper.isHostViable(currentConnectionSelected))
+			if (RemoteHelper.isHostViable(currentConnectionSelected))
 				curConn=currentConnectionSelected.getAliasName();
 		}
 		updateOkButton();
@@ -161,7 +161,7 @@ public class BaseSettingDialog extends Dialog {
 		int currentSelection = connectionCombo.getSelectionIndex();
 		String remoteConnection = currentSelection >= 0 ? connectionCombo
 				.getItem(currentSelection) : null;
-        return RSEHelper.getRemoteConnectionByName(remoteConnection);
+        return RemoteHelper.getRemoteConnectionByName(remoteConnection);
     }
 	
 	protected void handleNewRemoteConnectionSelected() {
@@ -179,10 +179,10 @@ public class BaseSettingDialog extends Dialog {
 	
 	protected void updateConnectionPulldown() {
 		int index=-1;
-		RSEHelper.waitForRSEInitCompletition();
+		RemoteHelper.waitForRSEInitCompletition();
 		// already initialized
 		connectionCombo.removeAll();
-		IHost[] connections = RSEHelper.getSuitableConnections();
+		IHost[] connections = RemoteHelper.getSuitableConnections();
 		for (int i = 0; i < connections.length; i++) {
 			connectionCombo.add(connections[i].getAliasName());
 			if(connections[i].getAliasName().equals(curConn))
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities
  2013-06-04 13:25 [Refactor RFC 0/9] Merging of windows-build with master Ioana Grigoropol
  2013-06-04 13:26 ` [Refactor RFC 1/9] Rename RSEHelper to RemoteHelper to match usages in org.yocto.bc.ui.plugin Ioana Grigoropol
@ 2013-06-04 13:26 ` Ioana Grigoropol
  2013-06-06 23:53   ` Zhang, Jessica
  2013-06-04 13:26 ` [Refactor RFC 3/9] Remove ICommandResponseHandler from plugin and use org.yocto.remote.utils implementation Ioana Grigoropol
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Ioana Grigoropol @ 2013-06-04 13:26 UTC (permalink / raw)
  To: yocto

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../org.yocto.remote.utils/META-INF/MANIFEST.MF    |    8 +-
 .../yocto/remote/utils/CommandOutputProcessor.java |   33 +++
 .../yocto/remote/utils/CommandResponseHandler.java |   36 +++
 .../org/yocto/remote/utils/CommandRunnable.java    |   34 +++
 .../src/org/yocto/remote/utils/ConsoleHelper.java  |   28 +++
 .../org/yocto/remote/utils/ConsoleRunnable.java    |   37 +++
 .../remote/utils/ICommandResponseHandler.java      |   15 ++
 .../org/yocto/remote/utils/OutputProcessor.java    |  102 ++++++++
 .../yocto/remote/utils/ProcessStreamBuffer.java    |   77 ++++++
 .../src/org/yocto/remote/utils/RemoteHelper.java   |  255 ++++++++++++++++----
 .../src/org/yocto/remote/utils/RemoteMachine.java  |  206 ++++++++++++++++
 .../src/org/yocto/remote/utils/Session.java        |  117 +++++++++
 .../src/org/yocto/remote/utils/YoctoCommand.java   |   53 ++++
 13 files changed, 952 insertions(+), 49 deletions(-)
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java

diff --git a/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF b/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF
index c7b57fe..06d14f8 100644
--- a/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF
+++ b/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF
@@ -11,17 +11,23 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Import-Package: org.eclipse.rse.core,
  org.eclipse.rse.core.model,
  org.eclipse.rse.core.subsystems,
+ org.eclipse.rse.internal.services.local.shells,
+ org.eclipse.rse.internal.services.shells,
  org.eclipse.rse.internal.terminals.ui,
  org.eclipse.rse.internal.terminals.ui.views,
  org.eclipse.rse.services,
+ org.eclipse.rse.services.clientserver.messages,
  org.eclipse.rse.services.files,
  org.eclipse.rse.services.shells,
  org.eclipse.rse.services.terminals,
+ org.eclipse.rse.subsystems.files.core.model,
  org.eclipse.rse.subsystems.files.core.servicesubsystem,
+ org.eclipse.rse.subsystems.files.core.subsystems,
  org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem,
  org.eclipse.rse.subsystems.terminals.core,
  org.eclipse.rse.subsystems.terminals.core.elements,
  org.eclipse.rse.ui,
  org.eclipse.tm.internal.terminal.control,
- org.eclipse.tm.internal.terminal.provisional.api
+ org.eclipse.tm.internal.terminal.provisional.api,
+ org.eclipse.ui.console
 Export-Package: org.yocto.remote.utils
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java
new file mode 100644
index 0000000..4fca662
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java
@@ -0,0 +1,33 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.services.shells.IHostShell;
+
+public class CommandOutputProcessor extends OutputProcessor {
+
+	public CommandOutputProcessor(IProgressMonitor monitor,
+			IHostShell hostShell, CommandResponseHandler cmdHandler, String task) {
+		super(monitor, hostShell, cmdHandler, task);
+	}
+
+	@Override
+	protected boolean isErrChStop(char ch) {
+		return (ch == '\n');
+	}
+
+	@Override
+	protected boolean isOutChStop(char ch) {
+		return (ch == '\n');
+	}
+
+	@Override
+	protected void processOutputBufferLine(char ch, String str) {
+		processBuffer.addOutputLine(str);
+	}
+
+	@Override
+	protected void processErrorBufferLine(char ch, String str) {
+		processBuffer.addErrorLine(str);
+	}
+
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java
new file mode 100644
index 0000000..0785c45
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java
@@ -0,0 +1,36 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
+
+public class CommandResponseHandler implements ICommandResponseHandler {
+	private MessageConsoleStream consoleStream;
+	private Boolean errorOccured = false;
+
+	public CommandResponseHandler(MessageConsole console) {
+		try {
+			this.consoleStream = console.newMessageStream();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public Boolean hasError() {
+		return errorOccured;
+	}
+
+	@Override
+	public void response(String line, boolean isError) {
+		try {
+			if (isError) {
+				consoleStream.println(line);
+				errorOccured = true;
+			} else {
+				consoleStream.println(line);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+}
\ No newline at end of file
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java
new file mode 100644
index 0000000..46a3f35
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java
@@ -0,0 +1,34 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.services.shells.IHostShell;
+
+public class CommandRunnable implements Runnable{
+	private IHostShell hostShell;
+	private final IHost connection;
+	private final YoctoCommand cmd;
+	private final IProgressMonitor monitor;
+	private final CommandResponseHandler cmdHandler;
+
+	CommandRunnable(IHost connection, YoctoCommand cmd, IProgressMonitor monitor){
+		this.connection = connection;
+		this.cmdHandler = RemoteHelper.getCommandHandler(connection);
+		this.cmd = cmd;
+		this.monitor = monitor;
+		this.hostShell = null;
+	}
+	@Override
+	public void run() {
+		try {
+			hostShell = RemoteHelper.runCommandRemote(connection, cmd, monitor);
+			cmd.setProcessBuffer(RemoteHelper.processOutput(monitor, hostShell, cmdHandler));
+		} catch (CoreException e) {
+			e.printStackTrace();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java
new file mode 100644
index 0000000..307e219
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java
@@ -0,0 +1,28 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.MessageConsole;
+
+public class ConsoleHelper {
+	public static final String YOCTO_CONSOLE = "Yocto Project Console";
+
+	public static MessageConsole findConsole(String name) {
+		ConsolePlugin plugin = ConsolePlugin.getDefault();
+		IConsoleManager conMan = plugin.getConsoleManager();
+		IConsole[] existing = conMan.getConsoles();
+		for (int i = 0; i < existing.length; i++)
+			if (name.equals(existing[i].getName()))
+				return (MessageConsole) existing[i];
+		// no console found, so create a new one
+		MessageConsole myConsole = new MessageConsole(name, null);
+		conMan.addConsoles(new IConsole[] { myConsole });
+		return myConsole;
+	}
+
+	public static void showConsole(MessageConsole console){
+		Display.getDefault().syncExec(new ConsoleRunnable(console));
+	}
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java
new file mode 100644
index 0000000..f3b0ccd
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java
@@ -0,0 +1,37 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleView;
+import org.eclipse.ui.console.MessageConsole;
+
+public class ConsoleRunnable implements Runnable{
+	MessageConsole console;
+	ConsoleRunnable (MessageConsole console){
+		this.console = console;
+	}
+	@Override
+	public void run() {
+		IWorkbench wb = PlatformUI.getWorkbench();
+		if (wb == null)
+			return;
+		IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
+		if (win == null)
+			return;
+		IWorkbenchPage page = win.getActivePage();
+		if (page == null)
+			return;
+		String id = IConsoleConstants.ID_CONSOLE_VIEW;
+		try {
+			IConsoleView view = (IConsoleView) page.showView(id);
+			if (view == null)
+				return;
+			view.display(console);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+}
\ No newline at end of file
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java
new file mode 100644
index 0000000..a8a8f95
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java
@@ -0,0 +1,15 @@
+/*****************************************************************************
+ * Copyright (c) 2009 Ken Gilmer
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Ken Gilmer - initial API and implementation
+ *******************************************************************************/
+package org.yocto.remote.utils;
+
+public interface ICommandResponseHandler {
+	public void response(String line, boolean isError);
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java
new file mode 100644
index 0000000..a06f077
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java
@@ -0,0 +1,102 @@
+package org.yocto.remote.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.concurrent.locks.Lock;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.internal.services.local.shells.LocalHostShell;
+import org.eclipse.rse.internal.services.shells.TerminalServiceHostShell;
+import org.eclipse.rse.services.shells.HostShellProcessAdapter;
+import org.eclipse.rse.services.shells.IHostShell;
+
+public abstract class OutputProcessor{
+	private static final int ERROR_BUFFER = 1;
+	private static final int OUTPUT_BUFFER = 2;
+	protected String task;
+	protected ProcessStreamBuffer processBuffer;
+	protected IHostShell hostShell;
+	protected CommandResponseHandler cmdHandler;
+	protected IProgressMonitor monitor;
+
+	public OutputProcessor(IProgressMonitor monitor, IHostShell hostShell, CommandResponseHandler cmdHandler, String task){
+		this.monitor = monitor;
+		this.hostShell = hostShell;
+		this.processBuffer = new ProcessStreamBuffer(hostShell instanceof TerminalServiceHostShell);
+		this.cmdHandler = cmdHandler;
+		this.task = task;
+	}
+	public ProcessStreamBuffer processOutput() throws Exception{
+		if (hostShell == null)
+			throw new Exception("An error has occured while trying to run remote command!");
+		monitor.beginTask(this.task, RemoteHelper.TOTALWORKLOAD);
+		Lock lock = null;
+		if (hostShell instanceof LocalHostShell) {
+			lock = ((LocalHostShell)hostShell).getLock();
+			lock.lock();
+		}
+		BufferedReader inbr = null;
+		BufferedReader errbr = null;
+
+		if (hostShell instanceof LocalHostShell) {
+			inbr = ((LocalHostShell)hostShell).getReader(false);
+			errbr = ((LocalHostShell)hostShell).getReader(true);
+		} else {
+			Process p = new HostShellProcessAdapter(hostShell);
+			inbr = new BufferedReader(new InputStreamReader(p.getInputStream()));
+			errbr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+		}
+		boolean cancel = false;
+		while (!cancel) {
+			if(monitor.isCanceled()) {
+				cancel = true;
+				if (lock != null)
+					lock.unlock();
+				throw new InterruptedException("User Cancelled");
+			}
+			processBuffer(errbr, ERROR_BUFFER);
+			processBuffer(inbr, OUTPUT_BUFFER);
+			cancel = true;
+		}
+		if (lock != null)
+			lock.unlock();
+		return processBuffer;
+	}
+	protected abstract boolean isErrChStop(char ch);
+	protected abstract boolean isOutChStop(char ch);
+	protected boolean isChStop(char ch, int type){
+		if (type == ERROR_BUFFER)
+			return isErrChStop(ch);
+		else if(type == OUTPUT_BUFFER)
+			return isOutChStop(ch);
+		return false;
+	}
+	protected abstract void processOutputBufferLine(char ch, String str);
+	protected abstract void processErrorBufferLine(char ch, String str);
+	protected void processBufferLine(String str, char ch, int type){
+		if (type == ERROR_BUFFER)
+			processErrorBufferLine(ch, str);
+		else if(type == OUTPUT_BUFFER)
+			processOutputBufferLine(ch, str);
+	}
+	protected void processBuffer(BufferedReader br, int type) throws IOException{
+		StringBuffer buffer = new StringBuffer();
+		int c;
+		if (br != null)
+		while ((c = br.read()) != -1) {
+			char ch = (char) c;
+			buffer.append(ch);
+			if (isChStop(ch, type)){
+				String str = buffer.toString();
+				processBufferLine(str, ch, type);
+				System.out.println(str);
+				if (str.trim().equals(RemoteHelper.TERMINATOR)) {
+					break;
+				}
+				cmdHandler.response(str, false);
+				buffer.delete(0, buffer.length());
+			}
+		}
+	}
+}
\ No newline at end of file
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java
new file mode 100644
index 0000000..3fe8731
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java
@@ -0,0 +1,77 @@
+package org.yocto.remote.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class ProcessStreamBuffer {
+	private static final String WHITESPACES = "\\s+";
+	List<String> errorLines;
+	List<String> outputLines;
+	boolean isTerminal;
+
+	ProcessStreamBuffer(boolean isTerminal){
+		this.isTerminal = isTerminal;
+		errorLines = new ArrayList<String>();
+		outputLines = new ArrayList<String>();
+	}
+
+	public void addErrorLine(String line){
+		errorLines.add(line);
+	}
+	public void addOutputLine(String line){
+		outputLines.add(line);
+	}
+
+	public List<String> getOutputLines(){
+		return outputLines;
+	}
+
+	public List<String> getErrorLines(){
+		return errorLines;
+	}
+
+	public String getMergedOutputLines(){
+		String returnVal = "";
+		for (int i = 0; i < outputLines.size(); i++) {
+			String line = outputLines.get(i);
+			returnVal += line;
+			if (outputLines.size() > 1 && i != outputLines.size() - 1)
+				returnVal += "\n";
+		}
+		return returnVal;
+	}
+
+	public boolean hasErrors() {
+		return errorLines.size() != 0;
+	}
+
+	public String getLastOutputLineContaining(String str) {
+		if (!errorLines.isEmpty())
+			return null;
+		for (int i = outputLines.size() - 1; i >= 0; i--){
+			String line = outputLines.get(i);
+			if (line.replaceAll(WHITESPACES, "").contains(str.replaceAll(WHITESPACES, "")))
+				return line;
+		}
+		return null;
+	}
+
+	public String getOutputLineContaining(String arg, String pattern) {
+		List<String> lines = null;
+		if (isTerminal)
+			lines = errorLines;
+		else
+			lines = outputLines;
+		for (int i = lines.size() - 1; i >= 0; i--){
+			String line = lines.get(i);
+			if (line.contains(arg)) {
+				String[] tokens = line.split("\\s+");
+				if (Pattern.matches(pattern,  tokens[0])) {
+					return tokens[0];
+				}
+			}
+		}
+		return "";
+	}
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java
index a1e9a08..e9118d6 100644
--- a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java
@@ -16,16 +16,19 @@ import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
@@ -38,17 +41,26 @@ import org.eclipse.rse.core.model.ISubSystemConfigurationCategories;
 import org.eclipse.rse.core.model.ISystemRegistry;
 import org.eclipse.rse.core.subsystems.ISubSystem;
 import org.eclipse.rse.services.IService;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
 import org.eclipse.rse.services.files.IFileService;
+import org.eclipse.rse.services.files.IHostFile;
 import org.eclipse.rse.services.shells.HostShellProcessAdapter;
 import org.eclipse.rse.services.shells.IHostShell;
 import org.eclipse.rse.services.shells.IShellService;
+import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
 import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
 import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem;
 import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem;
+import org.eclipse.ui.console.MessageConsole;
 
 public class RemoteHelper {
 	private final static String EXIT_CMD = "exit"; //$NON-NLS-1$
 	private final static String CMD_DELIMITER = ";"; //$NON-NLS-1$
+	public static final String TERMINATOR = "234o987dsfkcqiuwey18837032843259d";//$NON-NLS-1$
+	public static final int TOTALWORKLOAD = 100;
+	private static Map<IHost, RemoteMachine> machines;
 
 	public static IHost getRemoteConnectionByName(String remoteConnection) {
 		if (remoteConnection == null)
@@ -57,30 +69,7 @@ public class RemoteHelper {
 		for (int i = 0; i < connections.length; i++)
 			if (connections[i].getAliasName().equals(remoteConnection))
 				return connections[i];
-		return null; // TODO Connection is not found in the list--need to react
-		// somehow, throw the exception?
-
-	}
-
-	public static IService getConnectedRemoteFileService(
-			IHost currentConnection, IProgressMonitor monitor) throws Exception {
-		final ISubSystem subsystem = getFileSubsystem(currentConnection);
-
-		if (subsystem == null)
-			throw new Exception(Messages.ErrorNoSubsystem);
-
-		try {
-			subsystem.connect(monitor, false);
-		} catch (CoreException e) {
-			throw e;
-		} catch (OperationCanceledException e) {
-			throw new CoreException(Status.CANCEL_STATUS);
-		}
-
-		if (!subsystem.isConnected())
-			throw new Exception(Messages.ErrorConnectSubsystem);
-
-		return ((IFileServiceSubSystem) subsystem).getFileService();
+		return null;
 	}
 
 	public static ISubSystem getFileSubsystem(IHost host) {
@@ -94,27 +83,6 @@ public class RemoteHelper {
 		return null;
 	}
 
-	public static IService getConnectedShellService(
-			IHost currentConnection, IProgressMonitor monitor) throws Exception {
-		final ISubSystem subsystem = getShellSubsystem(currentConnection);
-
-		if (subsystem == null)
-			throw new Exception(Messages.ErrorNoSubsystem);
-
-		try {
-			subsystem.connect(monitor, false);
-		} catch (CoreException e) {
-			throw e;
-		} catch (OperationCanceledException e) {
-			throw new CoreException(Status.CANCEL_STATUS);
-		}
-
-		if (!subsystem.isConnected())
-			throw new Exception(Messages.ErrorConnectSubsystem);
-
-		return ((IShellServiceSubSystem) subsystem).getShellService();
-	}
-
 	public static ISubSystem getShellSubsystem(IHost host) {
 		if (host == null)
 			return null;
@@ -161,7 +129,7 @@ public class RemoteHelper {
 
 		IFileService fileService;
 		try {
-			fileService = (IFileService) getConnectedRemoteFileService(
+			fileService = getConnectedRemoteFileService(
 							connection,
 							new SubProgressMonitor(monitor, 5));
 			InputStream  inputStream = FileLocator.openStream(
@@ -204,7 +172,7 @@ public class RemoteHelper {
 
 		IFileService fileService;
 		try {
-			fileService = (IFileService) getConnectedRemoteFileService(
+			fileService = getConnectedRemoteFileService(
 							connection,
 							new SubProgressMonitor(monitor, 10));
 			File file = new File(localExePath);
@@ -341,4 +309,195 @@ public class RemoteHelper {
 				return;
 			}
 	}
+	public static RemoteMachine getRemoteMachine(IHost connection){
+		if (!getMachines().containsKey(connection))
+			getMachines().put(connection, new RemoteMachine(connection));
+		return getMachines().get(connection);
+	}
+
+	private static Map<IHost, RemoteMachine> getMachines() {
+		if (machines == null)
+			machines = new HashMap<IHost, RemoteMachine>();
+		return machines;
+	}
+
+	public static MessageConsole getConsole(IHost connection) {
+		return getRemoteMachine(connection).getConsole();
+	}
+
+	public static CommandResponseHandler getCommandHandler(IHost connection) {
+		return getRemoteMachine(connection).getCmdHandler();
+	}
+
+	public static ProcessStreamBuffer processOutput(IProgressMonitor monitor, IHostShell hostShell, CommandResponseHandler cmdHandler) throws Exception {
+		return new CommandOutputProcessor(monitor, hostShell, cmdHandler, "").processOutput();
+	}
+
+	public static IHost getRemoteConnectionForURI(URI uri, IProgressMonitor monitor) {
+		if (uri == null)
+			return null;
+
+		String host = uri.getHost();
+		if (host == null) {
+			// this is a local connection
+			ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
+			IHost local = null;
+			while (local == null) {
+				local = sr.getLocalHost();
+			}
+			return local;
+		}
+		ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
+		IHost[] connections = sr.getHosts();
+
+		IHost unconnected = null;
+		for (IHost conn : connections) {
+			if (host.equalsIgnoreCase(conn.getHostName())) {
+				IRemoteFileSubSystem fss = getRemoteFileSubSystem(conn);
+				if (fss != null && fss.isConnected())
+					return conn;
+				unconnected = conn;
+			}
+		}
+
+		return unconnected;
+	}
+
+	public static IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) {
+		IRemoteFileSubSystem candidate = null;
+		IRemoteFileSubSystem otherServiceCandidate = null;
+		IRemoteFileSubSystem[] subSystems = RemoteFileUtility.getFileSubSystems(host);
+
+		for (IRemoteFileSubSystem subSystem : subSystems) {
+			if (subSystem instanceof FileServiceSubSystem) {
+				if (subSystem.isConnected())
+					return subSystem;
+
+				if (otherServiceCandidate == null)
+					otherServiceCandidate = subSystem;
+
+			} else if (candidate == null || (subSystem.isConnected() && !candidate.isConnected()))
+				candidate = subSystem;
+
+		}
+		if (candidate != null && candidate.isConnected())
+			return candidate;
+		if (otherServiceCandidate != null)
+			return otherServiceCandidate;
+		return null;
+	}
+
+	public static IFileService getConnectedRemoteFileService(IHost connection, IProgressMonitor monitor) throws Exception {
+		return getRemoteMachine(connection).getRemoteFileService(monitor);
+	}
+
+	public static IHostFile[] getRemoteDirContent(IHost connection, String remoteParent, String fileFilter, int fileType, IProgressMonitor monitor){
+
+		try {
+			IFileService fileServ = getConnectedRemoteFileService(connection, monitor);
+			return fileServ.list(remoteParent, fileFilter, fileType, monitor);
+		} catch (SystemMessageException e) {
+			e.printStackTrace();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public static IService getConnectedShellService(IHost connection, IProgressMonitor monitor) throws Exception {
+		return getRemoteMachine(connection).getShellService(monitor);
+	}
+
+	public static void handleRunCommandRemote(IHost connection, YoctoCommand cmd, IProgressMonitor monitor){
+		try {
+			CommandRunnable cmdRun = new CommandRunnable(connection, cmd, monitor);
+			cmdRun.run();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public static IHostShell runCommandRemote(IHost connection, YoctoCommand cmd,
+			IProgressMonitor monitor) throws CoreException {
+
+		monitor.beginTask(NLS.bind(Messages.RemoteShellExec_1,
+				cmd, cmd.getArguments()), 10);
+
+		String remoteCommand = cmd.getCommand() + " " + cmd.getArguments() + " ; echo " + TERMINATOR + "; exit ;";
+
+		IShellService shellService;
+		try {
+			shellService = (IShellService) getConnectedShellService(connection, new SubProgressMonitor(monitor, 7));
+
+			String env[] = getRemoteMachine(connection).prepareEnvString(monitor);
+
+			try {
+				IHostShell hostShell = shellService.runCommand(cmd.getInitialDirectory(), remoteCommand, env, new SubProgressMonitor(monitor, 3));
+				return hostShell;
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		} catch (Exception e1) {
+			e1.printStackTrace();
+		}
+		return null;
+	}
+
+	public static IHostFile getRemoteHostFile(IHost connection, String remoteFilePath, IProgressMonitor monitor){
+		assert(connection != null);
+		monitor.beginTask(Messages.InfoDownload, 100);
+
+		try {
+			IFileService fileService = getConnectedRemoteFileService(connection, new SubProgressMonitor(monitor, 10));
+			Path remotePath = new Path(remoteFilePath);
+			IHostFile remoteFile = fileService.getFile(remotePath.removeLastSegments(1).toString(), remotePath.lastSegment(), new SubProgressMonitor(monitor, 5));
+			return remoteFile;
+		} catch (Exception e) {
+			e.printStackTrace();
+	    }finally {
+			monitor.done();
+		}
+		return null;
+	}
+
+	public static InputStream getRemoteInputStream(IHost connection, String parentPath, String remoteFilePath, IProgressMonitor monitor){
+		assert(connection != null);
+		monitor.beginTask(Messages.InfoDownload, 100);
+
+		try {
+			IFileService fileService = getConnectedRemoteFileService(connection, new SubProgressMonitor(monitor, 10));
+
+			return fileService.getInputStream(parentPath, remoteFilePath, false, monitor);
+		} catch (Exception e) {
+			e.printStackTrace();
+	    }finally {
+			monitor.done();
+		}
+		return null;
+	}
+
+	public static URI createNewURI(URI oldURI, String name) {
+		try {
+			String sep = oldURI.getPath().endsWith("/") ? "" : "/";
+			return new URI(oldURI.getScheme(), oldURI.getHost(), oldURI.getPath() + sep + name, oldURI.getFragment());
+		} catch (URISyntaxException e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	public static boolean fileExistsRemote(IHost conn, IProgressMonitor monitor, String path) {
+		try {
+			IFileService fs = getConnectedRemoteFileService(conn, monitor);
+			int nameStart = path.lastIndexOf("/");
+			String parentPath = path.substring(0, nameStart);
+			String name = path.substring(nameStart + 1);
+			IHostFile hostFile = fs.getFile(parentPath, name, monitor);
+
+			return hostFile.exists();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return false;
+	}
 }
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java
new file mode 100644
index 0000000..123a972
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java
@@ -0,0 +1,206 @@
+package org.yocto.remote.utils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.internal.services.local.shells.LocalShellService;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.rse.services.files.IFileService;
+import org.eclipse.rse.services.shells.IHostShell;
+import org.eclipse.rse.services.shells.IShellService;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem;
+import org.eclipse.ui.console.MessageConsole;
+
+public class RemoteMachine {
+	public static final String PROXY = "proxy";
+
+	private Map<String, String> environment;
+	private MessageConsole console;
+	private CommandResponseHandler cmdHandler;
+	private IHostShell hostShell;
+	private IShellService shellService;
+	private IHost connection;
+
+	private ISubSystem fileSubSystem;
+	private IFileService fileService;
+
+	public RemoteMachine(IHost connection) {
+		setConnection(connection);
+	}
+
+	public String[] prepareEnvString(IProgressMonitor monitor){
+		String[] env = null;
+		try {
+			if (shellService instanceof LocalShellService) {
+				env  = shellService.getHostEnvironment();
+			} else {
+				List<String> envList = new ArrayList<String>();
+				getRemoteEnvProxyVars(monitor);
+				String value = "";
+				for (String varName : environment.keySet()){
+					value = varName + "=" + environment.get(varName);
+					envList.add(value);
+				}
+				env = envList.toArray(new String[envList.size()]);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		return env;
+	}
+	public void getRemoteEnvProxyVars(IProgressMonitor monitor){
+		try {
+			if (environment != null && !environment.isEmpty())
+				return;
+
+			environment = new HashMap<String, String>();
+
+			IShellService shellService = getShellService(new SubProgressMonitor(monitor, 7));
+
+			ProcessStreamBuffer buffer = null;
+			try {
+				SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 3);
+				IHostShell hostShell = shellService.runCommand("", "env" + " ; echo " + RemoteHelper.TERMINATOR + "; exit;", new String[]{}, subMonitor);
+				buffer = RemoteHelper.processOutput(subMonitor, hostShell, cmdHandler);
+				for(int i = 0; i < buffer.getOutputLines().size(); i++) {
+					String out = buffer.getOutputLines().get(i);
+					String[] tokens = out.split("=");
+					if (tokens.length != 2)
+						continue;
+					String varName = tokens[0];
+					String varValue = tokens[1];
+					if (varName.contains(PROXY))
+						environment.put(varName, varValue);
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public Map<String, String> getEnvironment() {
+		return environment;
+	}
+	public void setEnvironment(Map<String, String> environment) {
+		this.environment = environment;
+	}
+	public MessageConsole getConsole() {
+		if (console == null)
+			console = ConsoleHelper.findConsole(ConsoleHelper.YOCTO_CONSOLE);
+
+		ConsoleHelper.showConsole(console);
+		return console;
+	}
+	public CommandResponseHandler getCmdHandler() {
+		if (cmdHandler == null)
+			cmdHandler = new CommandResponseHandler(getConsole());
+		return cmdHandler;
+	}
+	public IHostShell getHostShell() {
+		try {
+			if (hostShell == null) {
+				hostShell = getShellService(new NullProgressMonitor()).launchShell("", new String[]{}, new NullProgressMonitor());
+				prepareEnvString(new NullProgressMonitor());
+			}
+		} catch (SystemMessageException e) {
+			e.printStackTrace();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return hostShell;
+	}
+
+	public IShellService getShellService(IProgressMonitor monitor) throws Exception {
+		if (shellService != null)
+			return shellService;
+
+		final ISubSystem subsystem = getShellSubsystem();
+
+		if (subsystem == null)
+			throw new Exception(Messages.ErrorNoSubsystem);
+
+		try {
+			subsystem.connect(monitor, false);
+		} catch (CoreException e) {
+			throw e;
+		} catch (OperationCanceledException e) {
+			throw new CoreException(Status.CANCEL_STATUS);
+		}
+
+		if (!subsystem.isConnected())
+			throw new Exception(Messages.ErrorConnectSubsystem);
+
+		shellService = ((IShellServiceSubSystem) subsystem).getShellService();
+		return shellService;
+	}
+
+	private ISubSystem getShellSubsystem() {
+		if (connection == null)
+			return null;
+		ISubSystem[] subSystems = connection.getSubSystems();
+		for (int i = 0; i < subSystems.length; i++) {
+			if (subSystems[i] instanceof IShellServiceSubSystem)
+				return subSystems[i];
+		}
+		return null;
+	}
+
+	public IHost getConnection() {
+		return connection;
+	}
+	public void setConnection(IHost connection) {
+		this.connection = connection;
+	}
+
+	public IFileService getRemoteFileService(IProgressMonitor monitor) throws Exception {
+		if (fileService == null) {
+
+			while(getFileSubsystem() == null)
+				Thread.sleep(2);
+			try {
+				getFileSubsystem().connect(monitor, false);
+			} catch (CoreException e) {
+				throw e;
+			} catch (OperationCanceledException e) {
+				throw new CoreException(Status.CANCEL_STATUS);
+			}
+
+			if (!getFileSubsystem().isConnected())
+				throw new Exception(Messages.ErrorConnectSubsystem);
+
+			fileService = ((IFileServiceSubSystem) getFileSubsystem()).getFileService();
+		}
+		return fileService;
+	}
+
+	public ISubSystem getFileSubsystem() {
+		if (fileSubSystem == null) {
+			if (connection == null)
+				return null;
+			ISubSystem[] subSystems = connection.getSubSystems();
+			for (int i = 0; i < subSystems.length; i++) {
+				if (subSystems[i] instanceof IFileServiceSubSystem) {
+					fileSubSystem = subSystems[i];
+					break;
+				}
+			}
+		}
+		return fileSubSystem;
+	}
+
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java
new file mode 100644
index 0000000..cb14c0b
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java
@@ -0,0 +1,117 @@
+package org.yocto.remote.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.services.files.IHostFile;
+
+public abstract class Session {
+	public static final String LT = System.getProperty("line.separator");
+	public static final String EXPORT_CMD = "export BB_ENV_EXTRAWHITE=\"DISABLE_SANITY_CHECKS $BB_ENV_EXTRAWHITE\"";
+
+	private final String initCmd;
+	private final IHostFile root;
+
+	public String terminator;
+	private volatile boolean interrupt = false;
+	private Process process;
+	private final OutputStream pos = null;
+	private IHost connection;
+
+	public Session(IHostFile root, String initCmd) throws IOException {
+		this.root = root;
+		this.initCmd  = initCmd;
+		initializeConnection();
+		initializeShell(new NullProgressMonitor());
+	}
+
+	protected abstract void initializeConnection();
+
+	private void initializeShell(IProgressMonitor monitor) throws IOException {
+		try {
+			if (root != null) {
+				RemoteHelper.handleRunCommandRemote(connection, new YoctoCommand("source " + initCmd, root.getAbsolutePath(), ""), monitor);
+				RemoteHelper.handleRunCommandRemote(connection,  new YoctoCommand(EXPORT_CMD, root.getAbsolutePath(), ""), monitor);
+			} else {
+				throw new Exception("Root file not found!");
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+	synchronized
+	public void execute(String command, String terminator, ICommandResponseHandler handler) throws IOException {
+		interrupt = false;
+		InputStream errIs = process.getErrorStream();
+		if (errIs.available() > 0) {
+			clearErrorStream(errIs);
+		}
+		sendToProcessAndTerminate(command);
+
+		BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
+		String std = null;
+
+		do {
+			if (errIs.available() > 0) {
+				byte[] msg = new byte[errIs.available()];
+
+				errIs.read(msg, 0, msg.length);
+				handler.response(new String(msg), true);
+			}
+
+			std = br.readLine();
+
+			if (std != null && !std.endsWith(terminator)) {
+				handler.response(std, false);
+			}
+
+		} while (std != null && !std.endsWith(terminator) && !interrupt);
+
+		if (interrupt) {
+			process.destroy();
+			initializeShell(null);
+			interrupt = false;
+		}
+	}
+
+	private void clearErrorStream(InputStream is) {
+
+		try {
+			byte b[] = new byte[is.available()];
+			is.read(b);
+			System.out.println("clearing: " + new String(b));
+		} catch (IOException e) {
+			e.printStackTrace();
+			//Ignore any error
+		}
+	}
+	/**
+	 * Send command string to shell process and add special terminator string so
+	 * reader knows when output is complete.
+	 *
+	 * @param command
+	 * @throws IOException
+	 */
+	private void sendToProcessAndTerminate(String command) throws IOException {
+		pos.write(command.getBytes());
+		pos.write(LT.getBytes());
+		pos.flush();
+		pos.write("echo $?".getBytes());
+		pos.write(terminator.getBytes());
+		pos.write(LT.getBytes());
+		pos.flush();
+	}
+
+	/**
+	 * Interrupt any running processes.
+	 */
+	public void interrupt() {
+		interrupt = true;
+	}
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java
new file mode 100644
index 0000000..0cd7dcd
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java
@@ -0,0 +1,53 @@
+package org.yocto.remote.utils;
+
+
+public class YoctoCommand {
+	private String command;
+	private String initialDirectory;
+	private String arguments;
+	private ProcessStreamBuffer processBuffer;
+
+	public YoctoCommand(String command, String initialDirectory, String arguments){
+		this.setCommand(command);
+		this.setInitialDirectory(initialDirectory);
+		this.setArguments(arguments);
+		this.setProcessBuffer(new ProcessStreamBuffer(false));
+	}
+
+	public String getCommand() {
+		return command;
+	}
+
+	public void setCommand(String command) {
+		this.command = command;
+	}
+
+	public String getInitialDirectory() {
+		return initialDirectory;
+	}
+
+	public void setInitialDirectory(String initialDirectory) {
+		this.initialDirectory = initialDirectory;
+	}
+
+	public String getArguments() {
+		return arguments;
+	}
+
+	public void setArguments(String arguments) {
+		this.arguments = arguments;
+	}
+
+	public ProcessStreamBuffer getProcessBuffer() {
+		return processBuffer;
+	}
+
+	public void setProcessBuffer(ProcessStreamBuffer processBuffer) {
+		this.processBuffer = processBuffer;
+	}
+
+	@Override
+	public String toString() {
+		return command + " " + arguments;
+	}
+}
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Refactor RFC 3/9] Remove ICommandResponseHandler from plugin and use org.yocto.remote.utils implementation
  2013-06-04 13:25 [Refactor RFC 0/9] Merging of windows-build with master Ioana Grigoropol
  2013-06-04 13:26 ` [Refactor RFC 1/9] Rename RSEHelper to RemoteHelper to match usages in org.yocto.bc.ui.plugin Ioana Grigoropol
  2013-06-04 13:26 ` [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities Ioana Grigoropol
@ 2013-06-04 13:26 ` Ioana Grigoropol
  2013-06-06 23:56   ` Zhang, Jessica
  2013-06-04 13:26 ` [Refactor RFC 4/9] Remove unused Bitbake Actions Ioana Grigoropol
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Ioana Grigoropol @ 2013-06-04 13:26 UTC (permalink / raw)
  To: yocto

- add dependency to remote common plugin
- update all references to use the common interface

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF       |    3 +-
 .../yocto/bc/bitbake/ICommandResponseHandler.java  |   15 ----------
 .../src/org/yocto/bc/bitbake/ShellSession.java     |    2 ++
 .../ui/actions/AbstractBitbakeCommandAction.java   |    3 +-
 .../yocto/bc/ui/wizards/install/InstallWizard.java |   30 ++++++--------------
 5 files changed, 13 insertions(+), 40 deletions(-)
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java

diff --git a/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF b/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF
index 6366424..3ca62df 100644
--- a/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF
@@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.ui.editors,
  org.eclipse.ui.ide,
  org.eclipse.ui.console,
- org.eclipse.core.filesystem
+ org.eclipse.core.filesystem,
+ org.yocto.remote.utils;bundle-version="1.0.0"
 Eclipse-LazyStart: true
 Bundle-ClassPath: .
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java
deleted file mode 100644
index 4c44352..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.bitbake;
-
-public interface ICommandResponseHandler {
-	public void response(String line, boolean isError);
-}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
index 4719865..db8f564 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
@@ -18,6 +18,8 @@ import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.Writer;
 
+import org.yocto.remote.utils.ICommandResponseHandler;
+
 /**
  * A class for Linux shell sessions.
  * @author kgilmer
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
index 41d5c73..cd4f4c9 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
@@ -29,12 +29,11 @@ import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 import org.eclipse.ui.console.MessageConsole;
 import org.eclipse.ui.console.MessageConsoleStream;
-
 import org.yocto.bc.bitbake.BBLanguageHelper;
 import org.yocto.bc.bitbake.BBSession;
-import org.yocto.bc.bitbake.ICommandResponseHandler;
 import org.yocto.bc.ui.Activator;
 import org.yocto.bc.ui.builder.BitbakeCommanderNature;
+import org.yocto.remote.utils.ICommandResponseHandler;
 
 public abstract class AbstractBitbakeCommandAction implements IWorkbenchWindowActionDelegate {
 
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java
index f2cb1da..3130cbf 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java
@@ -2,53 +2,39 @@ package org.yocto.bc.ui.wizards.install;
 
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileDescriptor;
-import java.io.InputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.io.OutputStream;
 import java.io.Writer;
-import java.util.ArrayList;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.WizardPage;
-
-import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWizard;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.console.MessageConsole;
-import org.eclipse.ui.console.MessageConsoleStream;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsoleManager;
 import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleManager;
 import org.eclipse.ui.console.IConsoleView;
-import org.eclipse.ui.progress.IProgressService;
-
-import org.yocto.bc.bitbake.ICommandResponseHandler;
-import org.yocto.bc.bitbake.ShellSession;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
 import org.yocto.bc.ui.Activator;
 import org.yocto.bc.ui.model.ProjectInfo;
 import org.yocto.bc.ui.wizards.FiniteStateWizard;
-
 import org.yocto.bc.ui.wizards.newproject.BBConfigurationInitializeOperation;
 import org.yocto.bc.ui.wizards.newproject.CreateBBCProjectOperation;
+import org.yocto.remote.utils.ICommandResponseHandler;
 
 /**
  * A wizard for installing a fresh copy of an OE system.
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Refactor RFC 4/9] Remove unused Bitbake Actions
  2013-06-04 13:25 [Refactor RFC 0/9] Merging of windows-build with master Ioana Grigoropol
                   ` (2 preceding siblings ...)
  2013-06-04 13:26 ` [Refactor RFC 3/9] Remove ICommandResponseHandler from plugin and use org.yocto.remote.utils implementation Ioana Grigoropol
@ 2013-06-04 13:26 ` Ioana Grigoropol
  2013-06-06 23:57   ` Zhang, Jessica
  2013-06-04 13:26 ` [Refactor RFC 5/9] Remove storing of init script location Ioana Grigoropol
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Ioana Grigoropol @ 2013-06-04 13:26 UTC (permalink / raw)
  To: yocto

- none of the Bitbake action classes that inherit from AbstractBitbakeCommandAction is used -> clean-up classes & plugin.xml

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 plugins/org.yocto.bc.ui/plugin.xml                 |   55 ------
 .../ui/actions/AbstractBitbakeCommandAction.java   |  198 --------------------
 .../bc/ui/actions/BitbakeBuildRecipeAction.java    |   24 ---
 .../bc/ui/actions/BitbakeCleanRecipeAction.java    |   26 ---
 .../yocto/bc/ui/actions/BitbakeImportAction.java   |  106 -----------
 .../bc/ui/actions/BitbakeRebuildRecipeAction.java  |   29 ---
 6 files changed, 438 deletions(-)
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java

diff --git a/plugins/org.yocto.bc.ui/plugin.xml b/plugins/org.yocto.bc.ui/plugin.xml
index cb0561c..2e1421f 100644
--- a/plugins/org.yocto.bc.ui/plugin.xml
+++ b/plugins/org.yocto.bc.ui/plugin.xml
@@ -39,61 +39,6 @@
             commandId="org.yocto.bc.ui.command.launchHob">
       </handler>
    </extension>
-   <!--
-   <extension
-         point="org.eclipse.ui.popupMenus">
-      <objectContribution
-            adaptable="true"
-            id="org.yocto.bc.ui.contribution2"
-            nameFilter="*.bb"
-            objectClass="org.eclipse.core.resources.IFile">
-         <action
-               class="org.yocto.bc.ui.actions.BitbakeBuildRecipeAction"
-               enablesFor="+"
-               icon="icons/binary.gif"
-               id="org.yocto.bc.ui.BuildPackagePopupAction"
-               label="Build"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Build a package">
-         </action>
-   		<action
-               class="org.yocto.bc.ui.actions.BitbakeCleanRecipeAction"
-               enablesFor="+"
-               icon="icons/trash.gif"
-               id="org.yocto.bc.ui.CleanPackagePopupAction"
-               label="Clean"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Clean a package">
-         </action>
-         <action
-               class="org.yocto.bc.ui.actions.BitbakeImportAction"
-               enablesFor="+"
-               icon="icons/import_wiz.gif"
-               id="org.yocto.bc.ui.BitbakeImportPopupAction"
-               label="Import"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Import package sources as Eclipse project.">
-         </action>
-         <menu
-               id="org.yocto.bc.ui.menu1"
-               label="BitBake"
-               path="additions">
-            <separator
-                  name="bc.separator1">
-            </separator>
-         </menu>
-         <action
-               class="org.yocto.bc.ui.actions.BitbakeRebuildRecipeAction"
-               enablesFor="+"
-               icon="icons/refresh.gif"
-               id="org.yocto.bc.ui.BuildPackagePopupAction"
-               label="Rebuild"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Rebuild a package">
-         </action>
-     </objectContribution>
-   </extension>
-   -->
    <extension
          point="org.eclipse.ui.menus">
       <menuContribution
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
deleted file mode 100644
index cd4f4c9..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.preference.JFacePreferences;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.console.MessageConsole;
-import org.eclipse.ui.console.MessageConsoleStream;
-import org.yocto.bc.bitbake.BBLanguageHelper;
-import org.yocto.bc.bitbake.BBSession;
-import org.yocto.bc.ui.Activator;
-import org.yocto.bc.ui.builder.BitbakeCommanderNature;
-import org.yocto.remote.utils.ICommandResponseHandler;
-
-public abstract class AbstractBitbakeCommandAction implements IWorkbenchWindowActionDelegate {
-
-	private class CommandJob extends Job {
-
-		public CommandJob() {
-			super(getJobTitle());
-		}
-
-		@Override
-		protected IStatus run(IProgressMonitor monitor) {
-			String cmds[] = getCommands();
-			return execCommands(cmds, monitor);
-		}
-
-	}
-	protected IAction action;
-	protected IFile recipe;
-	protected BBSession bbs;
-
-	private Color commandColor, responseColor, errorColor;
-	private boolean errorOccurred = false;
-
-	public AbstractBitbakeCommandAction() {
-		commandColor = JFaceResources.getColorRegistry().get(JFacePreferences.ACTIVE_HYPERLINK_COLOR);
-		responseColor = JFaceResources.getColorRegistry().get(JFacePreferences.HYPERLINK_COLOR);
-		errorColor = JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR);
-	}
-
-	private void checkEnabled(IFile file) {
-		try {
-			if (file.getFileExtension() == null || !file.getFileExtension().equals(BBLanguageHelper.BITBAKE_RECIPE_FILE_EXTENSION)) {
-				action.setEnabled(false);
-				return;
-			}
-
-			IProject project = file.getProject();
-			if (!(project.hasNature(BitbakeCommanderNature.NATURE_ID))) {
-				action.setEnabled(false);
-				return;
-			}
-
-			bbs = Activator.getBBSession(project.getLocationURI().getPath());
-
-			if (bbs != null) {
-				recipe = file;
-				action.setEnabled(true);
-			}
-
-		} catch (CoreException e) {
-			action.setEnabled(false);
-			e.printStackTrace();
-		} catch (Exception e) {
-			action.setEnabled(false);
-			e.printStackTrace();
-		}
-	}
-
-	public void dispose() {
-	}
-
-	/**
-	 * Execute array of commands with bitbake and put output in console.
-	 * 
-	 * @param cmds
-	 * @param monitor
-	 * @return
-	 */
-	protected IStatus execCommands(String[] cmds, final IProgressMonitor monitor) {
-		MessageConsole mc = bbs.getConsole();
-		final MessageConsoleStream cmd = mc.newMessageStream();
-		cmd.setColor(commandColor);
-		final MessageConsoleStream out = mc.newMessageStream();
-		final MessageConsoleStream err = mc.newMessageStream();
-		err.setColor(errorColor);
-		
-		try {
-			for (int i = 0; i < cmds.length; ++i) {
-				cmd.println(cmds[i]);
-				monitor.subTask(cmds[i]);
-				bbs.getShell().execute(cmds[i], new ICommandResponseHandler() {
-
-					public void response(String line, boolean isError) {
-						if (monitor.isCanceled()) {
-							cmd.println("Interrupting process by user request.");
-							bbs.getShell().interrupt();
-						}
-						
-						if (isError) {
-							err.println(line);
-							errorOccurred();
-						} else if (line.startsWith("ERROR:")) {
-							err.println(line);
-						} else {
-							out.println(line);
-						}
-					}
-				});
-			}
-		} catch (IOException e) {
-			return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
-		} finally {
-			try {
-				if (errorOccurred) {
-					cmd.println("At least one error occured while executing this command.  Check output for more details.");
-				}
-				cmd.close();
-				out.close();
-				err.close();
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-
-		return Status.OK_STATUS;
-	}
-
-	protected void errorOccurred() {
-		errorOccurred = true;
-	}
-
-	/**
-	 * Return the command to be executed.
-	 * 
-	 * @return
-	 */
-	public abstract String[] getCommands();
-
-	public Job getJob() {
-		return new CommandJob();
-	}
-
-	/**
-	 * Return the title of the job.
-	 * 
-	 * @return
-	 */
-	public abstract String getJobTitle();
-
-	public void init(IWorkbenchWindow window) {
-	}
-
-	public void run(IAction action) {
-		Job job = getJob();
-		job.schedule();
-	}
-
-	public void selectionChanged(IAction action, ISelection selection) {
-		this.action = action;
-		if (selection instanceof IStructuredSelection) {
-			Object sel = ((IStructuredSelection) selection).getFirstElement();
-
-			if (sel instanceof IFile) {
-				checkEnabled((IFile) sel);
-				return;
-			}
-		}
-
-		action.setEnabled(false);
-	}
-
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java
deleted file mode 100644
index 22ac94c..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-public  class BitbakeBuildRecipeAction extends AbstractBitbakeCommandAction {
-
-	@Override
-	public String [] getCommands() {
-		return new String[] {"bitbake -b " + recipe.getLocationURI().getPath()};
-	}
-
-	@Override
-	public String getJobTitle() {
-		return "Building " + recipe.getName();
-	}
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java
deleted file mode 100644
index f95117e..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-public class BitbakeCleanRecipeAction extends AbstractBitbakeCommandAction {
-
-	@Override
-	public String [] getCommands() {
-		return new String[] {"bitbake -c clean -b " + recipe.getLocationURI().getPath()};
-	}
-
-	@Override
-	public String getJobTitle() {
-		return "Cleaning " + recipe.getName();
-	}
-	
-
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java
deleted file mode 100644
index ecceecf..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-
-import org.yocto.bc.bitbake.BBCommonVars;
-import org.yocto.bc.bitbake.BBRecipe;
-import org.yocto.bc.ui.Activator;
-
-public  class BitbakeImportAction extends AbstractBitbakeCommandAction {
-
-	private class ImportJob extends Job {
-
-		public ImportJob() {
-			super(getJobTitle());
-		}
-
-		@Override
-		protected IStatus run(IProgressMonitor monitor) {
-			
-			try {
-				BBRecipe br = new BBRecipe(bbs, recipe.getLocationURI().getPath());
-				br.initialize();
-				String filePath = (String) br.get(BBCommonVars.S);
-				
-				//"${WORKDIR}/${PN}-${PV}"
-				if (filePath == null) {
-					filePath = ((String) br.get(BBCommonVars.WORKDIR)) + File.separator + ((String) br.get(BBCommonVars.PN)) + "-" + ((String) br.get(BBCommonVars.PV));
-				}
-				
-				String projectName = (String) br.get(BBCommonVars.PN);
-				
-				if (filePath == null || projectName == null) {
-					return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to parse recipe file.");
-				}
-				
-				File workdir = new File(filePath);
-				
-				if (workdir.exists() && workdir.isFile()) {
-					return new Status(IStatus.ERROR, Activator.PLUGIN_ID, workdir.getPath() + " is an invalid workdir.");
-				}
-			
-				if (!workdir.exists()) {
-					execCommands(new String[] {"bitbake -c patch -b " + recipe.getLocationURI().getPath()}, monitor);
-				}
-				
-				if (!workdir.exists()) {
-					return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to retrieve sources from BitBake.  Consult console.");
-				}
-				
-				IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
-				IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
-				IProject proj = wsroot.getProject(projectName);
-				proj.create(desc, monitor);		
-				proj.open(monitor);
-				
-				String copyCmd = "cp -r " + workdir.getAbsolutePath() + File.separator + "* \"" + proj.getLocationURI().getPath() + "\"";
-				execCommands(new String[] {copyCmd} , monitor);
-				
-				proj.refreshLocal(IResource.DEPTH_INFINITE, monitor);
-				
-			} catch (Exception e) {
-				e.printStackTrace();
-				return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to create project.", e);
-			}
-			
-			return Status.OK_STATUS;
-		}
-		
-	}
-
-	@Override
-	public String [] getCommands() {
-		return null;
-	}
-	
-
-	@Override
-	public Job getJob() {
-		return new ImportJob();
-	}
-	
-	@Override
-	public String getJobTitle() {
-		return "Importing " + recipe.getName();
-	}
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java
deleted file mode 100644
index c5dedea..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-/**
- * Rebuild a recipe.
- * @author kgilmer
- *
- */
-public  class BitbakeRebuildRecipeAction extends AbstractBitbakeCommandAction {
-
-	@Override
-	public String [] getCommands() {
-		return new String[] {"bitbake -c rebuild -b " + recipe.getLocationURI().getPath()};
-	}
-
-	@Override
-	public String getJobTitle() {
-		return "Rebuilding " + recipe.getName();
-	}
-}
\ No newline at end of file
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Refactor RFC 5/9] Remove storing of init script location
  2013-06-04 13:25 [Refactor RFC 0/9] Merging of windows-build with master Ioana Grigoropol
                   ` (3 preceding siblings ...)
  2013-06-04 13:26 ` [Refactor RFC 4/9] Remove unused Bitbake Actions Ioana Grigoropol
@ 2013-06-04 13:26 ` Ioana Grigoropol
  2013-06-07  0:02   ` Zhang, Jessica
  2013-06-04 13:26 ` [Refactor RFC 6/9] Remove unused method loadInit in Activator Ioana Grigoropol
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Ioana Grigoropol @ 2013-06-04 13:26 UTC (permalink / raw)
  To: yocto

- when create a new bitbake commander project and when initializing the configuration - the location of the init bitbake script is stored in a file called .eclipse-data
- the information stored here is never used

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../org/yocto/bc/bitbake/ProjectInfoHelper.java    |   23 --------------------
 .../BBConfigurationInitializeOperation.java        |    1 -
 .../newproject/CreateBBCProjectOperation.java      |    6 -----
 3 files changed, 30 deletions(-)

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
index 25dac97..b8d4b29 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
@@ -79,27 +79,4 @@ public class ProjectInfoHelper {
 
 		return null;
 	}
-
-	/**
-	 * This method will store the path to the bitbake init script for future
-	 * reference.
-	 * 
-	 * @param path
-	 * @param projInfo
-	 * @throws IOException
-	 */
-	public static void store(String path, ProjectInfo projInfo) throws IOException {
-		writeToFile(path, projInfo.getInitScriptPath());
-	}
-
-	private static void writeToFile(String path, String init) throws IOException {
-		File outFile = new File(path, ".eclipse-data");
-		FileOutputStream fos = new FileOutputStream(outFile);
-
-		fos.write(init.getBytes());
-
-		fos.flush();
-		fos.close();
-	}
-
 }
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
index 4f15107..64c3e6e 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
@@ -39,7 +39,6 @@ public class BBConfigurationInitializeOperation implements IRunnableWithProgress
 	public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
 		BBSession session;
 		try {
-			ProjectInfoHelper.store(pinfo.getRootPath(), pinfo);
 			session = Activator.getBBSession(pinfo.getRootPath(), writer);
 			session.initialize();
 
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
index dc0153b..1d54ea3 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
@@ -85,12 +85,6 @@ public class CreateBBCProjectOperation extends WorkspaceModifyOperation {
 
 		IProject proj = wsroot.getProject(projInfo.getProjectName());
 		proj.create(desc, monitor);
-		try {
-			ProjectInfoHelper.store(proj.getLocationURI().getPath(), projInfo);
-		} catch (IOException e) {
-			throw new InvocationTargetException(e);
-		}
-		
 		proj.open(monitor);
 
 		addNatures(proj, monitor);
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Refactor RFC 6/9] Remove unused method loadInit in Activator
  2013-06-04 13:25 [Refactor RFC 0/9] Merging of windows-build with master Ioana Grigoropol
                   ` (4 preceding siblings ...)
  2013-06-04 13:26 ` [Refactor RFC 5/9] Remove storing of init script location Ioana Grigoropol
@ 2013-06-04 13:26 ` Ioana Grigoropol
  2013-06-04 13:26 ` [Refactor RFC 7/9] Remove unused getInitScript from ProjectInfoHelper Ioana Grigoropol
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Ioana Grigoropol @ 2013-06-04 13:26 UTC (permalink / raw)
  To: yocto

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../src/org/yocto/bc/ui/Activator.java             |   23 --------------------
 1 file changed, 23 deletions(-)

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/Activator.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/Activator.java
index 505a254..a6c10c6 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/Activator.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/Activator.java
@@ -187,29 +187,6 @@ public class Activator extends AbstractUIPlugin {
 		return ss;
 	}
 
-	private static String loadInit(String absolutePath) throws CoreException {
-		IProject [] prjs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
-		IProject foundPrj = null;
-		
-		for (int i = 0; i < prjs.length; ++i) {
-			IProject p = prjs[i];
-			
-			System.out
-					.println(p.getDescription().getLocationURI().getPath());
-			
-			if (p.getDescription().getLocationURI().getPath().equals(absolutePath)) {
-				foundPrj = p;
-				break;
-			}
-		}
-		
-		if (foundPrj == null) {
-			throw new RuntimeException("Unable to find project associated with path! " + absolutePath);
-		}
-	
-		return foundPrj.getPersistentProperty(CreateBBCProjectOperation.BBC_PROJECT_INIT);
-	}
-	
 	public static void putProjInfo(String location, ProjectInfo pinfo) {
 		if (projInfoMap == null) {
 			projInfoMap = new Hashtable();
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Refactor RFC 7/9] Remove unused getInitScript from ProjectInfoHelper
  2013-06-04 13:25 [Refactor RFC 0/9] Merging of windows-build with master Ioana Grigoropol
                   ` (5 preceding siblings ...)
  2013-06-04 13:26 ` [Refactor RFC 6/9] Remove unused method loadInit in Activator Ioana Grigoropol
@ 2013-06-04 13:26 ` Ioana Grigoropol
  2013-06-04 13:26 ` [Refactor RFC 8/9] Use URI for storing project locations Ioana Grigoropol
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Ioana Grigoropol @ 2013-06-04 13:26 UTC (permalink / raw)
  To: yocto

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../org/yocto/bc/bitbake/ProjectInfoHelper.java    |   15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
index b8d4b29..0d95c01 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
@@ -48,21 +48,6 @@ public class ProjectInfoHelper {
 		return val;
 	}
 	
-	public static String getInitScript(String path) throws IOException {
-		File inFile = new File(path);
-		BufferedReader br = new BufferedReader(new FileReader(inFile));
-		StringBuffer sb = new StringBuffer();
-		String line = null;
-		
-		while ((line = br.readLine()) != null) {
-			sb.append(line);
-		}
-		
-		br.close();
-
-		return sb.toString();
-	}
-
 	public static String getProjectName(String projectRoot) {
 		IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
 		for (int i = 0; i < projects.length; ++i) {
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Refactor RFC 8/9] Use URI for storing project locations
  2013-06-04 13:25 [Refactor RFC 0/9] Merging of windows-build with master Ioana Grigoropol
                   ` (6 preceding siblings ...)
  2013-06-04 13:26 ` [Refactor RFC 7/9] Remove unused getInitScript from ProjectInfoHelper Ioana Grigoropol
@ 2013-06-04 13:26 ` Ioana Grigoropol
  2013-06-04 13:26 ` [Refactor RFC 9/9] Redirect bitbake environment parsing to file & parse Ioana Grigoropol
  2013-06-07  0:29 ` [Refactor RFC 0/9] Merging of windows-build with master Zhang, Jessica
  9 siblings, 0 replies; 20+ messages in thread
From: Ioana Grigoropol @ 2013-06-04 13:26 UTC (permalink / raw)
  To: yocto

Added new class YoctoLocation
- wrapper over URI based location
- return original URI for working with the file system(remote or local)
- return OEFS URI for working with OEFS File system

ProjectInfo
- use YoctoLocation instead of String for storing project location
- store IHost connection and FileService fields in project info

Propagate these changes to all the other files that use project in any way:
- Activator
	- map ShellSession to Project Infos
- ShellSession
	- store projectInfo
	- retrive underlying shell session from the Activator using project info
	- use IHostFile instead of File to store project location root
- BBRecipe
	- use URI instead of String for storing the path
- BBSession
        - store list of dependencies using URI
- ProjectInfoHelper
        - change getInitScriptPath to use URI
- OEFile
	- use URI instead of String for storing the path
- OEFileSystem
	- store project info
- BitbakeSourceViewerConfiguration
- BitbakeFileEditor
- LoadRecipeJob
- LaunchVariableWizardAction
- RecipeContentProvider
- ImportYoctoProjectWizard
- InstallWizard
- BBConfigurationInitializeOperation
- CreateBBCProjectOperation

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF       |    4 ++
 .../src/org/yocto/bc/bitbake/BBRecipe.java         |   24 +++----
 .../src/org/yocto/bc/bitbake/BBSession.java        |   34 +++++----
 .../org/yocto/bc/bitbake/ProjectInfoHelper.java    |   22 +++---
 .../src/org/yocto/bc/bitbake/ShellSession.java     |   16 ++++-
 .../src/org/yocto/bc/ui/Activator.java             |   60 +++++++++-------
 .../bc/ui/actions/LaunchVariableWizardAction.java  |   16 ++++-
 .../bc/ui/editors/bitbake/BBVariableTextHover.java |   16 ++---
 .../bc/ui/editors/bitbake/BitBakeFileEditor.java   |   16 ++++-
 .../bitbake/BitBakeSourceViewerConfiguration.java  |   14 +++-
 .../src/org/yocto/bc/ui/filesystem/OEFile.java     |   13 ++--
 .../org/yocto/bc/ui/filesystem/OEFileSystem.java   |   24 ++++++-
 .../org/yocto/bc/ui/filesystem/YoctoLocation.java  |   34 +++++++++
 .../src/org/yocto/bc/ui/model/ProjectInfo.java     |   75 +++++++++++++++++---
 .../yocto/bc/ui/views/RecipeContentProvider.java   |    2 +-
 .../importProject/ImportYoctoProjectWizard.java    |    7 +-
 .../yocto/bc/ui/wizards/install/InstallWizard.java |    9 ++-
 .../BBConfigurationInitializeOperation.java        |    2 +-
 .../newproject/CreateBBCProjectOperation.java      |   14 ++--
 19 files changed, 281 insertions(+), 121 deletions(-)
 create mode 100755 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/YoctoLocation.java

diff --git a/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF b/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF
index 3ca62df..7cecce8 100644
--- a/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF
@@ -18,3 +18,7 @@ Require-Bundle: org.eclipse.ui,
  org.yocto.remote.utils;bundle-version="1.0.0"
 Eclipse-LazyStart: true
 Bundle-ClassPath: .
+Import-Package: org.eclipse.ptp.remote.core,
+ org.eclipse.rse.core.model,
+ org.eclipse.rse.services.clientserver.messages,
+ org.eclipse.rse.services.files
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
index 2b355ba..1baf124 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
@@ -11,14 +11,7 @@
 package org.yocto.bc.bitbake;
 
 import java.io.IOException;
-
-import org.eclipse.jface.preference.JFacePreferences;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.MessageConsole;
-import org.eclipse.ui.console.MessageConsoleStream;
+import java.net.URI;
 
 /**
  * Represents the bitbake environment of a recipe package.
@@ -27,24 +20,25 @@ import org.eclipse.ui.console.MessageConsoleStream;
  */
 public class BBRecipe extends BBSession {
 	private final BBSession session;
-	private final String filePath;
+	private final URI fileURI;
 
-	public BBRecipe(BBSession session, String filePath) throws IOException {
-		super(session.shell, session.pinfo.getRootPath());
+	public BBRecipe(BBSession session, URI filePath) throws IOException {
+		super(session.shell, session.pinfo.getOriginalURI());
 		this.session = session;
-		this.filePath = filePath;
+		this.fileURI = filePath;
 		this.parsingCmd = "DISABLE_SANITY_CHECKS=1 bitbake -e -b " + filePath;
 	}
 	
 	@Override
 	public void initialize() throws Exception {
 		if (this.size() == 0) {
-			//System.out.println("Failed to parse " + filePath);
+			//System.out.println("Failed to parse " + fileURI);
 			//throw new IOException("Failed to parse " + filePath);
 		}
 	}
 
-	protected String getDefaultDepends() {
-		return this.filePath;
+	@Override
+	protected URI getDefaultDepends() {
+		return this.fileURI;
 	}
 }
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
index e998bcd..fcde557 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
@@ -15,6 +15,7 @@ import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
 import java.io.StringReader;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -65,8 +66,8 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 
 	protected final ProjectInfo pinfo;
 	protected final ShellSession shell;
-	protected Map properties = null;
-	protected List <String> depends = null;
+	protected Map<?,?> properties = null;
+	protected List <URI> depends = null;
 	protected boolean initialized = false;
 	protected MessageConsole sessionConsole;
 	private final ReentrantReadWriteLock rwlock = new ReentrantReadWriteLock();
@@ -75,15 +76,15 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 	protected String parsingCmd;
 	private boolean silent = false;
 	
-	public BBSession(ShellSession ssession, String projectRoot) throws IOException {
+	public BBSession(ShellSession ssession, URI projectRoot) throws IOException {
 		shell = ssession;
 		this.pinfo = new ProjectInfo();
-		pinfo.setLocation(projectRoot);
+		pinfo.setLocationURI(projectRoot);
 		pinfo.setInitScriptPath(ProjectInfoHelper.getInitScriptPath(projectRoot));
 		this.parsingCmd = "DISABLE_SANITY_CHECKS=1 bitbake -e";
 	}
 
-	public BBSession(ShellSession ssession, String projectRoot, boolean silent) throws IOException {
+	public BBSession(ShellSession ssession, URI projectRoot, boolean silent) throws IOException {
 		this(ssession, projectRoot);
 		this.silent = silent;
 	}
@@ -182,8 +183,8 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 		return shell;
 	}
 
-	public String getProjInfoRoot() {
-		return pinfo.getRootPath();
+	public URI getProjInfoRoot() {
+		return pinfo.getOriginalURI();
 	}
 
 	/**
@@ -261,7 +262,7 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 	 */
 	public MessageConsole getConsole() {
 		if (sessionConsole == null) {
-			String cName = ProjectInfoHelper.getProjectName(pinfo.getRootPath()) + " Console";
+			String cName = ProjectInfoHelper.getProjectName(pinfo.getOriginalURI()) + " Console";
 			IConsoleManager conMan = ConsolePlugin.getDefault().getConsoleManager();
 			IConsole[] existing = conMan.getConsoles();
 			for (int i = 0; i < existing.length; i++)
@@ -330,8 +331,8 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 	}
 
 	protected int checkExecuteError(String result, int code) {
-		String recipe = getDefaultDepends();
-		String text = "Parsing " + ((recipe != null) ? ("recipe " + recipe) : "base configurations");
+		URI recipeURI = getDefaultDepends();
+		String text = "Parsing " + ((recipeURI != null) ? ("recipe " + recipeURI) : "base configurations");
 		if (code != 0) {
 			text = text + " ERROR!\n" + result;
 		}else {
@@ -503,13 +504,13 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 		}
 	}
 
-	protected String getDefaultDepends() {
+	protected URI getDefaultDepends() {
 		return null;
 	}
 	
 	protected Map parseBBEnvironment(String bbOut) throws Exception {
 		Map env = new Hashtable();
-		this.depends = new ArrayList<String>();
+		this.depends = new ArrayList<URI>();
 
 		parse(bbOut, env);
 
@@ -518,12 +519,15 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 			this.depends.add(getDefaultDepends());
 		}
 		if(included != null) {
-			this.depends.addAll(Arrays.asList(included.split(" ")));
+			String[] includedSplitted = included.split(" ");
+			for (String incl : includedSplitted){
+				this.depends.add(new URI(incl));
+			}
 		}
 
 		return env;
 	}
-	
+
 
 	private List parseBBFiles(String bbfiles) {
 		return Arrays.asList(bbfiles.split(" "));
@@ -719,7 +723,7 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 		try {
 			if (initialized && (removed != null || changed != null)) {
 				for(int i=0;removed != null && i<removed.length;i++) {
-					if (this.depends.contains(removed[i].getLocation().toString())) {
+					if (this.depends.contains(removed[i].getLocationURI())) {
 						initialized = false;
 						return;
 					}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
index 0d95c01..c053c28 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
@@ -15,6 +15,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileReader;
 import java.io.IOException;
+import java.net.URI;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
@@ -28,6 +29,9 @@ import org.yocto.bc.ui.model.ProjectInfo;
  * 
  */
 public class ProjectInfoHelper {
+	public static final String OEFS_SCHEME = "OEFS://";
+	public static final String FILE_SCHEME = "file";
+	public static final String RSE_SCHEME = "rse";
 
 	protected static final String DEFAULT_INIT_SCRIPT = "oe-init-build-env";
 	/**
@@ -35,24 +39,16 @@ public class ProjectInfoHelper {
 	 * @return The path to bitbake init script
 	 * @throws IOException
 	 */
-	public static String getInitScriptPath(String path) throws IOException {
-		String val = path + File.separator + DEFAULT_INIT_SCRIPT;
-
-		File inFile = new File(path, ".eclipse-data");
-		if(inFile.exists()) {
-			BufferedReader br = new BufferedReader(new FileReader(inFile));
-			val = br.readLine();
-			br.close();
-		}
-
+	public static String getInitScriptPath(URI uri) throws IOException {
+		String val = uri.getPath() + "/" + DEFAULT_INIT_SCRIPT;
 		return val;
 	}
-	
-	public static String getProjectName(String projectRoot) {
+
+	public static String getProjectName(URI projectRoot) {
 		IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
 		for (int i = 0; i < projects.length; ++i) {
 			try {
-				if (projects[i].getLocationURI().getPath().equals(projectRoot)) {
+				if (projects[i].getLocationURI().equals(projectRoot)) {
 					return projects[i].getName();
 				}
 
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
index db8f564..44b2696 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
@@ -18,6 +18,8 @@ import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.Writer;
 
+import org.eclipse.rse.services.files.IHostFile;
+import org.yocto.bc.ui.model.ProjectInfo;
 import org.yocto.remote.utils.ICommandResponseHandler;
 
 /**
@@ -65,11 +67,21 @@ public class ShellSession {
 	//private File initFile = null;
 	private String shellPath = null;
 	private final String initCmd;
-	private final File root;
+	private final IHostFile root;
 	private final Writer out;
 	
+	private ProjectInfo projectInfo;
 
-	public ShellSession(int shellType, File root, String initCmd, Writer out) throws IOException {
+	public ProjectInfo getProjectInfo() {
+		return projectInfo;
+	}
+
+	public void setProjectInfo(ProjectInfo projectInfo) {
+		this.projectInfo = projectInfo;
+	}
+
+	public ShellSession(ProjectInfo pInfo, int shellType, IHostFile root, String initCmd, Writer out) throws IOException {
+		this.projectInfo = pInfo;
 		this.root = root;
 		this.initCmd  = initCmd;
 		if (out == null) {
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/Activator.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/Activator.java
index a6c10c6..ded1e44 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/Activator.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/Activator.java
@@ -14,6 +14,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.Writer;
 import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
@@ -24,8 +25,10 @@ import org.eclipse.core.resources.IResourceChangeEvent;
 import org.eclipse.core.resources.IResourceChangeListener;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.rse.services.files.IHostFile;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
 
@@ -35,6 +38,7 @@ import org.yocto.bc.bitbake.ProjectInfoHelper;
 import org.yocto.bc.bitbake.ShellSession;
 import org.yocto.bc.ui.model.ProjectInfo;
 import org.yocto.bc.ui.wizards.newproject.CreateBBCProjectOperation;
+import org.yocto.remote.utils.RemoteHelper;
 
 public class Activator extends AbstractUIPlugin {
 
@@ -46,21 +50,21 @@ public class Activator extends AbstractUIPlugin {
 	// The shared instance
 	private static Activator plugin;
 	private static Map shellMap;
-	private static Map projInfoMap;
+	private static Map<URI, ProjectInfo> projInfoMap;
 	private static Hashtable bbSessionMap;
 	private static Hashtable bbRecipeMap;
 
 	private IResourceChangeListener listener = new BCResourceChangeListener();
 
-	public static BBRecipe getBBRecipe(BBSession session, String filePath) throws IOException {
+	public static BBRecipe getBBRecipe(BBSession session, URI fileURI) throws IOException {
 		if (bbRecipeMap == null) {
 			bbRecipeMap = new Hashtable();
 		}
 
-		String key = session.getProjInfoRoot() + filePath;
+		URI key = session.getProjInfoRoot();
 		BBRecipe recipe = (BBRecipe) bbRecipeMap.get(key);
 		if (recipe == null) {
-			recipe = new BBRecipe(session,filePath);
+			recipe = new BBRecipe(session, fileURI);
 			bbRecipeMap.put(key, recipe);
 		}
 
@@ -73,7 +77,8 @@ public class Activator extends AbstractUIPlugin {
 	 * @return
 	 * @throws IOException
 	 */
-	public static BBSession getBBSession(String projectRoot, Writer out) throws IOException {
+	public static BBSession getBBSession(ProjectInfo projectInfo, Writer out, IProgressMonitor monitor) throws IOException {
+		URI projectRoot = projectInfo.getOriginalURI();
 		if (bbSessionMap == null) {
 			bbSessionMap = new Hashtable();
 		}
@@ -81,7 +86,7 @@ public class Activator extends AbstractUIPlugin {
 		BBSession bbs = (BBSession) bbSessionMap.get(projectRoot);
 		
 		if (bbs == null) {
-			bbs = new BBSession(getShellSession(projectRoot, out), projectRoot);
+			bbs = new BBSession(getShellSession(projectInfo, out, monitor), projectRoot);
 			bbSessionMap.put(projectRoot, bbs);
 		}
 		
@@ -94,7 +99,8 @@ public class Activator extends AbstractUIPlugin {
 	 * @return
 	 * @throws IOException
 	 */
-	public static BBSession getBBSession(String projectRoot) throws IOException {
+	public static BBSession getBBSession(ProjectInfo projectInfo, IProgressMonitor monitor) throws Exception {
+		URI projectRoot = projectInfo.getOriginalURI();
 		if (bbSessionMap == null) {
 			bbSessionMap = new Hashtable();
 		}
@@ -102,7 +108,7 @@ public class Activator extends AbstractUIPlugin {
 		BBSession bbs = (BBSession) bbSessionMap.get(projectRoot);
 		
 		if (bbs == null) {
-			bbs = new BBSession(getShellSession(projectRoot, null), projectRoot);
+			bbs = new BBSession(getShellSession(projectInfo, null, monitor), projectRoot);
 			bbSessionMap.put(projectRoot, bbs);
 		}
 		
@@ -129,24 +135,26 @@ public class Activator extends AbstractUIPlugin {
 		return imageDescriptorFromPlugin(PLUGIN_ID, path);
 	}
 
-	public static ProjectInfo getProjInfo(String location) throws CoreException, InvocationTargetException, InterruptedException {
+	public static ProjectInfo getProjInfo(URI location) throws CoreException, InvocationTargetException, InterruptedException {
 		if (projInfoMap == null) {
-			projInfoMap = new Hashtable();
+			projInfoMap = new Hashtable<URI, ProjectInfo>();
 		}
-		
-		ProjectInfo pi = (ProjectInfo) projInfoMap.get(location);
-		
-		if (pi == null) {
-			pi = new ProjectInfo();
-			pi.setLocation(location);
-			try {
-				pi.setInitScriptPath(ProjectInfoHelper.getInitScriptPath(location));
-			} catch (IOException e) {
-				throw new InvocationTargetException(e);
+		if (location != null) {
+			ProjectInfo pi = projInfoMap.get(location);
+			if (pi == null) {
+				pi = new ProjectInfo();
+				pi.setLocationURI(location);
+				try {
+					pi.setInitScriptPath(ProjectInfoHelper.getInitScriptPath(location));
+				} catch (IOException e) {
+					throw new InvocationTargetException(e);
+				}
+
+				projInfoMap.put(location, pi);
 			}
+			return pi;
 		}
-		
-		return pi;
+		return null;
 	}
 
 	public static void notifyAllBBSession(IResource[] added, IResource[] removed, IResource[] changed) {
@@ -173,7 +181,8 @@ public class Activator extends AbstractUIPlugin {
 	 * @return a cached shell session for a given project root.
 	 * @throws IOException 
 	 */
-	private static ShellSession getShellSession(String absolutePath, Writer out) throws IOException {
+	private static ShellSession getShellSession(ProjectInfo projInfo, Writer out, IProgressMonitor monitor) throws IOException {
+		URI absolutePath = projInfo.getOriginalURI();
 		if (shellMap == null) {
 			shellMap = new Hashtable();
 		}
@@ -181,13 +190,14 @@ public class Activator extends AbstractUIPlugin {
 		ShellSession ss = (ShellSession) shellMap.get(absolutePath);
 		
 		if (ss == null) {
-			ss = new ShellSession(ShellSession.SHELL_TYPE_BASH, new File(absolutePath), ProjectInfoHelper.getInitScriptPath(absolutePath), out);
+			IHostFile remoteHostFile = RemoteHelper.getRemoteHostFile(projInfo.getConnection(), absolutePath.getPath(), monitor);
+			ss = new ShellSession(projInfo, ShellSession.SHELL_TYPE_BASH, remoteHostFile, ProjectInfoHelper.getInitScriptPath(absolutePath), out);
 		}
 		
 		return ss;
 	}
 
-	public static void putProjInfo(String location, ProjectInfo pinfo) {
+	public static void putProjInfo(URI location, ProjectInfo pinfo) {
 		if (projInfoMap == null) {
 			projInfoMap = new Hashtable();
 		}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java
index eaf716e..1899098 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java
@@ -11,20 +11,22 @@
 package org.yocto.bc.ui.actions;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Map;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
 import org.yocto.bc.ui.Activator;
 import org.yocto.bc.ui.builder.BitbakeCommanderNature;
+import org.yocto.bc.ui.model.ProjectInfo;
 import org.yocto.bc.ui.wizards.variable.VariableWizard;
 
 /**
@@ -62,13 +64,21 @@ public class LaunchVariableWizardAction implements IWorkbenchWindowActionDelegat
 				IProject p = ((IResource)element).getProject();
 
 				try {
-					if (p.isOpen() && p.hasNature(BitbakeCommanderNature.NATURE_ID)) {
-						session = Activator.getBBSession(((IResource)element).getProject().getLocationURI().getPath());
+					if (p.isAccessible() && p.isOpen() && p.hasNature(BitbakeCommanderNature.NATURE_ID)) {
+						IProject proj = ((IResource)element).getProject();
+						ProjectInfo projInfo = Activator.getProjInfo(proj.getLocationURI());
+						session = Activator.getBBSession(projInfo, new NullProgressMonitor());
 					}
 				} catch (IOException e) {
 					e.printStackTrace();
 				} catch (CoreException e) {
 					e.printStackTrace();
+				} catch (InvocationTargetException e) {
+					e.printStackTrace();
+				} catch (InterruptedException e) {
+					e.printStackTrace();
+				} catch (Exception e) {
+					e.printStackTrace();
 				}
 			}
 		}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BBVariableTextHover.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BBVariableTextHover.java
index 9478423..28e98d4 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BBVariableTextHover.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BBVariableTextHover.java
@@ -3,7 +3,7 @@
  */
 package org.yocto.bc.ui.editors.bitbake;
 
-import java.io.File;
+import java.net.URI;
 import java.util.Map;
 
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -14,7 +14,6 @@ import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.ITextHover;
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.Region;
-
 import org.yocto.bc.bitbake.BBRecipe;
 import org.yocto.bc.bitbake.BBSession;
 import org.yocto.bc.ui.Activator;
@@ -28,18 +27,15 @@ class BBVariableTextHover implements ITextHover {
 	private final BBSession session;
 	private volatile Map envMap;
 
-	public BBVariableTextHover(BBSession session, String file) {
+	public BBVariableTextHover(BBSession session, URI file) {
 		this.session = session;
 		envMap = session;
 		LoadRecipeJob loadRecipeJob = new LoadRecipeJob(getFilename(file), file);
 		loadRecipeJob.schedule();
 	}
 
-	private String getFilename(String file) {
-		
-		String [] elems = file.split(File.separator);
-		
-		return elems[elems.length - 1];
+	private String getFilename(URI uri) {
+		return uri.getPath();
 	}
 
 	public IRegion getHoverRegion(ITextViewer tv, int off) {
@@ -95,9 +91,9 @@ class BBVariableTextHover implements ITextHover {
 	}
 	
 	private class LoadRecipeJob extends Job {
-		private final String filePath;
+		private final URI filePath;
 
-		public LoadRecipeJob(String name, String filePath) {
+		public LoadRecipeJob(String name, URI filePath) {
 			super("Extracting BitBake environment for " + name);
 			this.filePath = filePath;
 		}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeFileEditor.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeFileEditor.java
index b33f030..7535341 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeFileEditor.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeFileEditor.java
@@ -11,10 +11,13 @@
 package org.yocto.bc.ui.editors.bitbake;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ResourceBundle;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorSite;
@@ -23,8 +26,8 @@ import org.eclipse.ui.part.FileEditorInput;
 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
 import org.eclipse.ui.texteditor.ContentAssistAction;
 import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-
 import org.yocto.bc.ui.Activator;
+import org.yocto.bc.ui.model.ProjectInfo;
 
 /**
  * Editor for BB Recipe
@@ -64,10 +67,19 @@ public class BitBakeFileEditor extends AbstractDecoratedTextEditor {
 			viewerConfiguration.setTargetFile(targetFile);
 			
 			try {
-				viewerConfiguration.setBBSession(Activator.getBBSession(p.getLocationURI().getPath()));
+				ProjectInfo projInfo = Activator.getProjInfo(p.getLocationURI());
+				viewerConfiguration.setBBSession(Activator.getBBSession(projInfo, new NullProgressMonitor()));
 			} catch (IOException e) {
 				e.printStackTrace();
 				throw new PartInitException(Status.CANCEL_STATUS);
+			} catch (InvocationTargetException e) {
+				e.printStackTrace();
+			} catch (CoreException e) {
+				e.printStackTrace();
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			} catch (Exception e) {
+				e.printStackTrace();
 			}
 		}
 		super.init(site, input);
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeSourceViewerConfiguration.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeSourceViewerConfiguration.java
index 56cd014..2be6f1d 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeSourceViewerConfiguration.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeSourceViewerConfiguration.java
@@ -10,6 +10,9 @@
  *******************************************************************************/
 package org.yocto.bc.ui.editors.bitbake;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+
 import org.eclipse.core.resources.IFile;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.ITextHover;
@@ -33,7 +36,6 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
-
 import org.yocto.bc.bitbake.BBLanguageHelper;
 import org.yocto.bc.bitbake.BBSession;
 
@@ -66,7 +68,15 @@ public class BitBakeSourceViewerConfiguration extends TextSourceViewerConfigurat
 	public ITextHover getTextHover(ISourceViewer sv, String contentType) {
 		//only .bb file support Text Hover.
 		if (textHover == null && targetFile.getFileExtension().equals(BBLanguageHelper.BITBAKE_RECIPE_FILE_EXTENSION)) {
-			textHover = new BBVariableTextHover(session, targetFile.getLocationURI().getPath());
+			URI root = session.getProjInfoRoot();
+			try {
+				String targetFileProjPath = targetFile.getProjectRelativePath().toPortableString();
+				URI targetFileURI = new URI(root.getScheme(), root.getHost(), root.getPath() + "/" +
+						targetFileProjPath, root.getFragment());
+				textHover = new BBVariableTextHover(session, targetFileURI);
+			} catch (URISyntaxException e) {
+				e.printStackTrace();
+			}
 		}
 		
 		return textHover;
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFile.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFile.java
index 85794f1..8340597 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFile.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFile.java
@@ -39,6 +39,7 @@ import org.eclipse.osgi.util.NLS;
 import org.yocto.bc.bitbake.BBSession;
 import org.yocto.bc.bitbake.ProjectInfoHelper;
 import org.yocto.bc.bitbake.ShellSession;
+import org.yocto.bc.ui.Activator;
 
 /**
  * File system implementation based on storage of files in the local
@@ -62,7 +63,7 @@ public class OEFile extends FileStore {
 	 */
 	protected final String filePath;
 
-	private final String root;
+	private final URI root;
 
 	/**
 	 * Creates a new local file.
@@ -70,7 +71,7 @@ public class OEFile extends FileStore {
 	 * @param file The file this local file represents
 	 * @param root 
 	 */
-	public OEFile(File file, List ignorePaths, String root) {
+	public OEFile(File file, List ignorePaths, URI root) {
 		this.file = file;
 		this.ignorePaths = ignorePaths;
 		this.root = root;
@@ -117,13 +118,11 @@ public class OEFile extends FileStore {
 	/*
 	 * try to find items for ignoreList
 	 */
-	private void updateIgnorePaths(String path, List list) {
+	private void updateIgnorePaths(String path, List<Object> list, IProgressMonitor monitor) {
 		if(isPotentialBuildDir(path)) {
 			BBSession config = null;
 			try {
-				ShellSession shell = new ShellSession(ShellSession.SHELL_TYPE_BASH, new File(root), 
-							ProjectInfoHelper.getInitScriptPath(root) + " " + path, null);
-				config = new BBSession(shell, root, true);
+				config = Activator.getBBSession(Activator.getProjInfo(root), monitor);
 				config.initialize();
 			} catch(Exception e) {
 				e.printStackTrace();
@@ -154,7 +153,7 @@ public class OEFile extends FileStore {
 		for (int i = 0; i < wrapped.length; i++) {
 			String fullPath = file.toString() +File.separatorChar + children[i];
 			
-			updateIgnorePaths(fullPath, ignorePaths);
+			updateIgnorePaths(fullPath, ignorePaths, monitor);
 			if (ignorePaths.contains(fullPath)) {
 				wrapped[i] = getDeadChild(children[i]);
 			} else {
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java
index f0bf449..19c9dbc 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java
@@ -11,6 +11,7 @@
 package org.yocto.bc.ui.filesystem;
 
 import java.io.File;
+import java.lang.reflect.InvocationTargetException;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Hashtable;
@@ -20,9 +21,12 @@ import java.util.Map;
 import org.eclipse.core.filesystem.IFileStore;
 import org.eclipse.core.filesystem.IFileSystem;
 import org.eclipse.core.filesystem.provider.FileSystem;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
 
 import org.yocto.bc.bitbake.BBSession;
 import org.yocto.bc.ui.Activator;
+import org.yocto.bc.ui.model.ProjectInfo;
 
 /**
  * A filesystem that ignores specific OE directories that contain derived information.
@@ -32,6 +36,8 @@ import org.yocto.bc.ui.Activator;
 public class OEFileSystem extends FileSystem {
 
 	private static IFileSystem ref;
+	private ProjectInfo projInfo;
+
 	public static IFileSystem getInstance() {
 		return ref;
 	}
@@ -47,11 +53,12 @@ public class OEFileSystem extends FileSystem {
 	public IFileStore getStore(URI uri) {
 		
 		OEFile uf = (OEFile) fileStoreCache.get(uri);
+		setProjInfo(uri);
 		
 		if (uf == null) {
 			BBSession config = null;
 			try {
-				config = Activator.getBBSession(uri.getPath());
+				config = Activator.getBBSession(projInfo, new NullProgressMonitor());
 				config.initialize();
 			} catch (Exception e) {
 				e.printStackTrace();
@@ -69,10 +76,23 @@ public class OEFileSystem extends FileSystem {
 			ignoreList.add(config.get("DL_DIR"));
 			ignoreList.add(config.get("SSTATE_DIR"));
 			
-			uf = new OEFile(new File(uri.getPath()), ignoreList, uri.getPath());
+			uf = new OEFile(new File(uri.getPath()), ignoreList, uri);
 			fileStoreCache.put(uri, uf);
 		}
 		
 		return uf;
 	}
+
+	private void setProjInfo(URI uri) {
+		try {
+			if(projInfo == null)
+				projInfo = Activator.getProjInfo(uri);
+		} catch (CoreException e) {
+			e.printStackTrace();
+		} catch (InvocationTargetException e) {
+			e.printStackTrace();
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+	}
 }
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/YoctoLocation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/YoctoLocation.java
new file mode 100755
index 0000000..ab99177
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/YoctoLocation.java
@@ -0,0 +1,34 @@
+package org.yocto.bc.ui.filesystem;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class YoctoLocation{
+	URI oefsURI;
+	URI originalURI;
+
+	public YoctoLocation(){
+		try {
+			oefsURI = new URI("");
+			originalURI = new URI("");
+		} catch (URISyntaxException e) {
+			e.printStackTrace();
+		}
+	}
+
+	public URI getOEFSURI() {
+		return oefsURI;
+	}
+
+	public URI getOriginalURI() {
+		return originalURI;
+	}
+
+	public void setOriginalURI(URI originalURI) {
+		this.originalURI = originalURI;
+	}
+
+	public void setOEFSURI(URI uri) {
+		this.oefsURI = uri;
+	}
+}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/model/ProjectInfo.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/model/ProjectInfo.java
index 3af1e2a..5ce6308 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/model/ProjectInfo.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/model/ProjectInfo.java
@@ -10,12 +10,25 @@
  *******************************************************************************/
 package org.yocto.bc.ui.model;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.ptp.remote.core.IRemoteServices;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.services.files.IFileService;
+import org.yocto.bc.bitbake.ProjectInfoHelper;
+import org.yocto.bc.ui.filesystem.YoctoLocation;
+import org.yocto.remote.utils.RemoteHelper;
 
 public class ProjectInfo implements IModelElement {
 	private String name;
-	private String location;
+	private YoctoLocation location;
 	private String init;
-	
+	private IHost connection;
+	private IRemoteServices remoteServices;
+
 	public ProjectInfo() {
 	}
 	
@@ -25,12 +38,18 @@ public class ProjectInfo implements IModelElement {
 	public String getProjectName() {
 		return name;
 	}
-	public String getRootPath() {
-		return location;
+	public URI getOriginalURI() {
+		return location.getOriginalURI();
+	}
+
+	public URI getOEFSURI() {
+		return location.getOEFSURI();
 	}
+
+	@Override
 	public void initialize() throws Exception {
 		name = new String();
-		location = new String();
+		location = new YoctoLocation();
 		init = new String();
 	}
 
@@ -38,11 +57,51 @@ public class ProjectInfo implements IModelElement {
 		this.init = init;
 	}
 
-	public void setLocation(String location) {
-		this.location = location;
+	public void setLocationURI(URI location) {
+		if (this.location == null)
+			this.location = new YoctoLocation();
+		this.location.setOriginalURI(location);
+		try {
+			this.location.setOEFSURI(new URI(ProjectInfoHelper.OEFS_SCHEME + location.getPath() ));
+		} catch (URISyntaxException e) {
+			try {
+				this.location.setOEFSURI(new URI(""));
+			} catch (URISyntaxException e1) {
+				e1.printStackTrace();
+			}
+			e.printStackTrace();
+		}
 	}
-	
+
 	public void setName(String name) {
 		this.name = name;
 	}
+
+	public IHost getConnection() {
+		if (connection == null) {
+			connection = RemoteHelper.getRemoteConnectionForURI(location.getOriginalURI(), new NullProgressMonitor());
+		}
+		return connection;
+	}
+
+	public void setConnection(IHost connection) {
+		this.connection = connection;
+	}
+
+	public IRemoteServices getRemoteServices() {
+		return remoteServices;
+	}
+
+	public void setRemoteServices(IRemoteServices remoteServices) {
+		this.remoteServices = remoteServices;
+	}
+
+	public IFileService getFileService(IProgressMonitor monitor){
+		try {
+			return RemoteHelper.getConnectedRemoteFileService(connection, monitor);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
 }
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java
index 7e29e7a..d657fd5 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java
@@ -51,7 +51,7 @@ class RecipeContentProvider implements IStructuredContentProvider {
 	}
 
 	private Collection getRecipesFromProject(IProject project) throws Exception {
-		BBSession session = Activator.getBBSession(project.getLocationURI().getPath(), null);
+		BBSession session = Activator.getBBSession(Activator.getProjInfo(project.getLocationURI()), null);
 		return session.getRecipeFiles(project);
 	}
 
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/importProject/ImportYoctoProjectWizard.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/importProject/ImportYoctoProjectWizard.java
index b1fc841..82c5ab3 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/importProject/ImportYoctoProjectWizard.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/importProject/ImportYoctoProjectWizard.java
@@ -12,6 +12,7 @@ package org.yocto.bc.ui.wizards.importProject;
 
 import java.io.IOException;
 import java.io.Writer;
+import java.net.URI;
 import java.util.Hashtable;
 import java.util.Map;
 
@@ -29,11 +30,9 @@ import org.eclipse.ui.console.IConsoleConstants;
 import org.eclipse.ui.console.IConsoleManager;
 import org.eclipse.ui.console.IConsoleView;
 import org.eclipse.ui.console.MessageConsole;
-
 import org.yocto.bc.ui.Activator;
 import org.yocto.bc.ui.model.ProjectInfo;
 import org.yocto.bc.ui.wizards.FiniteStateWizard;
-
 import org.yocto.bc.ui.wizards.newproject.BBConfigurationInitializeOperation;
 import org.yocto.bc.ui.wizards.newproject.CreateBBCProjectOperation;
 
@@ -68,7 +67,7 @@ public class ImportYoctoProjectWizard extends FiniteStateWizard  implements IImp
 	public boolean performFinish() {
 		ProjectInfo pinfo = new ProjectInfo();
 		pinfo.setInitScriptPath((String) projectModel.get(ImportYoctoProjectWizard.KEY_INITPATH));
-		pinfo.setLocation((String) projectModel.get(ImportYoctoProjectWizard.KEY_LOCATION));
+		pinfo.setLocationURI((URI) projectModel.get(ImportYoctoProjectWizard.KEY_LOCATION));
 		pinfo.setName((String) projectModel.get(ImportYoctoProjectWizard.KEY_NAME));
 		
 		try {
@@ -87,7 +86,7 @@ public class ImportYoctoProjectWizard extends FiniteStateWizard  implements IImp
 		projectModel.put(ImportYoctoProjectWizard.KEY_PINFO, pinfo);
 		//setPageComplete(valid);
 		//ProjectInfo pinfo = (ProjectInfo) projectModel.get(KEY_PINFO);
-		Activator.putProjInfo(pinfo.getRootPath(), pinfo);
+		Activator.putProjInfo(pinfo.getOEFSURI(), pinfo);
 		try {
 			getContainer().run(false, false, new CreateBBCProjectOperation(pinfo));
 		} catch (Exception e) {
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java
index 3130cbf..f9174e2 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java
@@ -6,6 +6,7 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.Writer;
 import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -142,6 +143,10 @@ public class InstallWizard extends FiniteStateWizard implements
 		}
 
 		try {
+			URI uri = new URI("");
+			if (options.containsKey(INSTALL_DIRECTORY)) {
+				uri = (URI) options.get(INSTALL_DIRECTORY);
+			}
 			if (((Boolean)options.get(GIT_CLONE)).booleanValue()) {
 				String []git_clone_cmd = {"git", "clone", "--progress", "git://git.pokylinux.org/poky.git", install_dir};
 				final Pattern pattern = Pattern.compile("^Receiving objects:\\s*(\\d+)%.*");
@@ -171,7 +176,7 @@ public class InstallWizard extends FiniteStateWizard implements
 				String prjName = (String) options.get(PROJECT_NAME);
 				ProjectInfo pinfo = new ProjectInfo();
 				pinfo.setInitScriptPath(initPath);
-				pinfo.setLocation(install_dir);
+				pinfo.setLocationURI(uri);
 				pinfo.setName(prjName);
 			
 				ConsoleWriter cw = new ConsoleWriter();
@@ -181,7 +186,7 @@ public class InstallWizard extends FiniteStateWizard implements
 				myConsole.newMessageStream().println(cw.getContents());
 
 				model.put(InstallWizard.KEY_PINFO, pinfo);
-				Activator.putProjInfo(pinfo.getRootPath(), pinfo);
+				Activator.putProjInfo(pinfo.getOEFSURI(), pinfo);
 
 				this.getContainer().run(false, false,
 						new CreateBBCProjectOperation(pinfo));
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
index 64c3e6e..20c001a 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
@@ -39,7 +39,7 @@ public class BBConfigurationInitializeOperation implements IRunnableWithProgress
 	public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
 		BBSession session;
 		try {
-			session = Activator.getBBSession(pinfo.getRootPath(), writer);
+			session = Activator.getBBSession(pinfo, writer, monitor);
 			session.initialize();
 
 		} catch (Exception e) {
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
index 1d54ea3..41efdb0 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
@@ -65,15 +65,10 @@ public class CreateBBCProjectOperation extends WorkspaceModifyOperation {
 		addNatureToProject(proj, BitbakeCommanderNature.NATURE_ID, monitor);
 	}
 
-	private IProjectDescription createProjectDescription(IWorkspace workspace, ProjectInfo projInfo2) throws CoreException {
-		IProjectDescription desc = workspace.newProjectDescription(projInfo2.getProjectName());
-		
-		try {
-			desc.setLocationURI(new URI(OEFS_SCHEME + projInfo2.getRootPath()));
-		} catch (URISyntaxException e) {
-			throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to load filesystem.", e));
-		}
-		
+	private IProjectDescription createProjectDescription(IWorkspace workspace, ProjectInfo projInfo) throws CoreException {
+		IProjectDescription desc = workspace.newProjectDescription(projInfo.getProjectName());
+
+		desc.setLocationURI(projInfo.getOEFSURI());
 		return desc;
 	}
 
@@ -85,6 +80,7 @@ public class CreateBBCProjectOperation extends WorkspaceModifyOperation {
 
 		IProject proj = wsroot.getProject(projInfo.getProjectName());
 		proj.create(desc, monitor);
+
 		proj.open(monitor);
 
 		addNatures(proj, monitor);
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Refactor RFC 9/9] Redirect bitbake environment parsing to file & parse
  2013-06-04 13:25 [Refactor RFC 0/9] Merging of windows-build with master Ioana Grigoropol
                   ` (7 preceding siblings ...)
  2013-06-04 13:26 ` [Refactor RFC 8/9] Use URI for storing project locations Ioana Grigoropol
@ 2013-06-04 13:26 ` Ioana Grigoropol
  2013-06-07  0:27   ` Zhang, Jessica
  2013-06-07  0:29 ` [Refactor RFC 0/9] Merging of windows-build with master Zhang, Jessica
  9 siblings, 1 reply; 20+ messages in thread
From: Ioana Grigoropol @ 2013-06-04 13:26 UTC (permalink / raw)
  To: yocto

- when running "bitbake -e" the output is sent to the console, poluting it
- instead, send the output to a file (bitbake.env) and parse the file accordingly
- if an error has occured while running the commad, all the error lines are collected and displayed on the console

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../src/org/yocto/bc/bitbake/BBRecipe.java         |    2 +-
 .../src/org/yocto/bc/bitbake/BBSession.java        |   49 +++++++++++++-------
 .../src/org/yocto/bc/bitbake/ShellSession.java     |   14 +++---
 3 files changed, 40 insertions(+), 25 deletions(-)

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
index 1baf124..6168f8c 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
@@ -26,7 +26,7 @@ public class BBRecipe extends BBSession {
 		super(session.shell, session.pinfo.getOriginalURI());
 		this.session = session;
 		this.fileURI = filePath;
-		this.parsingCmd = "DISABLE_SANITY_CHECKS=1 bitbake -e -b " + filePath;
+		this.parsingCmd = "DISABLE_SANITY_CHECKS=\"1\" bitbake -e -b " + filePath.getPath() + " >& " + BB_ENV_FILE;
 	}
 	
 	@Override
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
index fcde557..9bc4dcc 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
@@ -15,6 +15,8 @@ import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
 import java.io.StringReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -33,9 +35,11 @@ import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.preference.JFacePreferences;
 import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.rse.core.model.IHost;
 import org.eclipse.ui.console.ConsolePlugin;
 import org.eclipse.ui.console.IConsole;
 import org.eclipse.ui.console.IConsoleManager;
@@ -45,6 +49,7 @@ import org.eclipse.ui.progress.WorkbenchJob;
 
 import org.yocto.bc.ui.model.IModelElement;
 import org.yocto.bc.ui.model.ProjectInfo;
+import org.yocto.remote.utils.RemoteHelper;
 
 /**
  * BBSession encapsulates a global bitbake configuration and is the primary interface
@@ -59,6 +64,7 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 	public static final int TYPE_STATEMENT = 3;
 	public static final int TYPE_FLAG = 4;
 	
+	public static final String BB_ENV_FILE = "bitbake.env";
 	public static final String BUILDDIR_INDICATORS [] = {
 		File.separatorChar + "conf" + File.separatorChar + "local.conf",
 		File.separatorChar + "conf" + File.separatorChar + "bblayers.conf",
@@ -69,19 +75,21 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 	protected Map<?,?> properties = null;
 	protected List <URI> depends = null;
 	protected boolean initialized = false;
+	protected boolean errorOccured = false;
 	protected MessageConsole sessionConsole;
 	private final ReentrantReadWriteLock rwlock = new ReentrantReadWriteLock();
 	private final Lock rlock = rwlock.readLock();
 	private final Lock wlock = rwlock.writeLock();
 	protected String parsingCmd;
 	private boolean silent = false;
-	
+	private String errorLines = "";
+
 	public BBSession(ShellSession ssession, URI projectRoot) throws IOException {
 		shell = ssession;
 		this.pinfo = new ProjectInfo();
 		pinfo.setLocationURI(projectRoot);
 		pinfo.setInitScriptPath(ProjectInfoHelper.getInitScriptPath(projectRoot));
-		this.parsingCmd = "DISABLE_SANITY_CHECKS=1 bitbake -e";
+		this.parsingCmd = "DISABLE_SANITY_CHECKS=\"1\" bitbake -e >& " + BB_ENV_FILE;
 	}
 
 	public BBSession(ShellSession ssession, URI projectRoot, boolean silent) throws IOException {
@@ -330,18 +338,17 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 		}
 	}
 
-	protected int checkExecuteError(String result, int code) {
+	protected void checkExecuteError(String result, boolean hasErrors) {
 		URI recipeURI = getDefaultDepends();
 		String text = "Parsing " + ((recipeURI != null) ? ("recipe " + recipeURI) : "base configurations");
-		if (code != 0) {
+		if (hasErrors) {
 			text = text + " ERROR!\n" + result;
 		}else {
 				text = text + " SUCCESS.\n";
 		}
 		if(!silent) {
-			displayInConsole(text, code, false);
+			displayInConsole(text, -1, false);
 		}
-		return code;
 	}
 
 	protected void displayInConsole(final String result, final int code, boolean clear) {
@@ -378,14 +385,21 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 			}
 			try {
 				if(!initialized) { //recheck
-					int [] codes = {-1};
-					String result = shell.execute(parsingCmd, codes);
-					if(checkExecuteError(result, codes[0]) == 0) {
-						properties = parseBBEnvironment(result);
+					boolean hasErrors = false;
+					String result = shell.execute(parsingCmd, hasErrors);
+
+					//FIXME : wait for bitbake to finish
+					properties = parseBBEnvironment(result);
+
+					if (properties.size() == 0) { // there was an error in sourcing bitbake environment
+						shell.printError(errorLines);
+						errorOccured = true;
 					} else {
-						properties = parseBBEnvironment("");
+						errorLines = "";
+						errorOccured = false;
+						initialized = true;
 					}
-					initialized = true;
+					//FIXME: cleanup BB env file
 				}
 			} finally {
 				//downgrade lock
@@ -440,8 +454,11 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 		}
 	}
 
-	protected void parse(String content, Map outMap) throws Exception {
-		BufferedReader reader = new BufferedReader(new StringReader(content));
+	protected void parse(String bbOutfilePath, Map outMap) throws Exception {
+		IHost connection = shell.getProjectInfo().getConnection();
+		InputStream is = RemoteHelper.getRemoteInputStream(connection, bbOutfilePath, BB_ENV_FILE, new NullProgressMonitor());
+		RemoteHelper.getRemoteHostFile(connection, bbOutfilePath + BB_ENV_FILE, new NullProgressMonitor());
+		BufferedReader reader = new BufferedReader(new InputStreamReader(is));
 		String line;
 		boolean inLine = false;
 		StringBuffer sb = null;
@@ -508,11 +525,11 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
 		return null;
 	}
 	
-	protected Map parseBBEnvironment(String bbOut) throws Exception {
+	protected Map parseBBEnvironment(String bbOutFilePath) throws Exception {
 		Map env = new Hashtable();
 		this.depends = new ArrayList<URI>();
 
-		parse(bbOut, env);
+		parse(bbOutFilePath, env);
 
 		String included = (String) env.get("BBINCLUDED");
 		if(getDefaultDepends() != null) {
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
index 44b2696..129d1d9 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
@@ -21,6 +21,7 @@ import java.io.Writer;
 import org.eclipse.rse.services.files.IHostFile;
 import org.yocto.bc.ui.model.ProjectInfo;
 import org.yocto.remote.utils.ICommandResponseHandler;
+import org.yocto.remote.utils.RemoteHelper;
 
 /**
  * A class for Linux shell sessions.
@@ -112,11 +113,11 @@ public class ShellSession {
 
 	synchronized 
 	public String execute(String command) throws IOException {
-		return execute(command, (int [])null);
+		return execute(command, false);
 	}
 
 	synchronized 
-	public String execute(String command, int[] retCode) throws IOException {
+	public String execute(String command, boolean hasErrors) throws IOException {
 		String errorMessage = null;
 		interrupt = false;
 		out.write(command);
@@ -150,12 +151,6 @@ public class ShellSession {
 			process.destroy();
 			initializeShell();
 			interrupt = false;
-		}else if (line != null && retCode != null) {
-			try {
-				retCode[0]=Integer.parseInt(line.substring(0,line.lastIndexOf(TERMINATOR)));
-			}catch (NumberFormatException e) {
-				throw new IOException("Can NOT get return code" + command + LT + line);
-			}
 		}
 		
 		if (errorMessage != null) {
@@ -259,4 +254,7 @@ synchronized
 		}
 		
 	}
+	public void printError(String errorLines) {
+		RemoteHelper.getCommandHandler(projectInfo.getConnection()).response(errorLines, true);
+	}
 }
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities
  2013-06-04 13:26 ` [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities Ioana Grigoropol
@ 2013-06-06 23:53   ` Zhang, Jessica
  2013-06-07 15:29     ` Grigoropol, IoanaX
  0 siblings, 1 reply; 20+ messages in thread
From: Zhang, Jessica @ 2013-06-06 23:53 UTC (permalink / raw)
  To: Grigoropol, IoanaX, yocto

Hi Ioana,

Please separate this into 2 patches, one is for adding those new util files and also please add License for them.  Then make the RemoteHelper.java into a separate patch.  Other comments are:

1.please add much more detailed information in your patch to explain why we need new util classes and why RemoteHelper.java need to be changed.
2. there're many new functions that using IHost variable and you don't need to check for IHost is null case?

Thanks
Jessica

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: yocto@yoctoproject.org
Subject: [yocto] [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../org.yocto.remote.utils/META-INF/MANIFEST.MF    |    8 +-
 .../yocto/remote/utils/CommandOutputProcessor.java |   33 +++
 .../yocto/remote/utils/CommandResponseHandler.java |   36 +++
 .../org/yocto/remote/utils/CommandRunnable.java    |   34 +++
 .../src/org/yocto/remote/utils/ConsoleHelper.java  |   28 +++
 .../org/yocto/remote/utils/ConsoleRunnable.java    |   37 +++
 .../remote/utils/ICommandResponseHandler.java      |   15 ++
 .../org/yocto/remote/utils/OutputProcessor.java    |  102 ++++++++
 .../yocto/remote/utils/ProcessStreamBuffer.java    |   77 ++++++
 .../src/org/yocto/remote/utils/RemoteHelper.java   |  255 ++++++++++++++++----
 .../src/org/yocto/remote/utils/RemoteMachine.java  |  206 ++++++++++++++++
 .../src/org/yocto/remote/utils/Session.java        |  117 +++++++++
 .../src/org/yocto/remote/utils/YoctoCommand.java   |   53 ++++
 13 files changed, 952 insertions(+), 49 deletions(-)  create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java

diff --git a/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF b/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF
index c7b57fe..06d14f8 100644
--- a/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF
+++ b/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF
@@ -11,17 +11,23 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Import-Package: org.eclipse.rse.core,
  org.eclipse.rse.core.model,
  org.eclipse.rse.core.subsystems,
+ org.eclipse.rse.internal.services.local.shells,
+ org.eclipse.rse.internal.services.shells,
  org.eclipse.rse.internal.terminals.ui,
  org.eclipse.rse.internal.terminals.ui.views,
  org.eclipse.rse.services,
+ org.eclipse.rse.services.clientserver.messages,
  org.eclipse.rse.services.files,
  org.eclipse.rse.services.shells,
  org.eclipse.rse.services.terminals,
+ org.eclipse.rse.subsystems.files.core.model,
  org.eclipse.rse.subsystems.files.core.servicesubsystem,
+ org.eclipse.rse.subsystems.files.core.subsystems,
  org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem,
  org.eclipse.rse.subsystems.terminals.core,
  org.eclipse.rse.subsystems.terminals.core.elements,
  org.eclipse.rse.ui,
  org.eclipse.tm.internal.terminal.control,
- org.eclipse.tm.internal.terminal.provisional.api
+ org.eclipse.tm.internal.terminal.provisional.api,
+ org.eclipse.ui.console
 Export-Package: org.yocto.remote.utils
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java
new file mode 100644
index 0000000..4fca662
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandO
+++ utputProcessor.java
@@ -0,0 +1,33 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.services.shells.IHostShell;
+
+public class CommandOutputProcessor extends OutputProcessor {
+
+       public CommandOutputProcessor(IProgressMonitor monitor,
+                       IHostShell hostShell, CommandResponseHandler cmdHandler, String task) {
+               super(monitor, hostShell, cmdHandler, task);
+       }
+
+       @Override
+       protected boolean isErrChStop(char ch) {
+               return (ch == '\n');
+       }
+
+       @Override
+       protected boolean isOutChStop(char ch) {
+               return (ch == '\n');
+       }
+
+       @Override
+       protected void processOutputBufferLine(char ch, String str) {
+               processBuffer.addOutputLine(str);
+       }
+
+       @Override
+       protected void processErrorBufferLine(char ch, String str) {
+               processBuffer.addErrorLine(str);
+       }
+
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java
new file mode 100644
index 0000000..0785c45
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandR
+++ esponseHandler.java
@@ -0,0 +1,36 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
+
+public class CommandResponseHandler implements ICommandResponseHandler {
+       private MessageConsoleStream consoleStream;
+       private Boolean errorOccured = false;
+
+       public CommandResponseHandler(MessageConsole console) {
+               try {
+                       this.consoleStream = console.newMessageStream();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public Boolean hasError() {
+               return errorOccured;
+       }
+
+       @Override
+       public void response(String line, boolean isError) {
+               try {
+                       if (isError) {
+                               consoleStream.println(line);
+                               errorOccured = true;
+                       } else {
+                               consoleStream.println(line);
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+}
\ No newline at end of file
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java
new file mode 100644
index 0000000..46a3f35
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandR
+++ unnable.java
@@ -0,0 +1,34 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.core.model.IHost; import
+org.eclipse.rse.services.shells.IHostShell;
+
+public class CommandRunnable implements Runnable{
+       private IHostShell hostShell;
+       private final IHost connection;
+       private final YoctoCommand cmd;
+       private final IProgressMonitor monitor;
+       private final CommandResponseHandler cmdHandler;
+
+       CommandRunnable(IHost connection, YoctoCommand cmd, IProgressMonitor monitor){
+               this.connection = connection;
+               this.cmdHandler = RemoteHelper.getCommandHandler(connection);
+               this.cmd = cmd;
+               this.monitor = monitor;
+               this.hostShell = null;
+       }
+       @Override
+       public void run() {
+               try {
+                       hostShell = RemoteHelper.runCommandRemote(connection, cmd, monitor);
+                       cmd.setProcessBuffer(RemoteHelper.processOutput(monitor, hostShell, cmdHandler));
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java
new file mode 100644
index 0000000..307e219
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleH
+++ elper.java
@@ -0,0 +1,28 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.swt.widgets.Display; import
+org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole; import
+org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.MessageConsole;
+
+public class ConsoleHelper {
+       public static final String YOCTO_CONSOLE = "Yocto Project Console";
+
+       public static MessageConsole findConsole(String name) {
+               ConsolePlugin plugin = ConsolePlugin.getDefault();
+               IConsoleManager conMan = plugin.getConsoleManager();
+               IConsole[] existing = conMan.getConsoles();
+               for (int i = 0; i < existing.length; i++)
+                       if (name.equals(existing[i].getName()))
+                               return (MessageConsole) existing[i];
+               // no console found, so create a new one
+               MessageConsole myConsole = new MessageConsole(name, null);
+               conMan.addConsoles(new IConsole[] { myConsole });
+               return myConsole;
+       }
+
+       public static void showConsole(MessageConsole console){
+               Display.getDefault().syncExec(new ConsoleRunnable(console));
+       }
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java
new file mode 100644
index 0000000..f3b0ccd
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleR
+++ unnable.java
@@ -0,0 +1,37 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow; import
+org.eclipse.ui.PlatformUI; import
+org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleView;
+import org.eclipse.ui.console.MessageConsole;
+
+public class ConsoleRunnable implements Runnable{
+       MessageConsole console;
+       ConsoleRunnable (MessageConsole console){
+               this.console = console;
+       }
+       @Override
+       public void run() {
+               IWorkbench wb = PlatformUI.getWorkbench();
+               if (wb == null)
+                       return;
+               IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
+               if (win == null)
+                       return;
+               IWorkbenchPage page = win.getActivePage();
+               if (page == null)
+                       return;
+               String id = IConsoleConstants.ID_CONSOLE_VIEW;
+               try {
+                       IConsoleView view = (IConsoleView) page.showView(id);
+                       if (view == null)
+                               return;
+                       view.display(console);
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+}
\ No newline at end of file
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java
new file mode 100644
index 0000000..a8a8f95
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommand
+++ ResponseHandler.java
@@ -0,0 +1,15 @@
+/**********************************************************************
+*******
+ * Copyright (c) 2009 Ken Gilmer
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License
+v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Ken Gilmer - initial API and implementation
+
+***********************************************************************
+********/
+package org.yocto.remote.utils;
+
+public interface ICommandResponseHandler {
+       public void response(String line, boolean isError); }
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java
new file mode 100644
index 0000000..a06f077
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputPr
+++ ocessor.java
@@ -0,0 +1,102 @@
+package org.yocto.remote.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.concurrent.locks.Lock;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.internal.services.local.shells.LocalHostShell;
+import
+org.eclipse.rse.internal.services.shells.TerminalServiceHostShell;
+import org.eclipse.rse.services.shells.HostShellProcessAdapter;
+import org.eclipse.rse.services.shells.IHostShell;
+
+public abstract class OutputProcessor{
+       private static final int ERROR_BUFFER = 1;
+       private static final int OUTPUT_BUFFER = 2;
+       protected String task;
+       protected ProcessStreamBuffer processBuffer;
+       protected IHostShell hostShell;
+       protected CommandResponseHandler cmdHandler;
+       protected IProgressMonitor monitor;
+
+       public OutputProcessor(IProgressMonitor monitor, IHostShell hostShell, CommandResponseHandler cmdHandler, String task){
+               this.monitor = monitor;
+               this.hostShell = hostShell;
+               this.processBuffer = new ProcessStreamBuffer(hostShell instanceof TerminalServiceHostShell);
+               this.cmdHandler = cmdHandler;
+               this.task = task;
+       }
+       public ProcessStreamBuffer processOutput() throws Exception{
+               if (hostShell == null)
+                       throw new Exception("An error has occured while trying to run remote command!");
+               monitor.beginTask(this.task, RemoteHelper.TOTALWORKLOAD);
+               Lock lock = null;
+               if (hostShell instanceof LocalHostShell) {
+                       lock = ((LocalHostShell)hostShell).getLock();
+                       lock.lock();
+               }
+               BufferedReader inbr = null;
+               BufferedReader errbr = null;
+
+               if (hostShell instanceof LocalHostShell) {
+                       inbr = ((LocalHostShell)hostShell).getReader(false);
+                       errbr = ((LocalHostShell)hostShell).getReader(true);
+               } else {
+                       Process p = new HostShellProcessAdapter(hostShell);
+                       inbr = new BufferedReader(new InputStreamReader(p.getInputStream()));
+                       errbr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+               }
+               boolean cancel = false;
+               while (!cancel) {
+                       if(monitor.isCanceled()) {
+                               cancel = true;
+                               if (lock != null)
+                                       lock.unlock();
+                               throw new InterruptedException("User Cancelled");
+                       }
+                       processBuffer(errbr, ERROR_BUFFER);
+                       processBuffer(inbr, OUTPUT_BUFFER);
+                       cancel = true;
+               }
+               if (lock != null)
+                       lock.unlock();
+               return processBuffer;
+       }
+       protected abstract boolean isErrChStop(char ch);
+       protected abstract boolean isOutChStop(char ch);
+       protected boolean isChStop(char ch, int type){
+               if (type == ERROR_BUFFER)
+                       return isErrChStop(ch);
+               else if(type == OUTPUT_BUFFER)
+                       return isOutChStop(ch);
+               return false;
+       }
+       protected abstract void processOutputBufferLine(char ch, String str);
+       protected abstract void processErrorBufferLine(char ch, String str);
+       protected void processBufferLine(String str, char ch, int type){
+               if (type == ERROR_BUFFER)
+                       processErrorBufferLine(ch, str);
+               else if(type == OUTPUT_BUFFER)
+                       processOutputBufferLine(ch, str);
+       }
+       protected void processBuffer(BufferedReader br, int type) throws IOException{
+               StringBuffer buffer = new StringBuffer();
+               int c;
+               if (br != null)
+               while ((c = br.read()) != -1) {
+                       char ch = (char) c;
+                       buffer.append(ch);
+                       if (isChStop(ch, type)){
+                               String str = buffer.toString();
+                               processBufferLine(str, ch, type);
+                               System.out.println(str);
+                               if (str.trim().equals(RemoteHelper.TERMINATOR)) {
+                                       break;
+                               }
+                               cmdHandler.response(str, false);
+                               buffer.delete(0, buffer.length());
+                       }
+               }
+       }
+}
\ No newline at end of file
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java
new file mode 100644
index 0000000..3fe8731
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessS
+++ treamBuffer.java
@@ -0,0 +1,77 @@
+package org.yocto.remote.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class ProcessStreamBuffer {
+       private static final String WHITESPACES = "\\s+";
+       List<String> errorLines;
+       List<String> outputLines;
+       boolean isTerminal;
+
+       ProcessStreamBuffer(boolean isTerminal){
+               this.isTerminal = isTerminal;
+               errorLines = new ArrayList<String>();
+               outputLines = new ArrayList<String>();
+       }
+
+       public void addErrorLine(String line){
+               errorLines.add(line);
+       }
+       public void addOutputLine(String line){
+               outputLines.add(line);
+       }
+
+       public List<String> getOutputLines(){
+               return outputLines;
+       }
+
+       public List<String> getErrorLines(){
+               return errorLines;
+       }
+
+       public String getMergedOutputLines(){
+               String returnVal = "";
+               for (int i = 0; i < outputLines.size(); i++) {
+                       String line = outputLines.get(i);
+                       returnVal += line;
+                       if (outputLines.size() > 1 && i != outputLines.size() - 1)
+                               returnVal += "\n";
+               }
+               return returnVal;
+       }
+
+       public boolean hasErrors() {
+               return errorLines.size() != 0;
+       }
+
+       public String getLastOutputLineContaining(String str) {
+               if (!errorLines.isEmpty())
+                       return null;
+               for (int i = outputLines.size() - 1; i >= 0; i--){
+                       String line = outputLines.get(i);
+                       if (line.replaceAll(WHITESPACES, "").contains(str.replaceAll(WHITESPACES, "")))
+                               return line;
+               }
+               return null;
+       }
+
+       public String getOutputLineContaining(String arg, String pattern) {
+               List<String> lines = null;
+               if (isTerminal)
+                       lines = errorLines;
+               else
+                       lines = outputLines;
+               for (int i = lines.size() - 1; i >= 0; i--){
+                       String line = lines.get(i);
+                       if (line.contains(arg)) {
+                               String[] tokens = line.split("\\s+");
+                               if (Pattern.matches(pattern,  tokens[0])) {
+                                       return tokens[0];
+                               }
+                       }
+               }
+               return "";
+       }
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java
index a1e9a08..e9118d6 100644
--- a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHe
+++ lper.java
@@ -16,16 +16,19 @@ import java.io.BufferedOutputStream;  import java.io.File;  import java.io.FileOutputStream;  import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;

 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;  import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;  import org.eclipse.core.runtime.SubProgressMonitor;
@@ -38,17 +41,26 @@ import org.eclipse.rse.core.model.ISubSystemConfigurationCategories;
 import org.eclipse.rse.core.model.ISystemRegistry;
 import org.eclipse.rse.core.subsystems.ISubSystem;
 import org.eclipse.rse.services.IService;
+import
+org.eclipse.rse.services.clientserver.messages.SystemMessageException;
 import org.eclipse.rse.services.files.IFileService;
+import org.eclipse.rse.services.files.IHostFile;
 import org.eclipse.rse.services.shells.HostShellProcessAdapter;
 import org.eclipse.rse.services.shells.IHostShell;
 import org.eclipse.rse.services.shells.IShellService;
+import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
+import
+org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSy
+stem;
 import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+import
+org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
 import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem;
 import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem;
+import org.eclipse.ui.console.MessageConsole;

 public class RemoteHelper {
        private final static String EXIT_CMD = "exit"; //$NON-NLS-1$
        private final static String CMD_DELIMITER = ";"; //$NON-NLS-1$
+       public static final String TERMINATOR = "234o987dsfkcqiuwey18837032843259d";//$NON-NLS-1$
+       public static final int TOTALWORKLOAD = 100;
+       private static Map<IHost, RemoteMachine> machines;

        public static IHost getRemoteConnectionByName(String remoteConnection) {
                if (remoteConnection == null)
@@ -57,30 +69,7 @@ public class RemoteHelper {
                for (int i = 0; i < connections.length; i++)
                        if (connections[i].getAliasName().equals(remoteConnection))
                                return connections[i];
-               return null; // TODO Connection is not found in the list--need to react
-               // somehow, throw the exception?
-
-       }
-
-       public static IService getConnectedRemoteFileService(
-                       IHost currentConnection, IProgressMonitor monitor) throws Exception {
-               final ISubSystem subsystem = getFileSubsystem(currentConnection);
-
-               if (subsystem == null)
-                       throw new Exception(Messages.ErrorNoSubsystem);
-
-               try {
-                       subsystem.connect(monitor, false);
-               } catch (CoreException e) {
-                       throw e;
-               } catch (OperationCanceledException e) {
-                       throw new CoreException(Status.CANCEL_STATUS);
-               }
-
-               if (!subsystem.isConnected())
-                       throw new Exception(Messages.ErrorConnectSubsystem);
-
-               return ((IFileServiceSubSystem) subsystem).getFileService();
+               return null;
        }

        public static ISubSystem getFileSubsystem(IHost host) { @@ -94,27 +83,6 @@ public class RemoteHelper {
                return null;
        }

-       public static IService getConnectedShellService(
-                       IHost currentConnection, IProgressMonitor monitor) throws Exception {
-               final ISubSystem subsystem = getShellSubsystem(currentConnection);
-
-               if (subsystem == null)
-                       throw new Exception(Messages.ErrorNoSubsystem);
-
-               try {
-                       subsystem.connect(monitor, false);
-               } catch (CoreException e) {
-                       throw e;
-               } catch (OperationCanceledException e) {
-                       throw new CoreException(Status.CANCEL_STATUS);
-               }
-
-               if (!subsystem.isConnected())
-                       throw new Exception(Messages.ErrorConnectSubsystem);
-
-               return ((IShellServiceSubSystem) subsystem).getShellService();
-       }
-
        public static ISubSystem getShellSubsystem(IHost host) {
                if (host == null)
                        return null;
@@ -161,7 +129,7 @@ public class RemoteHelper {

                IFileService fileService;
                try {
-                       fileService = (IFileService) getConnectedRemoteFileService(
+                       fileService = getConnectedRemoteFileService(
                                                        connection,
                                                        new SubProgressMonitor(monitor, 5));
                        InputStream  inputStream = FileLocator.openStream( @@ -204,7 +172,7 @@ public class RemoteHelper {

                IFileService fileService;
                try {
-                       fileService = (IFileService) getConnectedRemoteFileService(
+                       fileService = getConnectedRemoteFileService(
                                                        connection,
                                                        new SubProgressMonitor(monitor, 10));
                        File file = new File(localExePath);
@@ -341,4 +309,195 @@ public class RemoteHelper {
                                return;
                        }
        }
+       public static RemoteMachine getRemoteMachine(IHost connection){
+               if (!getMachines().containsKey(connection))
+                       getMachines().put(connection, new RemoteMachine(connection));
+               return getMachines().get(connection);
+       }
+
+       private static Map<IHost, RemoteMachine> getMachines() {
+               if (machines == null)
+                       machines = new HashMap<IHost, RemoteMachine>();
+               return machines;
+       }
+
+       public static MessageConsole getConsole(IHost connection) {
+               return getRemoteMachine(connection).getConsole();
+       }
+
+       public static CommandResponseHandler getCommandHandler(IHost connection) {
+               return getRemoteMachine(connection).getCmdHandler();
+       }
+
+       public static ProcessStreamBuffer processOutput(IProgressMonitor monitor, IHostShell hostShell, CommandResponseHandler cmdHandler) throws Exception {
+               return new CommandOutputProcessor(monitor, hostShell, cmdHandler, "").processOutput();
+       }
+
+       public static IHost getRemoteConnectionForURI(URI uri, IProgressMonitor monitor) {
+               if (uri == null)
+                       return null;
+
+               String host = uri.getHost();
+               if (host == null) {
+                       // this is a local connection
+                       ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
+                       IHost local = null;
+                       while (local == null) {
+                               local = sr.getLocalHost();
+                       }
+                       return local;
+               }
+               ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
+               IHost[] connections = sr.getHosts();
+
+               IHost unconnected = null;
+               for (IHost conn : connections) {
+                       if (host.equalsIgnoreCase(conn.getHostName())) {
+                               IRemoteFileSubSystem fss = getRemoteFileSubSystem(conn);
+                               if (fss != null && fss.isConnected())
+                                       return conn;
+                               unconnected = conn;
+                       }
+               }
+
+               return unconnected;
+       }
+
+       public static IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) {
+               IRemoteFileSubSystem candidate = null;
+               IRemoteFileSubSystem otherServiceCandidate = null;
+               IRemoteFileSubSystem[] subSystems =
+RemoteFileUtility.getFileSubSystems(host);
+
+               for (IRemoteFileSubSystem subSystem : subSystems) {
+                       if (subSystem instanceof FileServiceSubSystem) {
+                               if (subSystem.isConnected())
+                                       return subSystem;
+
+                               if (otherServiceCandidate == null)
+                                       otherServiceCandidate = subSystem;
+
+                       } else if (candidate == null || (subSystem.isConnected() && !candidate.isConnected()))
+                               candidate = subSystem;
+
+               }
+               if (candidate != null && candidate.isConnected())
+                       return candidate;
+               if (otherServiceCandidate != null)
+                       return otherServiceCandidate;
+               return null;
+       }
+
+       public static IFileService getConnectedRemoteFileService(IHost connection, IProgressMonitor monitor) throws Exception {
+               return getRemoteMachine(connection).getRemoteFileService(monitor);
+       }
+
+       public static IHostFile[] getRemoteDirContent(IHost connection, String
+remoteParent, String fileFilter, int fileType, IProgressMonitor
+monitor){
+
+               try {
+                       IFileService fileServ = getConnectedRemoteFileService(connection, monitor);
+                       return fileServ.list(remoteParent, fileFilter, fileType, monitor);
+               } catch (SystemMessageException e) {
+                       e.printStackTrace();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               return null;
+       }
+
+       public static IService getConnectedShellService(IHost connection, IProgressMonitor monitor) throws Exception {
+               return getRemoteMachine(connection).getShellService(monitor);
+       }
+
+       public static void handleRunCommandRemote(IHost connection, YoctoCommand cmd, IProgressMonitor monitor){
+               try {
+                       CommandRunnable cmdRun = new CommandRunnable(connection, cmd, monitor);
+                       cmdRun.run();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public static IHostShell runCommandRemote(IHost connection, YoctoCommand cmd,
+                       IProgressMonitor monitor) throws CoreException {
+
+               monitor.beginTask(NLS.bind(Messages.RemoteShellExec_1,
+                               cmd, cmd.getArguments()), 10);
+
+               String remoteCommand = cmd.getCommand() + " " + cmd.getArguments() +
+" ; echo " + TERMINATOR + "; exit ;";
+
+               IShellService shellService;
+               try {
+                       shellService = (IShellService) getConnectedShellService(connection,
+new SubProgressMonitor(monitor, 7));
+
+                       String env[] =
+getRemoteMachine(connection).prepareEnvString(monitor);
+
+                       try {
+                               IHostShell hostShell = shellService.runCommand(cmd.getInitialDirectory(), remoteCommand, env, new SubProgressMonitor(monitor, 3));
+                               return hostShell;
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       }
+               } catch (Exception e1) {
+                       e1.printStackTrace();
+               }
+               return null;
+       }
+
+       public static IHostFile getRemoteHostFile(IHost connection, String remoteFilePath, IProgressMonitor monitor){
+               assert(connection != null);
+               monitor.beginTask(Messages.InfoDownload, 100);
+
+               try {
+                       IFileService fileService = getConnectedRemoteFileService(connection, new SubProgressMonitor(monitor, 10));
+                       Path remotePath = new Path(remoteFilePath);
+                       IHostFile remoteFile = fileService.getFile(remotePath.removeLastSegments(1).toString(), remotePath.lastSegment(), new SubProgressMonitor(monitor, 5));
+                       return remoteFile;
+               } catch (Exception e) {
+                       e.printStackTrace();
+           }finally {
+                       monitor.done();
+               }
+               return null;
+       }
+
+       public static InputStream getRemoteInputStream(IHost connection, String parentPath, String remoteFilePath, IProgressMonitor monitor){
+               assert(connection != null);
+               monitor.beginTask(Messages.InfoDownload, 100);
+
+               try {
+                       IFileService fileService = getConnectedRemoteFileService(connection,
+new SubProgressMonitor(monitor, 10));
+
+                       return fileService.getInputStream(parentPath, remoteFilePath, false, monitor);
+               } catch (Exception e) {
+                       e.printStackTrace();
+           }finally {
+                       monitor.done();
+               }
+               return null;
+       }
+
+       public static URI createNewURI(URI oldURI, String name) {
+               try {
+                       String sep = oldURI.getPath().endsWith("/") ? "" : "/";
+                       return new URI(oldURI.getScheme(), oldURI.getHost(), oldURI.getPath() + sep + name, oldURI.getFragment());
+               } catch (URISyntaxException e) {
+                       e.printStackTrace();
+                       return null;
+               }
+       }
+
+       public static boolean fileExistsRemote(IHost conn, IProgressMonitor monitor, String path) {
+               try {
+                       IFileService fs = getConnectedRemoteFileService(conn, monitor);
+                       int nameStart = path.lastIndexOf("/");
+                       String parentPath = path.substring(0, nameStart);
+                       String name = path.substring(nameStart + 1);
+                       IHostFile hostFile = fs.getFile(parentPath, name, monitor);
+
+                       return hostFile.exists();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               return false;
+       }
 }
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java
new file mode 100644
index 0000000..123a972
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMa
+++ chine.java
@@ -0,0 +1,206 @@
+package org.yocto.remote.utils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status; import
+org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.rse.core.model.IHost; import
+org.eclipse.rse.core.subsystems.ISubSystem;
+import
+org.eclipse.rse.internal.services.local.shells.LocalShellService;
+import
+org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.rse.services.files.IFileService;
+import org.eclipse.rse.services.shells.IHostShell;
+import org.eclipse.rse.services.shells.IShellService;
+import
+org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubS
+ystem; import
+org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShe
+llServiceSubSystem; import org.eclipse.ui.console.MessageConsole;
+
+public class RemoteMachine {
+       public static final String PROXY = "proxy";
+
+       private Map<String, String> environment;
+       private MessageConsole console;
+       private CommandResponseHandler cmdHandler;
+       private IHostShell hostShell;
+       private IShellService shellService;
+       private IHost connection;
+
+       private ISubSystem fileSubSystem;
+       private IFileService fileService;
+
+       public RemoteMachine(IHost connection) {
+               setConnection(connection);
+       }
+
+       public String[] prepareEnvString(IProgressMonitor monitor){
+               String[] env = null;
+               try {
+                       if (shellService instanceof LocalShellService) {
+                               env  = shellService.getHostEnvironment();
+                       } else {
+                               List<String> envList = new ArrayList<String>();
+                               getRemoteEnvProxyVars(monitor);
+                               String value = "";
+                               for (String varName : environment.keySet()){
+                                       value = varName + "=" + environment.get(varName);
+                                       envList.add(value);
+                               }
+                               env = envList.toArray(new String[envList.size()]);
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+
+               return env;
+       }
+       public void getRemoteEnvProxyVars(IProgressMonitor monitor){
+               try {
+                       if (environment != null && !environment.isEmpty())
+                               return;
+
+                       environment = new HashMap<String, String>();
+
+                       IShellService shellService = getShellService(new
+SubProgressMonitor(monitor, 7));
+
+                       ProcessStreamBuffer buffer = null;
+                       try {
+                               SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 3);
+                               IHostShell hostShell = shellService.runCommand("", "env" + " ; echo " + RemoteHelper.TERMINATOR + "; exit;", new String[]{}, subMonitor);
+                               buffer = RemoteHelper.processOutput(subMonitor, hostShell, cmdHandler);
+                               for(int i = 0; i < buffer.getOutputLines().size(); i++) {
+                                       String out = buffer.getOutputLines().get(i);
+                                       String[] tokens = out.split("=");
+                                       if (tokens.length != 2)
+                                               continue;
+                                       String varName = tokens[0];
+                                       String varValue = tokens[1];
+                                       if (varName.contains(PROXY))
+                                               environment.put(varName, varValue);
+                               }
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       }
+
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public Map<String, String> getEnvironment() {
+               return environment;
+       }
+       public void setEnvironment(Map<String, String> environment) {
+               this.environment = environment;
+       }
+       public MessageConsole getConsole() {
+               if (console == null)
+                       console = ConsoleHelper.findConsole(ConsoleHelper.YOCTO_CONSOLE);
+
+               ConsoleHelper.showConsole(console);
+               return console;
+       }
+       public CommandResponseHandler getCmdHandler() {
+               if (cmdHandler == null)
+                       cmdHandler = new CommandResponseHandler(getConsole());
+               return cmdHandler;
+       }
+       public IHostShell getHostShell() {
+               try {
+                       if (hostShell == null) {
+                               hostShell = getShellService(new NullProgressMonitor()).launchShell("", new String[]{}, new NullProgressMonitor());
+                               prepareEnvString(new NullProgressMonitor());
+                       }
+               } catch (SystemMessageException e) {
+                       e.printStackTrace();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               return hostShell;
+       }
+
+       public IShellService getShellService(IProgressMonitor monitor) throws Exception {
+               if (shellService != null)
+                       return shellService;
+
+               final ISubSystem subsystem = getShellSubsystem();
+
+               if (subsystem == null)
+                       throw new Exception(Messages.ErrorNoSubsystem);
+
+               try {
+                       subsystem.connect(monitor, false);
+               } catch (CoreException e) {
+                       throw e;
+               } catch (OperationCanceledException e) {
+                       throw new CoreException(Status.CANCEL_STATUS);
+               }
+
+               if (!subsystem.isConnected())
+                       throw new Exception(Messages.ErrorConnectSubsystem);
+
+               shellService = ((IShellServiceSubSystem) subsystem).getShellService();
+               return shellService;
+       }
+
+       private ISubSystem getShellSubsystem() {
+               if (connection == null)
+                       return null;
+               ISubSystem[] subSystems = connection.getSubSystems();
+               for (int i = 0; i < subSystems.length; i++) {
+                       if (subSystems[i] instanceof IShellServiceSubSystem)
+                               return subSystems[i];
+               }
+               return null;
+       }
+
+       public IHost getConnection() {
+               return connection;
+       }
+       public void setConnection(IHost connection) {
+               this.connection = connection;
+       }
+
+       public IFileService getRemoteFileService(IProgressMonitor monitor) throws Exception {
+               if (fileService == null) {
+
+                       while(getFileSubsystem() == null)
+                               Thread.sleep(2);
+                       try {
+                               getFileSubsystem().connect(monitor, false);
+                       } catch (CoreException e) {
+                               throw e;
+                       } catch (OperationCanceledException e) {
+                               throw new CoreException(Status.CANCEL_STATUS);
+                       }
+
+                       if (!getFileSubsystem().isConnected())
+                               throw new Exception(Messages.ErrorConnectSubsystem);
+
+                       fileService = ((IFileServiceSubSystem) getFileSubsystem()).getFileService();
+               }
+               return fileService;
+       }
+
+       public ISubSystem getFileSubsystem() {
+               if (fileSubSystem == null) {
+                       if (connection == null)
+                               return null;
+                       ISubSystem[] subSystems = connection.getSubSystems();
+                       for (int i = 0; i < subSystems.length; i++) {
+                               if (subSystems[i] instanceof IFileServiceSubSystem) {
+                                       fileSubSystem = subSystems[i];
+                                       break;
+                               }
+                       }
+               }
+               return fileSubSystem;
+       }
+
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java
new file mode 100644
index 0000000..cb14c0b
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.
+++ java
@@ -0,0 +1,117 @@
+package org.yocto.remote.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.rse.core.model.IHost; import
+org.eclipse.rse.services.files.IHostFile;
+
+public abstract class Session {
+       public static final String LT = System.getProperty("line.separator");
+       public static final String EXPORT_CMD = "export
+BB_ENV_EXTRAWHITE=\"DISABLE_SANITY_CHECKS $BB_ENV_EXTRAWHITE\"";
+
+       private final String initCmd;
+       private final IHostFile root;
+
+       public String terminator;
+       private volatile boolean interrupt = false;
+       private Process process;
+       private final OutputStream pos = null;
+       private IHost connection;
+
+       public Session(IHostFile root, String initCmd) throws IOException {
+               this.root = root;
+               this.initCmd  = initCmd;
+               initializeConnection();
+               initializeShell(new NullProgressMonitor());
+       }
+
+       protected abstract void initializeConnection();
+
+       private void initializeShell(IProgressMonitor monitor) throws IOException {
+               try {
+                       if (root != null) {
+                               RemoteHelper.handleRunCommandRemote(connection, new YoctoCommand("source " + initCmd, root.getAbsolutePath(), ""), monitor);
+                               RemoteHelper.handleRunCommandRemote(connection,  new YoctoCommand(EXPORT_CMD, root.getAbsolutePath(), ""), monitor);
+                       } else {
+                               throw new Exception("Root file not found!");
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+       synchronized
+       public void execute(String command, String terminator, ICommandResponseHandler handler) throws IOException {
+               interrupt = false;
+               InputStream errIs = process.getErrorStream();
+               if (errIs.available() > 0) {
+                       clearErrorStream(errIs);
+               }
+               sendToProcessAndTerminate(command);
+
+               BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
+               String std = null;
+
+               do {
+                       if (errIs.available() > 0) {
+                               byte[] msg = new byte[errIs.available()];
+
+                               errIs.read(msg, 0, msg.length);
+                               handler.response(new String(msg), true);
+                       }
+
+                       std = br.readLine();
+
+                       if (std != null && !std.endsWith(terminator)) {
+                               handler.response(std, false);
+                       }
+
+               } while (std != null && !std.endsWith(terminator) && !interrupt);
+
+               if (interrupt) {
+                       process.destroy();
+                       initializeShell(null);
+                       interrupt = false;
+               }
+       }
+
+       private void clearErrorStream(InputStream is) {
+
+               try {
+                       byte b[] = new byte[is.available()];
+                       is.read(b);
+                       System.out.println("clearing: " + new String(b));
+               } catch (IOException e) {
+                       e.printStackTrace();
+                       //Ignore any error
+               }
+       }
+       /**
+        * Send command string to shell process and add special terminator string so
+        * reader knows when output is complete.
+        *
+        * @param command
+        * @throws IOException
+        */
+       private void sendToProcessAndTerminate(String command) throws IOException {
+               pos.write(command.getBytes());
+               pos.write(LT.getBytes());
+               pos.flush();
+               pos.write("echo $?".getBytes());
+               pos.write(terminator.getBytes());
+               pos.write(LT.getBytes());
+               pos.flush();
+       }
+
+       /**
+        * Interrupt any running processes.
+        */
+       public void interrupt() {
+               interrupt = true;
+       }
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java
new file mode 100644
index 0000000..0cd7dcd
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCom
+++ mand.java
@@ -0,0 +1,53 @@
+package org.yocto.remote.utils;
+
+
+public class YoctoCommand {
+       private String command;
+       private String initialDirectory;
+       private String arguments;
+       private ProcessStreamBuffer processBuffer;
+
+       public YoctoCommand(String command, String initialDirectory, String arguments){
+               this.setCommand(command);
+               this.setInitialDirectory(initialDirectory);
+               this.setArguments(arguments);
+               this.setProcessBuffer(new ProcessStreamBuffer(false));
+       }
+
+       public String getCommand() {
+               return command;
+       }
+
+       public void setCommand(String command) {
+               this.command = command;
+       }
+
+       public String getInitialDirectory() {
+               return initialDirectory;
+       }
+
+       public void setInitialDirectory(String initialDirectory) {
+               this.initialDirectory = initialDirectory;
+       }
+
+       public String getArguments() {
+               return arguments;
+       }
+
+       public void setArguments(String arguments) {
+               this.arguments = arguments;
+       }
+
+       public ProcessStreamBuffer getProcessBuffer() {
+               return processBuffer;
+       }
+
+       public void setProcessBuffer(ProcessStreamBuffer processBuffer) {
+               this.processBuffer = processBuffer;
+       }
+
+       @Override
+       public String toString() {
+               return command + " " + arguments;
+       }
+}
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Refactor RFC 3/9] Remove ICommandResponseHandler from plugin and use org.yocto.remote.utils implementation
  2013-06-04 13:26 ` [Refactor RFC 3/9] Remove ICommandResponseHandler from plugin and use org.yocto.remote.utils implementation Ioana Grigoropol
@ 2013-06-06 23:56   ` Zhang, Jessica
  0 siblings, 0 replies; 20+ messages in thread
From: Zhang, Jessica @ 2013-06-06 23:56 UTC (permalink / raw)
  To: Grigoropol, IoanaX, yocto

Please fix the license for the files.

Thanks,
Jessica

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: yocto@yoctoproject.org
Subject: [yocto] [Refactor RFC 3/9] Remove ICommandResponseHandler from plugin and use org.yocto.remote.utils implementation

- add dependency to remote common plugin
- update all references to use the common interface

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF       |    3 +-
 .../yocto/bc/bitbake/ICommandResponseHandler.java  |   15 ----------
 .../src/org/yocto/bc/bitbake/ShellSession.java     |    2 ++
 .../ui/actions/AbstractBitbakeCommandAction.java   |    3 +-
 .../yocto/bc/ui/wizards/install/InstallWizard.java |   30 ++++++--------------
 5 files changed, 13 insertions(+), 40 deletions(-)  delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java

diff --git a/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF b/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF
index 6366424..3ca62df 100644
--- a/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF
@@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.ui.editors,
  org.eclipse.ui.ide,
  org.eclipse.ui.console,
- org.eclipse.core.filesystem
+ org.eclipse.core.filesystem,
+ org.yocto.remote.utils;bundle-version="1.0.0"
 Eclipse-LazyStart: true
 Bundle-ClassPath: .
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java
deleted file mode 100644
index 4c44352..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.bitbake;
-
-public interface ICommandResponseHandler {
-       public void response(String line, boolean isError);
-}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
index 4719865..db8f564 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
@@ -18,6 +18,8 @@ import java.io.InputStreamReader;  import java.io.OutputStream;  import java.io.Writer;

+import org.yocto.remote.utils.ICommandResponseHandler;
+
 /**
  * A class for Linux shell sessions.
  * @author kgilmer
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
index 41d5c73..cd4f4c9 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbak
+++ eCommandAction.java
@@ -29,12 +29,11 @@ import org.eclipse.ui.IWorkbenchWindow;  import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 import org.eclipse.ui.console.MessageConsole;
 import org.eclipse.ui.console.MessageConsoleStream;
-
 import org.yocto.bc.bitbake.BBLanguageHelper;
 import org.yocto.bc.bitbake.BBSession;
-import org.yocto.bc.bitbake.ICommandResponseHandler;
 import org.yocto.bc.ui.Activator;
 import org.yocto.bc.ui.builder.BitbakeCommanderNature;
+import org.yocto.remote.utils.ICommandResponseHandler;

 public abstract class AbstractBitbakeCommandAction implements IWorkbenchWindowActionDelegate {

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java
index f2cb1da..3130cbf 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/Instal
+++ lWizard.java
@@ -2,53 +2,39 @@ package org.yocto.bc.ui.wizards.install;

 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileDescriptor;
-import java.io.InputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.io.OutputStream;
 import java.io.Writer;
-import java.util.ArrayList;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;

 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;  import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.WizardPage;
-
-import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWizard;  import org.eclipse.ui.IWorkbenchPage;  import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.console.MessageConsole;
-import org.eclipse.ui.console.MessageConsoleStream;
+import org.eclipse.ui.IWorkbenchWizard; import
+org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsoleManager;
 import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleManager;
 import org.eclipse.ui.console.IConsoleView;
-import org.eclipse.ui.progress.IProgressService;
-
-import org.yocto.bc.bitbake.ICommandResponseHandler;
-import org.yocto.bc.bitbake.ShellSession;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
 import org.yocto.bc.ui.Activator;
 import org.yocto.bc.ui.model.ProjectInfo;
 import org.yocto.bc.ui.wizards.FiniteStateWizard;
-
 import org.yocto.bc.ui.wizards.newproject.BBConfigurationInitializeOperation;
 import org.yocto.bc.ui.wizards.newproject.CreateBBCProjectOperation;
+import org.yocto.remote.utils.ICommandResponseHandler;

 /**
  * A wizard for installing a fresh copy of an OE system.
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Refactor RFC 4/9] Remove unused Bitbake Actions
  2013-06-04 13:26 ` [Refactor RFC 4/9] Remove unused Bitbake Actions Ioana Grigoropol
@ 2013-06-06 23:57   ` Zhang, Jessica
  2013-06-07 12:19     ` Grigoropol, IoanaX
  0 siblings, 1 reply; 20+ messages in thread
From: Zhang, Jessica @ 2013-06-06 23:57 UTC (permalink / raw)
  To: Grigoropol, IoanaX, yocto

We can't remove them, since we should support build a specific recipe as from the command line.

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: yocto@yoctoproject.org
Subject: [yocto] [Refactor RFC 4/9] Remove unused Bitbake Actions

- none of the Bitbake action classes that inherit from AbstractBitbakeCommandAction is used -> clean-up classes & plugin.xml

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 plugins/org.yocto.bc.ui/plugin.xml                 |   55 ------
 .../ui/actions/AbstractBitbakeCommandAction.java   |  198 --------------------
 .../bc/ui/actions/BitbakeBuildRecipeAction.java    |   24 ---
 .../bc/ui/actions/BitbakeCleanRecipeAction.java    |   26 ---
 .../yocto/bc/ui/actions/BitbakeImportAction.java   |  106 -----------
 .../bc/ui/actions/BitbakeRebuildRecipeAction.java  |   29 ---
 6 files changed, 438 deletions(-)
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java

diff --git a/plugins/org.yocto.bc.ui/plugin.xml b/plugins/org.yocto.bc.ui/plugin.xml
index cb0561c..2e1421f 100644
--- a/plugins/org.yocto.bc.ui/plugin.xml
+++ b/plugins/org.yocto.bc.ui/plugin.xml
@@ -39,61 +39,6 @@
             commandId="org.yocto.bc.ui.command.launchHob">
       </handler>
    </extension>
-   <!--
-   <extension
-         point="org.eclipse.ui.popupMenus">
-      <objectContribution
-            adaptable="true"
-            id="org.yocto.bc.ui.contribution2"
-            nameFilter="*.bb"
-            objectClass="org.eclipse.core.resources.IFile">
-         <action
-               class="org.yocto.bc.ui.actions.BitbakeBuildRecipeAction"
-               enablesFor="+"
-               icon="icons/binary.gif"
-               id="org.yocto.bc.ui.BuildPackagePopupAction"
-               label="Build"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Build a package">
-         </action>
-               <action
-               class="org.yocto.bc.ui.actions.BitbakeCleanRecipeAction"
-               enablesFor="+"
-               icon="icons/trash.gif"
-               id="org.yocto.bc.ui.CleanPackagePopupAction"
-               label="Clean"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Clean a package">
-         </action>
-         <action
-               class="org.yocto.bc.ui.actions.BitbakeImportAction"
-               enablesFor="+"
-               icon="icons/import_wiz.gif"
-               id="org.yocto.bc.ui.BitbakeImportPopupAction"
-               label="Import"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Import package sources as Eclipse project.">
-         </action>
-         <menu
-               id="org.yocto.bc.ui.menu1"
-               label="BitBake"
-               path="additions">
-            <separator
-                  name="bc.separator1">
-            </separator>
-         </menu>
-         <action
-               class="org.yocto.bc.ui.actions.BitbakeRebuildRecipeAction"
-               enablesFor="+"
-               icon="icons/refresh.gif"
-               id="org.yocto.bc.ui.BuildPackagePopupAction"
-               label="Rebuild"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Rebuild a package">
-         </action>
-     </objectContribution>
-   </extension>
-   -->
    <extension
          point="org.eclipse.ui.menus">
       <menuContribution
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
deleted file mode 100644
index cd4f4c9..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IAction; -import org.eclipse.jface.preference.JFacePreferences;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.console.MessageConsole;
-import org.eclipse.ui.console.MessageConsoleStream;
-import org.yocto.bc.bitbake.BBLanguageHelper;
-import org.yocto.bc.bitbake.BBSession;
-import org.yocto.bc.ui.Activator;
-import org.yocto.bc.ui.builder.BitbakeCommanderNature;
-import org.yocto.remote.utils.ICommandResponseHandler;
-
-public abstract class AbstractBitbakeCommandAction implements IWorkbenchWindowActionDelegate {
-
-       private class CommandJob extends Job {
-
-               public CommandJob() {
-                       super(getJobTitle());
-               }
-
-               @Override
-               protected IStatus run(IProgressMonitor monitor) {
-                       String cmds[] = getCommands();
-                       return execCommands(cmds, monitor);
-               }
-
-       }
-       protected IAction action;
-       protected IFile recipe;
-       protected BBSession bbs;
-
-       private Color commandColor, responseColor, errorColor;
-       private boolean errorOccurred = false;
-
-       public AbstractBitbakeCommandAction() {
-               commandColor = JFaceResources.getColorRegistry().get(JFacePreferences.ACTIVE_HYPERLINK_COLOR);
-               responseColor = JFaceResources.getColorRegistry().get(JFacePreferences.HYPERLINK_COLOR);
-               errorColor = JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR);
-       }
-
-       private void checkEnabled(IFile file) {
-               try {
-                       if (file.getFileExtension() == null || !file.getFileExtension().equals(BBLanguageHelper.BITBAKE_RECIPE_FILE_EXTENSION)) {
-                               action.setEnabled(false);
-                               return;
-                       }
-
-                       IProject project = file.getProject();
-                       if (!(project.hasNature(BitbakeCommanderNature.NATURE_ID))) {
-                               action.setEnabled(false);
-                               return;
-                       }
-
-                       bbs = Activator.getBBSession(project.getLocationURI().getPath());
-
-                       if (bbs != null) {
-                               recipe = file;
-                               action.setEnabled(true);
-                       }
-
-               } catch (CoreException e) {
-                       action.setEnabled(false);
-                       e.printStackTrace();
-               } catch (Exception e) {
-                       action.setEnabled(false);
-                       e.printStackTrace();
-               }
-       }
-
-       public void dispose() {
-       }
-
-       /**
-        * Execute array of commands with bitbake and put output in console.
-        *
-        * @param cmds
-        * @param monitor
-        * @return
-        */
-       protected IStatus execCommands(String[] cmds, final IProgressMonitor monitor) {
-               MessageConsole mc = bbs.getConsole();
-               final MessageConsoleStream cmd = mc.newMessageStream();
-               cmd.setColor(commandColor);
-               final MessageConsoleStream out = mc.newMessageStream();
-               final MessageConsoleStream err = mc.newMessageStream();
-               err.setColor(errorColor);
-
-               try {
-                       for (int i = 0; i < cmds.length; ++i) {
-                               cmd.println(cmds[i]);
-                               monitor.subTask(cmds[i]);
-                               bbs.getShell().execute(cmds[i], new ICommandResponseHandler() {
-
-                                       public void response(String line, boolean isError) {
-                                               if (monitor.isCanceled()) {
-                                                       cmd.println("Interrupting process by user request.");
-                                                       bbs.getShell().interrupt();
-                                               }
-
-                                               if (isError) {
-                                                       err.println(line);
-                                                       errorOccurred();
-                                               } else if (line.startsWith("ERROR:")) {
-                                                       err.println(line);
-                                               } else {
-                                                       out.println(line);
-                                               }
-                                       }
-                               });
-                       }
-               } catch (IOException e) {
-                       return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
-               } finally {
-                       try {
-                               if (errorOccurred) {
-                                       cmd.println("At least one error occured while executing this command.  Check output for more details.");
-                               }
-                               cmd.close();
-                               out.close();
-                               err.close();
-                       } catch (IOException e) {
-                               e.printStackTrace();
-                       }
-               }
-
-               return Status.OK_STATUS;
-       }
-
-       protected void errorOccurred() {
-               errorOccurred = true;
-       }
-
-       /**
-        * Return the command to be executed.
-        *
-        * @return
-        */
-       public abstract String[] getCommands();
-
-       public Job getJob() {
-               return new CommandJob();
-       }
-
-       /**
-        * Return the title of the job.
-        *
-        * @return
-        */
-       public abstract String getJobTitle();
-
-       public void init(IWorkbenchWindow window) {
-       }
-
-       public void run(IAction action) {
-               Job job = getJob();
-               job.schedule();
-       }
-
-       public void selectionChanged(IAction action, ISelection selection) {
-               this.action = action;
-               if (selection instanceof IStructuredSelection) {
-                       Object sel = ((IStructuredSelection) selection).getFirstElement();
-
-                       if (sel instanceof IFile) {
-                               checkEnabled((IFile) sel);
-                               return;
-                       }
-               }
-
-               action.setEnabled(false);
-       }
-
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java
deleted file mode 100644
index 22ac94c..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-public  class BitbakeBuildRecipeAction extends AbstractBitbakeCommandAction {
-
-       @Override
-       public String [] getCommands() {
-               return new String[] {"bitbake -b " + recipe.getLocationURI().getPath()};
-       }
-
-       @Override
-       public String getJobTitle() {
-               return "Building " + recipe.getName();
-       }
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java
deleted file mode 100644
index f95117e..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-public class BitbakeCleanRecipeAction extends AbstractBitbakeCommandAction {
-
-       @Override
-       public String [] getCommands() {
-               return new String[] {"bitbake -c clean -b " + recipe.getLocationURI().getPath()};
-       }
-
-       @Override
-       public String getJobTitle() {
-               return "Cleaning " + recipe.getName();
-       }
-
-
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java
deleted file mode 100644
index ecceecf..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job;
-
-import org.yocto.bc.bitbake.BBCommonVars;
-import org.yocto.bc.bitbake.BBRecipe;
-import org.yocto.bc.ui.Activator;
-
-public  class BitbakeImportAction extends AbstractBitbakeCommandAction {
-
-       private class ImportJob extends Job {
-
-               public ImportJob() {
-                       super(getJobTitle());
-               }
-
-               @Override
-               protected IStatus run(IProgressMonitor monitor) {
-
-                       try {
-                               BBRecipe br = new BBRecipe(bbs, recipe.getLocationURI().getPath());
-                               br.initialize();
-                               String filePath = (String) br.get(BBCommonVars.S);
-
-                               //"${WORKDIR}/${PN}-${PV}"
-                               if (filePath == null) {
-                                       filePath = ((String) br.get(BBCommonVars.WORKDIR)) + File.separator + ((String) br.get(BBCommonVars.PN)) + "-" + ((String) br.get(BBCommonVars.PV));
-                               }
-
-                               String projectName = (String) br.get(BBCommonVars.PN);
-
-                               if (filePath == null || projectName == null) {
-                                       return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to parse recipe file.");
-                               }
-
-                               File workdir = new File(filePath);
-
-                               if (workdir.exists() && workdir.isFile()) {
-                                       return new Status(IStatus.ERROR, Activator.PLUGIN_ID, workdir.getPath() + " is an invalid workdir.");
-                               }
-
-                               if (!workdir.exists()) {
-                                       execCommands(new String[] {"bitbake -c patch -b " + recipe.getLocationURI().getPath()}, monitor);
-                               }
-
-                               if (!workdir.exists()) {
-                                       return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to retrieve sources from BitBake.  Consult console.");
-                               }
-
-                               IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
-                               IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
-                               IProject proj = wsroot.getProject(projectName);
-                               proj.create(desc, monitor);
-                               proj.open(monitor);
-
-                               String copyCmd = "cp -r " + workdir.getAbsolutePath() + File.separator + "* \"" + proj.getLocationURI().getPath() + "\"";
-                               execCommands(new String[] {copyCmd} , monitor);
-
-                               proj.refreshLocal(IResource.DEPTH_INFINITE, monitor);
-
-                       } catch (Exception e) {
-                               e.printStackTrace();
-                               return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to create project.", e);
-                       }
-
-                       return Status.OK_STATUS;
-               }
-
-       }
-
-       @Override
-       public String [] getCommands() {
-               return null;
-       }
-
-
-       @Override
-       public Job getJob() {
-               return new ImportJob();
-       }
-
-       @Override
-       public String getJobTitle() {
-               return "Importing " + recipe.getName();
-       }
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java
deleted file mode 100644
index c5dedea..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-/**
- * Rebuild a recipe.
- * @author kgilmer
- *
- */
-public  class BitbakeRebuildRecipeAction extends AbstractBitbakeCommandAction {
-
-       @Override
-       public String [] getCommands() {
-               return new String[] {"bitbake -c rebuild -b " + recipe.getLocationURI().getPath()};
-       }
-
-       @Override
-       public String getJobTitle() {
-               return "Rebuilding " + recipe.getName();
-       }
-}
\ No newline at end of file
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Refactor RFC 5/9] Remove storing of init script location
  2013-06-04 13:26 ` [Refactor RFC 5/9] Remove storing of init script location Ioana Grigoropol
@ 2013-06-07  0:02   ` Zhang, Jessica
  2013-06-07 12:18     ` Grigoropol, IoanaX
  0 siblings, 1 reply; 20+ messages in thread
From: Zhang, Jessica @ 2013-06-07  0:02 UTC (permalink / raw)
  To: Grigoropol, IoanaX, yocto

Why we want to remove this project info file, since it's not used now but it stated it's used for future.

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: yocto@yoctoproject.org
Subject: [yocto] [Refactor RFC 5/9] Remove storing of init script location

- when create a new bitbake commander project and when initializing the configuration - the location of the init bitbake script is stored in a file called .eclipse-data
- the information stored here is never used

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../org/yocto/bc/bitbake/ProjectInfoHelper.java    |   23 --------------------
 .../BBConfigurationInitializeOperation.java        |    1 -
 .../newproject/CreateBBCProjectOperation.java      |    6 -----
 3 files changed, 30 deletions(-)

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
index 25dac97..b8d4b29 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
@@ -79,27 +79,4 @@ public class ProjectInfoHelper {

                return null;
        }
-
-       /**
-        * This method will store the path to the bitbake init script for future
-        * reference.
-        *
-        * @param path
-        * @param projInfo
-        * @throws IOException
-        */
-       public static void store(String path, ProjectInfo projInfo) throws IOException {
-               writeToFile(path, projInfo.getInitScriptPath());
-       }
-
-       private static void writeToFile(String path, String init) throws IOException {
-               File outFile = new File(path, ".eclipse-data");
-               FileOutputStream fos = new FileOutputStream(outFile);
-
-               fos.write(init.getBytes());
-
-               fos.flush();
-               fos.close();
-       }
-
 }
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
index 4f15107..64c3e6e 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
@@ -39,7 +39,6 @@ public class BBConfigurationInitializeOperation implements IRunnableWithProgress
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                BBSession session;
                try {
-                       ProjectInfoHelper.store(pinfo.getRootPath(), pinfo);
                        session = Activator.getBBSession(pinfo.getRootPath(), writer);
                        session.initialize();

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
index dc0153b..1d54ea3 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
@@ -85,12 +85,6 @@ public class CreateBBCProjectOperation extends WorkspaceModifyOperation {

                IProject proj = wsroot.getProject(projInfo.getProjectName());
                proj.create(desc, monitor);
-               try {
-                       ProjectInfoHelper.store(proj.getLocationURI().getPath(), projInfo);
-               } catch (IOException e) {
-                       throw new InvocationTargetException(e);
-               }
-
                proj.open(monitor);

                addNatures(proj, monitor);
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Refactor RFC 9/9] Redirect bitbake environment parsing to file & parse
  2013-06-04 13:26 ` [Refactor RFC 9/9] Redirect bitbake environment parsing to file & parse Ioana Grigoropol
@ 2013-06-07  0:27   ` Zhang, Jessica
  2013-06-11 11:27     ` Grigoropol, IoanaX
  0 siblings, 1 reply; 20+ messages in thread
From: Zhang, Jessica @ 2013-06-07  0:27 UTC (permalink / raw)
  To: Grigoropol, IoanaX, yocto

Ioana,

There're couple fixme in wait for bitbake to finish and clean up the environment file that seems not addressed.  Also, please make sure the changed files have valid license info.

Thanks,
Jessica

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: yocto@yoctoproject.org
Subject: [yocto] [Refactor RFC 9/9] Redirect bitbake environment parsing to file & parse

- when running "bitbake -e" the output is sent to the console, poluting it
- instead, send the output to a file (bitbake.env) and parse the file accordingly
- if an error has occured while running the commad, all the error lines are collected and displayed on the console

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../src/org/yocto/bc/bitbake/BBRecipe.java         |    2 +-
 .../src/org/yocto/bc/bitbake/BBSession.java        |   49 +++++++++++++-------
 .../src/org/yocto/bc/bitbake/ShellSession.java     |   14 +++---
 3 files changed, 40 insertions(+), 25 deletions(-)

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
index 1baf124..6168f8c 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
@@ -26,7 +26,7 @@ public class BBRecipe extends BBSession {
                super(session.shell, session.pinfo.getOriginalURI());
                this.session = session;
                this.fileURI = filePath;
-               this.parsingCmd = "DISABLE_SANITY_CHECKS=1 bitbake -e -b " + filePath;
+               this.parsingCmd = "DISABLE_SANITY_CHECKS=\"1\" bitbake -e -b " +
+filePath.getPath() + " >& " + BB_ENV_FILE;
        }

        @Override
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
index fcde557..9bc4dcc 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
@@ -15,6 +15,8 @@ import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
 import java.io.StringReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -33,9 +35,11 @@ import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Status;  import org.eclipse.jface.preference.JFacePreferences;
 import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.rse.core.model.IHost;
 import org.eclipse.ui.console.ConsolePlugin;
 import org.eclipse.ui.console.IConsole;  import org.eclipse.ui.console.IConsoleManager;
@@ -45,6 +49,7 @@ import org.eclipse.ui.progress.WorkbenchJob;

 import org.yocto.bc.ui.model.IModelElement;
 import org.yocto.bc.ui.model.ProjectInfo;
+import org.yocto.remote.utils.RemoteHelper;

 /**
  * BBSession encapsulates a global bitbake configuration and is the primary interface @@ -59,6 +64,7 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
        public static final int TYPE_STATEMENT = 3;
        public static final int TYPE_FLAG = 4;

+       public static final String BB_ENV_FILE = "bitbake.env";
        public static final String BUILDDIR_INDICATORS [] = {
                File.separatorChar + "conf" + File.separatorChar + "local.conf",
                File.separatorChar + "conf" + File.separatorChar + "bblayers.conf", @@ -69,19 +75,21 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
        protected Map<?,?> properties = null;
        protected List <URI> depends = null;
        protected boolean initialized = false;
+       protected boolean errorOccured = false;
        protected MessageConsole sessionConsole;
        private final ReentrantReadWriteLock rwlock = new ReentrantReadWriteLock();
        private final Lock rlock = rwlock.readLock();
        private final Lock wlock = rwlock.writeLock();
        protected String parsingCmd;
        private boolean silent = false;
-
+       private String errorLines = "";
+
        public BBSession(ShellSession ssession, URI projectRoot) throws IOException {
                shell = ssession;
                this.pinfo = new ProjectInfo();
                pinfo.setLocationURI(projectRoot);
                pinfo.setInitScriptPath(ProjectInfoHelper.getInitScriptPath(projectRoot));
-               this.parsingCmd = "DISABLE_SANITY_CHECKS=1 bitbake -e";
+               this.parsingCmd = "DISABLE_SANITY_CHECKS=\"1\" bitbake -e >& " +
+BB_ENV_FILE;
        }

        public BBSession(ShellSession ssession, URI projectRoot, boolean silent) throws IOException { @@ -330,18 +338,17 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
                }
        }

-       protected int checkExecuteError(String result, int code) {
+       protected void checkExecuteError(String result, boolean hasErrors) {
                URI recipeURI = getDefaultDepends();
                String text = "Parsing " + ((recipeURI != null) ? ("recipe " + recipeURI) : "base configurations");
-               if (code != 0) {
+               if (hasErrors) {
                        text = text + " ERROR!\n" + result;
                }else {
                                text = text + " SUCCESS.\n";
                }
                if(!silent) {
-                       displayInConsole(text, code, false);
+                       displayInConsole(text, -1, false);
                }
-               return code;
        }

        protected void displayInConsole(final String result, final int code, boolean clear) { @@ -378,14 +385,21 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
                        }
                        try {
                                if(!initialized) { //recheck
-                                       int [] codes = {-1};
-                                       String result = shell.execute(parsingCmd, codes);
-                                       if(checkExecuteError(result, codes[0]) == 0) {
-                                               properties = parseBBEnvironment(result);
+                                       boolean hasErrors = false;
+                                       String result = shell.execute(parsingCmd, hasErrors);
+
+                                       //FIXME : wait for bitbake to finish
+                                       properties = parseBBEnvironment(result);
+
+                                       if (properties.size() == 0) { // there was an error in sourcing bitbake environment
+                                               shell.printError(errorLines);
+                                               errorOccured = true;
                                        } else {
-                                               properties = parseBBEnvironment("");
+                                               errorLines = "";
+                                               errorOccured = false;
+                                               initialized = true;
                                        }
-                                       initialized = true;
+                                       //FIXME: cleanup BB env file
                                }
                        } finally {
                                //downgrade lock
@@ -440,8 +454,11 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
                }
        }

-       protected void parse(String content, Map outMap) throws Exception {
-               BufferedReader reader = new BufferedReader(new StringReader(content));
+       protected void parse(String bbOutfilePath, Map outMap) throws Exception {
+               IHost connection = shell.getProjectInfo().getConnection();
+               InputStream is = RemoteHelper.getRemoteInputStream(connection, bbOutfilePath, BB_ENV_FILE, new NullProgressMonitor());
+               RemoteHelper.getRemoteHostFile(connection, bbOutfilePath + BB_ENV_FILE, new NullProgressMonitor());
+               BufferedReader reader = new BufferedReader(new
+InputStreamReader(is));
                String line;
                boolean inLine = false;
                StringBuffer sb = null;
@@ -508,11 +525,11 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
                return null;
        }

-       protected Map parseBBEnvironment(String bbOut) throws Exception {
+       protected Map parseBBEnvironment(String bbOutFilePath) throws
+Exception {
                Map env = new Hashtable();
                this.depends = new ArrayList<URI>();

-               parse(bbOut, env);
+               parse(bbOutFilePath, env);

                String included = (String) env.get("BBINCLUDED");
                if(getDefaultDepends() != null) {
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
index 44b2696..129d1d9 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
@@ -21,6 +21,7 @@ import java.io.Writer;  import org.eclipse.rse.services.files.IHostFile;
 import org.yocto.bc.ui.model.ProjectInfo;
 import org.yocto.remote.utils.ICommandResponseHandler;
+import org.yocto.remote.utils.RemoteHelper;

 /**
  * A class for Linux shell sessions.
@@ -112,11 +113,11 @@ public class ShellSession {

        synchronized
        public String execute(String command) throws IOException {
-               return execute(command, (int [])null);
+               return execute(command, false);
        }

        synchronized
-       public String execute(String command, int[] retCode) throws IOException {
+       public String execute(String command, boolean hasErrors) throws
+IOException {
                String errorMessage = null;
                interrupt = false;
                out.write(command);
@@ -150,12 +151,6 @@ public class ShellSession {
                        process.destroy();
                        initializeShell();
                        interrupt = false;
-               }else if (line != null && retCode != null) {
-                       try {
-                               retCode[0]=Integer.parseInt(line.substring(0,line.lastIndexOf(TERMINATOR)));
-                       }catch (NumberFormatException e) {
-                               throw new IOException("Can NOT get return code" + command + LT + line);
-                       }
                }

                if (errorMessage != null) {
@@ -259,4 +254,7 @@ synchronized
                }

        }
+       public void printError(String errorLines) {
+               RemoteHelper.getCommandHandler(projectInfo.getConnection()).response(errorLines, true);
+       }
 }
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Refactor RFC 0/9] Merging of windows-build with master
  2013-06-04 13:25 [Refactor RFC 0/9] Merging of windows-build with master Ioana Grigoropol
                   ` (8 preceding siblings ...)
  2013-06-04 13:26 ` [Refactor RFC 9/9] Redirect bitbake environment parsing to file & parse Ioana Grigoropol
@ 2013-06-07  0:29 ` Zhang, Jessica
  9 siblings, 0 replies; 20+ messages in thread
From: Zhang, Jessica @ 2013-06-07  0:29 UTC (permalink / raw)
  To: Grigoropol, IoanaX, yocto

Hi Ioana,

I've provided detailed info regarding each patch.  Please have them addressed and resubmit.  I'll hold off review of the other RFC series till we have this set settled.

Thanks,
Jessica

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: yocto@yoctoproject.org
Subject: [yocto] [Refactor RFC 0/9] Merging of windows-build with master


Ioana Grigoropol (9):
  Rename RSEHelper to RemoteHelper to match usages in
    org.yocto.bc.ui.plugin
  Add remote tools classes needed for bitbake remote capabilities
  Remove ICommandResponseHandler from plugin and use
    org.yocto.remote.utils implementation
  Remove unused Bitbake Actions
  Remove storing of init script location
  Remove unused method loadInit in Activator
  Remove unused getInitScript from ProjectInfoHelper
  Use URI for storing project locations
  Redirect bitbake environment parsing to file & parse

 plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF       |    7 +-
 plugins/org.yocto.bc.ui/plugin.xml                 |   55 ---
 .../src/org/yocto/bc/bitbake/BBRecipe.java         |   26 +-
 .../src/org/yocto/bc/bitbake/BBSession.java        |   83 ++--
 .../yocto/bc/bitbake/ICommandResponseHandler.java  |   15 -
 .../org/yocto/bc/bitbake/ProjectInfoHelper.java    |   58 +--
 .../src/org/yocto/bc/bitbake/ShellSession.java     |   32 +-
 .../src/org/yocto/bc/ui/Activator.java             |   83 ++--
 .../ui/actions/AbstractBitbakeCommandAction.java   |  199 --------
 .../bc/ui/actions/BitbakeBuildRecipeAction.java    |   24 -
 .../bc/ui/actions/BitbakeCleanRecipeAction.java    |   26 -
 .../yocto/bc/ui/actions/BitbakeImportAction.java   |  106 -----
 .../bc/ui/actions/BitbakeRebuildRecipeAction.java  |   29 --
 .../bc/ui/actions/LaunchVariableWizardAction.java  |   16 +-
 .../bc/ui/editors/bitbake/BBVariableTextHover.java |   16 +-
 .../bc/ui/editors/bitbake/BitBakeFileEditor.java   |   16 +-
 .../bitbake/BitBakeSourceViewerConfiguration.java  |   14 +-
 .../src/org/yocto/bc/ui/filesystem/OEFile.java     |   13 +-
 .../org/yocto/bc/ui/filesystem/OEFileSystem.java   |   24 +-
 .../org/yocto/bc/ui/filesystem/YoctoLocation.java  |   34 ++
 .../src/org/yocto/bc/ui/model/ProjectInfo.java     |   75 ++-
 .../yocto/bc/ui/views/RecipeContentProvider.java   |    2 +-
 .../importProject/ImportYoctoProjectWizard.java    |    7 +-
 .../yocto/bc/ui/wizards/install/InstallWizard.java |   39 +-
 .../BBConfigurationInitializeOperation.java        |    3 +-
 .../newproject/CreateBBCProjectOperation.java      |   20 +-
 .../org.yocto.remote.utils/META-INF/MANIFEST.MF    |    8 +-
 .../yocto/remote/utils/CommandOutputProcessor.java |   33 ++
 .../yocto/remote/utils/CommandResponseHandler.java |   36 ++
 .../org/yocto/remote/utils/CommandRunnable.java    |   34 ++
 .../src/org/yocto/remote/utils/ConsoleHelper.java  |   28 ++
 .../org/yocto/remote/utils/ConsoleRunnable.java    |   37 ++
 .../remote/utils/ICommandResponseHandler.java      |   15 +
 .../org/yocto/remote/utils/OutputProcessor.java    |  102 ++++
 .../yocto/remote/utils/ProcessStreamBuffer.java    |   77 +++
 .../src/org/yocto/remote/utils/RSEHelper.java      |  344 -------------
 .../src/org/yocto/remote/utils/RemoteHelper.java   |  503 ++++++++++++++++++++
 .../src/org/yocto/remote/utils/RemoteMachine.java  |  206 ++++++++
 .../org/yocto/remote/utils/RemoteShellExec.java    |    2 +-
 .../src/org/yocto/remote/utils/Session.java        |  117 +++++
 .../org/yocto/remote/utils/TerminalHandler.java    |    2 +-
 .../src/org/yocto/remote/utils/YoctoCommand.java   |   53 +++
 .../yocto/sdk/remotetools/actions/BaseModel.java   |    6 +-
 .../sdk/remotetools/actions/BaseSettingDialog.java |   12 +-
 44 files changed, 1591 insertions(+), 1046 deletions(-)  delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java
 create mode 100755 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/YoctoLocation.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java
 delete mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RSEHelper.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java

--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Refactor RFC 5/9] Remove storing of init script location
  2013-06-07  0:02   ` Zhang, Jessica
@ 2013-06-07 12:18     ` Grigoropol, IoanaX
  0 siblings, 0 replies; 20+ messages in thread
From: Grigoropol, IoanaX @ 2013-06-07 12:18 UTC (permalink / raw)
  To: Zhang, Jessica, yocto

Hi Jessica,

The reason I have remove this is that we can always find it on git.
So if we at some point decide that we need to save the location of the init script, we can just look in the git log, and add it again. 
I do not see the point in keeping classes, methods that are not used, and which at this point need to be fixed due to the changes I have introduced, otherwise they will not compile.

Thanks,
Ioana
________________________________________
From: Zhang, Jessica
Sent: Friday, June 07, 2013 3:02 AM
To: Grigoropol, IoanaX; yocto@yoctoproject.org
Subject: RE: [yocto] [Refactor RFC 5/9] Remove storing of init script location

Why we want to remove this project info file, since it's not used now but it stated it's used for future.

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: yocto@yoctoproject.org
Subject: [yocto] [Refactor RFC 5/9] Remove storing of init script location

- when create a new bitbake commander project and when initializing the configuration - the location of the init bitbake script is stored in a file called .eclipse-data
- the information stored here is never used

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../org/yocto/bc/bitbake/ProjectInfoHelper.java    |   23 --------------------
 .../BBConfigurationInitializeOperation.java        |    1 -
 .../newproject/CreateBBCProjectOperation.java      |    6 -----
 3 files changed, 30 deletions(-)

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
index 25dac97..b8d4b29 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java
@@ -79,27 +79,4 @@ public class ProjectInfoHelper {

                return null;
        }
-
-       /**
-        * This method will store the path to the bitbake init script for future
-        * reference.
-        *
-        * @param path
-        * @param projInfo
-        * @throws IOException
-        */
-       public static void store(String path, ProjectInfo projInfo) throws IOException {
-               writeToFile(path, projInfo.getInitScriptPath());
-       }
-
-       private static void writeToFile(String path, String init) throws IOException {
-               File outFile = new File(path, ".eclipse-data");
-               FileOutputStream fos = new FileOutputStream(outFile);
-
-               fos.write(init.getBytes());
-
-               fos.flush();
-               fos.close();
-       }
-
 }
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
index 4f15107..64c3e6e 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
@@ -39,7 +39,6 @@ public class BBConfigurationInitializeOperation implements IRunnableWithProgress
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                BBSession session;
                try {
-                       ProjectInfoHelper.store(pinfo.getRootPath(), pinfo);
                        session = Activator.getBBSession(pinfo.getRootPath(), writer);
                        session.initialize();

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
index dc0153b..1d54ea3 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
@@ -85,12 +85,6 @@ public class CreateBBCProjectOperation extends WorkspaceModifyOperation {

                IProject proj = wsroot.getProject(projInfo.getProjectName());
                proj.create(desc, monitor);
-               try {
-                       ProjectInfoHelper.store(proj.getLocationURI().getPath(), projInfo);
-               } catch (IOException e) {
-                       throw new InvocationTargetException(e);
-               }
-
                proj.open(monitor);

                addNatures(proj, monitor);
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Refactor RFC 4/9] Remove unused Bitbake Actions
  2013-06-06 23:57   ` Zhang, Jessica
@ 2013-06-07 12:19     ` Grigoropol, IoanaX
  0 siblings, 0 replies; 20+ messages in thread
From: Grigoropol, IoanaX @ 2013-06-07 12:19 UTC (permalink / raw)
  To: Zhang, Jessica, yocto

Neither of the actions is actually defined in the plugin.xml. If we need to support it, why aren't they enabled ?
________________________________________
From: Zhang, Jessica
Sent: Friday, June 07, 2013 2:57 AM
To: Grigoropol, IoanaX; yocto@yoctoproject.org
Subject: RE: [yocto] [Refactor RFC 4/9] Remove unused Bitbake Actions

We can't remove them, since we should support build a specific recipe as from the command line.

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: yocto@yoctoproject.org
Subject: [yocto] [Refactor RFC 4/9] Remove unused Bitbake Actions

- none of the Bitbake action classes that inherit from AbstractBitbakeCommandAction is used -> clean-up classes & plugin.xml

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 plugins/org.yocto.bc.ui/plugin.xml                 |   55 ------
 .../ui/actions/AbstractBitbakeCommandAction.java   |  198 --------------------
 .../bc/ui/actions/BitbakeBuildRecipeAction.java    |   24 ---
 .../bc/ui/actions/BitbakeCleanRecipeAction.java    |   26 ---
 .../yocto/bc/ui/actions/BitbakeImportAction.java   |  106 -----------
 .../bc/ui/actions/BitbakeRebuildRecipeAction.java  |   29 ---
 6 files changed, 438 deletions(-)
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java

diff --git a/plugins/org.yocto.bc.ui/plugin.xml b/plugins/org.yocto.bc.ui/plugin.xml
index cb0561c..2e1421f 100644
--- a/plugins/org.yocto.bc.ui/plugin.xml
+++ b/plugins/org.yocto.bc.ui/plugin.xml
@@ -39,61 +39,6 @@
             commandId="org.yocto.bc.ui.command.launchHob">
       </handler>
    </extension>
-   <!--
-   <extension
-         point="org.eclipse.ui.popupMenus">
-      <objectContribution
-            adaptable="true"
-            id="org.yocto.bc.ui.contribution2"
-            nameFilter="*.bb"
-            objectClass="org.eclipse.core.resources.IFile">
-         <action
-               class="org.yocto.bc.ui.actions.BitbakeBuildRecipeAction"
-               enablesFor="+"
-               icon="icons/binary.gif"
-               id="org.yocto.bc.ui.BuildPackagePopupAction"
-               label="Build"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Build a package">
-         </action>
-               <action
-               class="org.yocto.bc.ui.actions.BitbakeCleanRecipeAction"
-               enablesFor="+"
-               icon="icons/trash.gif"
-               id="org.yocto.bc.ui.CleanPackagePopupAction"
-               label="Clean"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Clean a package">
-         </action>
-         <action
-               class="org.yocto.bc.ui.actions.BitbakeImportAction"
-               enablesFor="+"
-               icon="icons/import_wiz.gif"
-               id="org.yocto.bc.ui.BitbakeImportPopupAction"
-               label="Import"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Import package sources as Eclipse project.">
-         </action>
-         <menu
-               id="org.yocto.bc.ui.menu1"
-               label="BitBake"
-               path="additions">
-            <separator
-                  name="bc.separator1">
-            </separator>
-         </menu>
-         <action
-               class="org.yocto.bc.ui.actions.BitbakeRebuildRecipeAction"
-               enablesFor="+"
-               icon="icons/refresh.gif"
-               id="org.yocto.bc.ui.BuildPackagePopupAction"
-               label="Rebuild"
-               menubarPath="org.yocto.bc.ui.menu1/group1"
-               tooltip="Rebuild a package">
-         </action>
-     </objectContribution>
-   </extension>
-   -->
    <extension
          point="org.eclipse.ui.menus">
       <menuContribution
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
deleted file mode 100644
index cd4f4c9..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IAction; -import org.eclipse.jface.preference.JFacePreferences;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.console.MessageConsole;
-import org.eclipse.ui.console.MessageConsoleStream;
-import org.yocto.bc.bitbake.BBLanguageHelper;
-import org.yocto.bc.bitbake.BBSession;
-import org.yocto.bc.ui.Activator;
-import org.yocto.bc.ui.builder.BitbakeCommanderNature;
-import org.yocto.remote.utils.ICommandResponseHandler;
-
-public abstract class AbstractBitbakeCommandAction implements IWorkbenchWindowActionDelegate {
-
-       private class CommandJob extends Job {
-
-               public CommandJob() {
-                       super(getJobTitle());
-               }
-
-               @Override
-               protected IStatus run(IProgressMonitor monitor) {
-                       String cmds[] = getCommands();
-                       return execCommands(cmds, monitor);
-               }
-
-       }
-       protected IAction action;
-       protected IFile recipe;
-       protected BBSession bbs;
-
-       private Color commandColor, responseColor, errorColor;
-       private boolean errorOccurred = false;
-
-       public AbstractBitbakeCommandAction() {
-               commandColor = JFaceResources.getColorRegistry().get(JFacePreferences.ACTIVE_HYPERLINK_COLOR);
-               responseColor = JFaceResources.getColorRegistry().get(JFacePreferences.HYPERLINK_COLOR);
-               errorColor = JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR);
-       }
-
-       private void checkEnabled(IFile file) {
-               try {
-                       if (file.getFileExtension() == null || !file.getFileExtension().equals(BBLanguageHelper.BITBAKE_RECIPE_FILE_EXTENSION)) {
-                               action.setEnabled(false);
-                               return;
-                       }
-
-                       IProject project = file.getProject();
-                       if (!(project.hasNature(BitbakeCommanderNature.NATURE_ID))) {
-                               action.setEnabled(false);
-                               return;
-                       }
-
-                       bbs = Activator.getBBSession(project.getLocationURI().getPath());
-
-                       if (bbs != null) {
-                               recipe = file;
-                               action.setEnabled(true);
-                       }
-
-               } catch (CoreException e) {
-                       action.setEnabled(false);
-                       e.printStackTrace();
-               } catch (Exception e) {
-                       action.setEnabled(false);
-                       e.printStackTrace();
-               }
-       }
-
-       public void dispose() {
-       }
-
-       /**
-        * Execute array of commands with bitbake and put output in console.
-        *
-        * @param cmds
-        * @param monitor
-        * @return
-        */
-       protected IStatus execCommands(String[] cmds, final IProgressMonitor monitor) {
-               MessageConsole mc = bbs.getConsole();
-               final MessageConsoleStream cmd = mc.newMessageStream();
-               cmd.setColor(commandColor);
-               final MessageConsoleStream out = mc.newMessageStream();
-               final MessageConsoleStream err = mc.newMessageStream();
-               err.setColor(errorColor);
-
-               try {
-                       for (int i = 0; i < cmds.length; ++i) {
-                               cmd.println(cmds[i]);
-                               monitor.subTask(cmds[i]);
-                               bbs.getShell().execute(cmds[i], new ICommandResponseHandler() {
-
-                                       public void response(String line, boolean isError) {
-                                               if (monitor.isCanceled()) {
-                                                       cmd.println("Interrupting process by user request.");
-                                                       bbs.getShell().interrupt();
-                                               }
-
-                                               if (isError) {
-                                                       err.println(line);
-                                                       errorOccurred();
-                                               } else if (line.startsWith("ERROR:")) {
-                                                       err.println(line);
-                                               } else {
-                                                       out.println(line);
-                                               }
-                                       }
-                               });
-                       }
-               } catch (IOException e) {
-                       return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
-               } finally {
-                       try {
-                               if (errorOccurred) {
-                                       cmd.println("At least one error occured while executing this command.  Check output for more details.");
-                               }
-                               cmd.close();
-                               out.close();
-                               err.close();
-                       } catch (IOException e) {
-                               e.printStackTrace();
-                       }
-               }
-
-               return Status.OK_STATUS;
-       }
-
-       protected void errorOccurred() {
-               errorOccurred = true;
-       }
-
-       /**
-        * Return the command to be executed.
-        *
-        * @return
-        */
-       public abstract String[] getCommands();
-
-       public Job getJob() {
-               return new CommandJob();
-       }
-
-       /**
-        * Return the title of the job.
-        *
-        * @return
-        */
-       public abstract String getJobTitle();
-
-       public void init(IWorkbenchWindow window) {
-       }
-
-       public void run(IAction action) {
-               Job job = getJob();
-               job.schedule();
-       }
-
-       public void selectionChanged(IAction action, ISelection selection) {
-               this.action = action;
-               if (selection instanceof IStructuredSelection) {
-                       Object sel = ((IStructuredSelection) selection).getFirstElement();
-
-                       if (sel instanceof IFile) {
-                               checkEnabled((IFile) sel);
-                               return;
-                       }
-               }
-
-               action.setEnabled(false);
-       }
-
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java
deleted file mode 100644
index 22ac94c..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-public  class BitbakeBuildRecipeAction extends AbstractBitbakeCommandAction {
-
-       @Override
-       public String [] getCommands() {
-               return new String[] {"bitbake -b " + recipe.getLocationURI().getPath()};
-       }
-
-       @Override
-       public String getJobTitle() {
-               return "Building " + recipe.getName();
-       }
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java
deleted file mode 100644
index f95117e..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-public class BitbakeCleanRecipeAction extends AbstractBitbakeCommandAction {
-
-       @Override
-       public String [] getCommands() {
-               return new String[] {"bitbake -c clean -b " + recipe.getLocationURI().getPath()};
-       }
-
-       @Override
-       public String getJobTitle() {
-               return "Cleaning " + recipe.getName();
-       }
-
-
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java
deleted file mode 100644
index ecceecf..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job;
-
-import org.yocto.bc.bitbake.BBCommonVars;
-import org.yocto.bc.bitbake.BBRecipe;
-import org.yocto.bc.ui.Activator;
-
-public  class BitbakeImportAction extends AbstractBitbakeCommandAction {
-
-       private class ImportJob extends Job {
-
-               public ImportJob() {
-                       super(getJobTitle());
-               }
-
-               @Override
-               protected IStatus run(IProgressMonitor monitor) {
-
-                       try {
-                               BBRecipe br = new BBRecipe(bbs, recipe.getLocationURI().getPath());
-                               br.initialize();
-                               String filePath = (String) br.get(BBCommonVars.S);
-
-                               //"${WORKDIR}/${PN}-${PV}"
-                               if (filePath == null) {
-                                       filePath = ((String) br.get(BBCommonVars.WORKDIR)) + File.separator + ((String) br.get(BBCommonVars.PN)) + "-" + ((String) br.get(BBCommonVars.PV));
-                               }
-
-                               String projectName = (String) br.get(BBCommonVars.PN);
-
-                               if (filePath == null || projectName == null) {
-                                       return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to parse recipe file.");
-                               }
-
-                               File workdir = new File(filePath);
-
-                               if (workdir.exists() && workdir.isFile()) {
-                                       return new Status(IStatus.ERROR, Activator.PLUGIN_ID, workdir.getPath() + " is an invalid workdir.");
-                               }
-
-                               if (!workdir.exists()) {
-                                       execCommands(new String[] {"bitbake -c patch -b " + recipe.getLocationURI().getPath()}, monitor);
-                               }
-
-                               if (!workdir.exists()) {
-                                       return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to retrieve sources from BitBake.  Consult console.");
-                               }
-
-                               IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
-                               IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
-                               IProject proj = wsroot.getProject(projectName);
-                               proj.create(desc, monitor);
-                               proj.open(monitor);
-
-                               String copyCmd = "cp -r " + workdir.getAbsolutePath() + File.separator + "* \"" + proj.getLocationURI().getPath() + "\"";
-                               execCommands(new String[] {copyCmd} , monitor);
-
-                               proj.refreshLocal(IResource.DEPTH_INFINITE, monitor);
-
-                       } catch (Exception e) {
-                               e.printStackTrace();
-                               return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to create project.", e);
-                       }
-
-                       return Status.OK_STATUS;
-               }
-
-       }
-
-       @Override
-       public String [] getCommands() {
-               return null;
-       }
-
-
-       @Override
-       public Job getJob() {
-               return new ImportJob();
-       }
-
-       @Override
-       public String getJobTitle() {
-               return "Importing " + recipe.getName();
-       }
-}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java
deleted file mode 100644
index c5dedea..0000000
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Ken Gilmer
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Ken Gilmer - initial API and implementation
- *******************************************************************************/
-package org.yocto.bc.ui.actions;
-
-/**
- * Rebuild a recipe.
- * @author kgilmer
- *
- */
-public  class BitbakeRebuildRecipeAction extends AbstractBitbakeCommandAction {
-
-       @Override
-       public String [] getCommands() {
-               return new String[] {"bitbake -c rebuild -b " + recipe.getLocationURI().getPath()};
-       }
-
-       @Override
-       public String getJobTitle() {
-               return "Rebuilding " + recipe.getName();
-       }
-}
\ No newline at end of file
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities
  2013-06-06 23:53   ` Zhang, Jessica
@ 2013-06-07 15:29     ` Grigoropol, IoanaX
  0 siblings, 0 replies; 20+ messages in thread
From: Grigoropol, IoanaX @ 2013-06-07 15:29 UTC (permalink / raw)
  To: Zhang, Jessica, yocto

Hi Jessica,

I have sent you a set of 8 patches that replaces the second patch (2/9). I have added the new classes incrementally and put the changes to the RemoteHelper along with the classes that are strongly linked with it.
I have also sent a pull request for the whole set of patches(50). They can be found also on poky-contrib: igrigorx/common-remote-refactor.

Thanks,
Ioana 
________________________________________
From: Zhang, Jessica
Sent: Friday, June 07, 2013 2:53 AM
To: Grigoropol, IoanaX; yocto@yoctoproject.org
Subject: RE: [yocto] [Refactor RFC 2/9] Add remote tools classes needed for     bitbake remote capabilities

Hi Ioana,

Please separate this into 2 patches, one is for adding those new util files and also please add License for them.  Then make the RemoteHelper.java into a separate patch.  Other comments are:

1.please add much more detailed information in your patch to explain why we need new util classes and why RemoteHelper.java need to be changed.
2. there're many new functions that using IHost variable and you don't need to check for IHost is null case?

Thanks
Jessica

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: yocto@yoctoproject.org
Subject: [yocto] [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../org.yocto.remote.utils/META-INF/MANIFEST.MF    |    8 +-
 .../yocto/remote/utils/CommandOutputProcessor.java |   33 +++
 .../yocto/remote/utils/CommandResponseHandler.java |   36 +++
 .../org/yocto/remote/utils/CommandRunnable.java    |   34 +++
 .../src/org/yocto/remote/utils/ConsoleHelper.java  |   28 +++
 .../org/yocto/remote/utils/ConsoleRunnable.java    |   37 +++
 .../remote/utils/ICommandResponseHandler.java      |   15 ++
 .../org/yocto/remote/utils/OutputProcessor.java    |  102 ++++++++
 .../yocto/remote/utils/ProcessStreamBuffer.java    |   77 ++++++
 .../src/org/yocto/remote/utils/RemoteHelper.java   |  255 ++++++++++++++++----
 .../src/org/yocto/remote/utils/RemoteMachine.java  |  206 ++++++++++++++++
 .../src/org/yocto/remote/utils/Session.java        |  117 +++++++++
 .../src/org/yocto/remote/utils/YoctoCommand.java   |   53 ++++
 13 files changed, 952 insertions(+), 49 deletions(-)  create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java
 create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java

diff --git a/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF b/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF
index c7b57fe..06d14f8 100644
--- a/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF
+++ b/plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF
@@ -11,17 +11,23 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Import-Package: org.eclipse.rse.core,
  org.eclipse.rse.core.model,
  org.eclipse.rse.core.subsystems,
+ org.eclipse.rse.internal.services.local.shells,
+ org.eclipse.rse.internal.services.shells,
  org.eclipse.rse.internal.terminals.ui,
  org.eclipse.rse.internal.terminals.ui.views,
  org.eclipse.rse.services,
+ org.eclipse.rse.services.clientserver.messages,
  org.eclipse.rse.services.files,
  org.eclipse.rse.services.shells,
  org.eclipse.rse.services.terminals,
+ org.eclipse.rse.subsystems.files.core.model,
  org.eclipse.rse.subsystems.files.core.servicesubsystem,
+ org.eclipse.rse.subsystems.files.core.subsystems,
  org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem,
  org.eclipse.rse.subsystems.terminals.core,
  org.eclipse.rse.subsystems.terminals.core.elements,
  org.eclipse.rse.ui,
  org.eclipse.tm.internal.terminal.control,
- org.eclipse.tm.internal.terminal.provisional.api
+ org.eclipse.tm.internal.terminal.provisional.api,
+ org.eclipse.ui.console
 Export-Package: org.yocto.remote.utils
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java
new file mode 100644
index 0000000..4fca662
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandO
+++ utputProcessor.java
@@ -0,0 +1,33 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.services.shells.IHostShell;
+
+public class CommandOutputProcessor extends OutputProcessor {
+
+       public CommandOutputProcessor(IProgressMonitor monitor,
+                       IHostShell hostShell, CommandResponseHandler cmdHandler, String task) {
+               super(monitor, hostShell, cmdHandler, task);
+       }
+
+       @Override
+       protected boolean isErrChStop(char ch) {
+               return (ch == '\n');
+       }
+
+       @Override
+       protected boolean isOutChStop(char ch) {
+               return (ch == '\n');
+       }
+
+       @Override
+       protected void processOutputBufferLine(char ch, String str) {
+               processBuffer.addOutputLine(str);
+       }
+
+       @Override
+       protected void processErrorBufferLine(char ch, String str) {
+               processBuffer.addErrorLine(str);
+       }
+
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java
new file mode 100644
index 0000000..0785c45
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandR
+++ esponseHandler.java
@@ -0,0 +1,36 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
+
+public class CommandResponseHandler implements ICommandResponseHandler {
+       private MessageConsoleStream consoleStream;
+       private Boolean errorOccured = false;
+
+       public CommandResponseHandler(MessageConsole console) {
+               try {
+                       this.consoleStream = console.newMessageStream();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public Boolean hasError() {
+               return errorOccured;
+       }
+
+       @Override
+       public void response(String line, boolean isError) {
+               try {
+                       if (isError) {
+                               consoleStream.println(line);
+                               errorOccured = true;
+                       } else {
+                               consoleStream.println(line);
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+}
\ No newline at end of file
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java
new file mode 100644
index 0000000..46a3f35
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandR
+++ unnable.java
@@ -0,0 +1,34 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.core.model.IHost; import
+org.eclipse.rse.services.shells.IHostShell;
+
+public class CommandRunnable implements Runnable{
+       private IHostShell hostShell;
+       private final IHost connection;
+       private final YoctoCommand cmd;
+       private final IProgressMonitor monitor;
+       private final CommandResponseHandler cmdHandler;
+
+       CommandRunnable(IHost connection, YoctoCommand cmd, IProgressMonitor monitor){
+               this.connection = connection;
+               this.cmdHandler = RemoteHelper.getCommandHandler(connection);
+               this.cmd = cmd;
+               this.monitor = monitor;
+               this.hostShell = null;
+       }
+       @Override
+       public void run() {
+               try {
+                       hostShell = RemoteHelper.runCommandRemote(connection, cmd, monitor);
+                       cmd.setProcessBuffer(RemoteHelper.processOutput(monitor, hostShell, cmdHandler));
+               } catch (CoreException e) {
+                       e.printStackTrace();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java
new file mode 100644
index 0000000..307e219
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleH
+++ elper.java
@@ -0,0 +1,28 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.swt.widgets.Display; import
+org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole; import
+org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.MessageConsole;
+
+public class ConsoleHelper {
+       public static final String YOCTO_CONSOLE = "Yocto Project Console";
+
+       public static MessageConsole findConsole(String name) {
+               ConsolePlugin plugin = ConsolePlugin.getDefault();
+               IConsoleManager conMan = plugin.getConsoleManager();
+               IConsole[] existing = conMan.getConsoles();
+               for (int i = 0; i < existing.length; i++)
+                       if (name.equals(existing[i].getName()))
+                               return (MessageConsole) existing[i];
+               // no console found, so create a new one
+               MessageConsole myConsole = new MessageConsole(name, null);
+               conMan.addConsoles(new IConsole[] { myConsole });
+               return myConsole;
+       }
+
+       public static void showConsole(MessageConsole console){
+               Display.getDefault().syncExec(new ConsoleRunnable(console));
+       }
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java
new file mode 100644
index 0000000..f3b0ccd
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleR
+++ unnable.java
@@ -0,0 +1,37 @@
+package org.yocto.remote.utils;
+
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow; import
+org.eclipse.ui.PlatformUI; import
+org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleView;
+import org.eclipse.ui.console.MessageConsole;
+
+public class ConsoleRunnable implements Runnable{
+       MessageConsole console;
+       ConsoleRunnable (MessageConsole console){
+               this.console = console;
+       }
+       @Override
+       public void run() {
+               IWorkbench wb = PlatformUI.getWorkbench();
+               if (wb == null)
+                       return;
+               IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
+               if (win == null)
+                       return;
+               IWorkbenchPage page = win.getActivePage();
+               if (page == null)
+                       return;
+               String id = IConsoleConstants.ID_CONSOLE_VIEW;
+               try {
+                       IConsoleView view = (IConsoleView) page.showView(id);
+                       if (view == null)
+                               return;
+                       view.display(console);
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+}
\ No newline at end of file
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java
new file mode 100644
index 0000000..a8a8f95
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommand
+++ ResponseHandler.java
@@ -0,0 +1,15 @@
+/**********************************************************************
+*******
+ * Copyright (c) 2009 Ken Gilmer
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License
+v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Ken Gilmer - initial API and implementation
+
+***********************************************************************
+********/
+package org.yocto.remote.utils;
+
+public interface ICommandResponseHandler {
+       public void response(String line, boolean isError); }
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java
new file mode 100644
index 0000000..a06f077
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputPr
+++ ocessor.java
@@ -0,0 +1,102 @@
+package org.yocto.remote.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.concurrent.locks.Lock;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.internal.services.local.shells.LocalHostShell;
+import
+org.eclipse.rse.internal.services.shells.TerminalServiceHostShell;
+import org.eclipse.rse.services.shells.HostShellProcessAdapter;
+import org.eclipse.rse.services.shells.IHostShell;
+
+public abstract class OutputProcessor{
+       private static final int ERROR_BUFFER = 1;
+       private static final int OUTPUT_BUFFER = 2;
+       protected String task;
+       protected ProcessStreamBuffer processBuffer;
+       protected IHostShell hostShell;
+       protected CommandResponseHandler cmdHandler;
+       protected IProgressMonitor monitor;
+
+       public OutputProcessor(IProgressMonitor monitor, IHostShell hostShell, CommandResponseHandler cmdHandler, String task){
+               this.monitor = monitor;
+               this.hostShell = hostShell;
+               this.processBuffer = new ProcessStreamBuffer(hostShell instanceof TerminalServiceHostShell);
+               this.cmdHandler = cmdHandler;
+               this.task = task;
+       }
+       public ProcessStreamBuffer processOutput() throws Exception{
+               if (hostShell == null)
+                       throw new Exception("An error has occured while trying to run remote command!");
+               monitor.beginTask(this.task, RemoteHelper.TOTALWORKLOAD);
+               Lock lock = null;
+               if (hostShell instanceof LocalHostShell) {
+                       lock = ((LocalHostShell)hostShell).getLock();
+                       lock.lock();
+               }
+               BufferedReader inbr = null;
+               BufferedReader errbr = null;
+
+               if (hostShell instanceof LocalHostShell) {
+                       inbr = ((LocalHostShell)hostShell).getReader(false);
+                       errbr = ((LocalHostShell)hostShell).getReader(true);
+               } else {
+                       Process p = new HostShellProcessAdapter(hostShell);
+                       inbr = new BufferedReader(new InputStreamReader(p.getInputStream()));
+                       errbr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+               }
+               boolean cancel = false;
+               while (!cancel) {
+                       if(monitor.isCanceled()) {
+                               cancel = true;
+                               if (lock != null)
+                                       lock.unlock();
+                               throw new InterruptedException("User Cancelled");
+                       }
+                       processBuffer(errbr, ERROR_BUFFER);
+                       processBuffer(inbr, OUTPUT_BUFFER);
+                       cancel = true;
+               }
+               if (lock != null)
+                       lock.unlock();
+               return processBuffer;
+       }
+       protected abstract boolean isErrChStop(char ch);
+       protected abstract boolean isOutChStop(char ch);
+       protected boolean isChStop(char ch, int type){
+               if (type == ERROR_BUFFER)
+                       return isErrChStop(ch);
+               else if(type == OUTPUT_BUFFER)
+                       return isOutChStop(ch);
+               return false;
+       }
+       protected abstract void processOutputBufferLine(char ch, String str);
+       protected abstract void processErrorBufferLine(char ch, String str);
+       protected void processBufferLine(String str, char ch, int type){
+               if (type == ERROR_BUFFER)
+                       processErrorBufferLine(ch, str);
+               else if(type == OUTPUT_BUFFER)
+                       processOutputBufferLine(ch, str);
+       }
+       protected void processBuffer(BufferedReader br, int type) throws IOException{
+               StringBuffer buffer = new StringBuffer();
+               int c;
+               if (br != null)
+               while ((c = br.read()) != -1) {
+                       char ch = (char) c;
+                       buffer.append(ch);
+                       if (isChStop(ch, type)){
+                               String str = buffer.toString();
+                               processBufferLine(str, ch, type);
+                               System.out.println(str);
+                               if (str.trim().equals(RemoteHelper.TERMINATOR)) {
+                                       break;
+                               }
+                               cmdHandler.response(str, false);
+                               buffer.delete(0, buffer.length());
+                       }
+               }
+       }
+}
\ No newline at end of file
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java
new file mode 100644
index 0000000..3fe8731
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessS
+++ treamBuffer.java
@@ -0,0 +1,77 @@
+package org.yocto.remote.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class ProcessStreamBuffer {
+       private static final String WHITESPACES = "\\s+";
+       List<String> errorLines;
+       List<String> outputLines;
+       boolean isTerminal;
+
+       ProcessStreamBuffer(boolean isTerminal){
+               this.isTerminal = isTerminal;
+               errorLines = new ArrayList<String>();
+               outputLines = new ArrayList<String>();
+       }
+
+       public void addErrorLine(String line){
+               errorLines.add(line);
+       }
+       public void addOutputLine(String line){
+               outputLines.add(line);
+       }
+
+       public List<String> getOutputLines(){
+               return outputLines;
+       }
+
+       public List<String> getErrorLines(){
+               return errorLines;
+       }
+
+       public String getMergedOutputLines(){
+               String returnVal = "";
+               for (int i = 0; i < outputLines.size(); i++) {
+                       String line = outputLines.get(i);
+                       returnVal += line;
+                       if (outputLines.size() > 1 && i != outputLines.size() - 1)
+                               returnVal += "\n";
+               }
+               return returnVal;
+       }
+
+       public boolean hasErrors() {
+               return errorLines.size() != 0;
+       }
+
+       public String getLastOutputLineContaining(String str) {
+               if (!errorLines.isEmpty())
+                       return null;
+               for (int i = outputLines.size() - 1; i >= 0; i--){
+                       String line = outputLines.get(i);
+                       if (line.replaceAll(WHITESPACES, "").contains(str.replaceAll(WHITESPACES, "")))
+                               return line;
+               }
+               return null;
+       }
+
+       public String getOutputLineContaining(String arg, String pattern) {
+               List<String> lines = null;
+               if (isTerminal)
+                       lines = errorLines;
+               else
+                       lines = outputLines;
+               for (int i = lines.size() - 1; i >= 0; i--){
+                       String line = lines.get(i);
+                       if (line.contains(arg)) {
+                               String[] tokens = line.split("\\s+");
+                               if (Pattern.matches(pattern,  tokens[0])) {
+                                       return tokens[0];
+                               }
+                       }
+               }
+               return "";
+       }
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java
index a1e9a08..e9118d6 100644
--- a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHe
+++ lper.java
@@ -16,16 +16,19 @@ import java.io.BufferedOutputStream;  import java.io.File;  import java.io.FileOutputStream;  import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;

 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;  import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;  import org.eclipse.core.runtime.SubProgressMonitor;
@@ -38,17 +41,26 @@ import org.eclipse.rse.core.model.ISubSystemConfigurationCategories;
 import org.eclipse.rse.core.model.ISystemRegistry;
 import org.eclipse.rse.core.subsystems.ISubSystem;
 import org.eclipse.rse.services.IService;
+import
+org.eclipse.rse.services.clientserver.messages.SystemMessageException;
 import org.eclipse.rse.services.files.IFileService;
+import org.eclipse.rse.services.files.IHostFile;
 import org.eclipse.rse.services.shells.HostShellProcessAdapter;
 import org.eclipse.rse.services.shells.IHostShell;
 import org.eclipse.rse.services.shells.IShellService;
+import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
+import
+org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSy
+stem;
 import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+import
+org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
 import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem;
 import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem;
+import org.eclipse.ui.console.MessageConsole;

 public class RemoteHelper {
        private final static String EXIT_CMD = "exit"; //$NON-NLS-1$
        private final static String CMD_DELIMITER = ";"; //$NON-NLS-1$
+       public static final String TERMINATOR = "234o987dsfkcqiuwey18837032843259d";//$NON-NLS-1$
+       public static final int TOTALWORKLOAD = 100;
+       private static Map<IHost, RemoteMachine> machines;

        public static IHost getRemoteConnectionByName(String remoteConnection) {
                if (remoteConnection == null)
@@ -57,30 +69,7 @@ public class RemoteHelper {
                for (int i = 0; i < connections.length; i++)
                        if (connections[i].getAliasName().equals(remoteConnection))
                                return connections[i];
-               return null; // TODO Connection is not found in the list--need to react
-               // somehow, throw the exception?
-
-       }
-
-       public static IService getConnectedRemoteFileService(
-                       IHost currentConnection, IProgressMonitor monitor) throws Exception {
-               final ISubSystem subsystem = getFileSubsystem(currentConnection);
-
-               if (subsystem == null)
-                       throw new Exception(Messages.ErrorNoSubsystem);
-
-               try {
-                       subsystem.connect(monitor, false);
-               } catch (CoreException e) {
-                       throw e;
-               } catch (OperationCanceledException e) {
-                       throw new CoreException(Status.CANCEL_STATUS);
-               }
-
-               if (!subsystem.isConnected())
-                       throw new Exception(Messages.ErrorConnectSubsystem);
-
-               return ((IFileServiceSubSystem) subsystem).getFileService();
+               return null;
        }

        public static ISubSystem getFileSubsystem(IHost host) { @@ -94,27 +83,6 @@ public class RemoteHelper {
                return null;
        }

-       public static IService getConnectedShellService(
-                       IHost currentConnection, IProgressMonitor monitor) throws Exception {
-               final ISubSystem subsystem = getShellSubsystem(currentConnection);
-
-               if (subsystem == null)
-                       throw new Exception(Messages.ErrorNoSubsystem);
-
-               try {
-                       subsystem.connect(monitor, false);
-               } catch (CoreException e) {
-                       throw e;
-               } catch (OperationCanceledException e) {
-                       throw new CoreException(Status.CANCEL_STATUS);
-               }
-
-               if (!subsystem.isConnected())
-                       throw new Exception(Messages.ErrorConnectSubsystem);
-
-               return ((IShellServiceSubSystem) subsystem).getShellService();
-       }
-
        public static ISubSystem getShellSubsystem(IHost host) {
                if (host == null)
                        return null;
@@ -161,7 +129,7 @@ public class RemoteHelper {

                IFileService fileService;
                try {
-                       fileService = (IFileService) getConnectedRemoteFileService(
+                       fileService = getConnectedRemoteFileService(
                                                        connection,
                                                        new SubProgressMonitor(monitor, 5));
                        InputStream  inputStream = FileLocator.openStream( @@ -204,7 +172,7 @@ public class RemoteHelper {

                IFileService fileService;
                try {
-                       fileService = (IFileService) getConnectedRemoteFileService(
+                       fileService = getConnectedRemoteFileService(
                                                        connection,
                                                        new SubProgressMonitor(monitor, 10));
                        File file = new File(localExePath);
@@ -341,4 +309,195 @@ public class RemoteHelper {
                                return;
                        }
        }
+       public static RemoteMachine getRemoteMachine(IHost connection){
+               if (!getMachines().containsKey(connection))
+                       getMachines().put(connection, new RemoteMachine(connection));
+               return getMachines().get(connection);
+       }
+
+       private static Map<IHost, RemoteMachine> getMachines() {
+               if (machines == null)
+                       machines = new HashMap<IHost, RemoteMachine>();
+               return machines;
+       }
+
+       public static MessageConsole getConsole(IHost connection) {
+               return getRemoteMachine(connection).getConsole();
+       }
+
+       public static CommandResponseHandler getCommandHandler(IHost connection) {
+               return getRemoteMachine(connection).getCmdHandler();
+       }
+
+       public static ProcessStreamBuffer processOutput(IProgressMonitor monitor, IHostShell hostShell, CommandResponseHandler cmdHandler) throws Exception {
+               return new CommandOutputProcessor(monitor, hostShell, cmdHandler, "").processOutput();
+       }
+
+       public static IHost getRemoteConnectionForURI(URI uri, IProgressMonitor monitor) {
+               if (uri == null)
+                       return null;
+
+               String host = uri.getHost();
+               if (host == null) {
+                       // this is a local connection
+                       ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
+                       IHost local = null;
+                       while (local == null) {
+                               local = sr.getLocalHost();
+                       }
+                       return local;
+               }
+               ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
+               IHost[] connections = sr.getHosts();
+
+               IHost unconnected = null;
+               for (IHost conn : connections) {
+                       if (host.equalsIgnoreCase(conn.getHostName())) {
+                               IRemoteFileSubSystem fss = getRemoteFileSubSystem(conn);
+                               if (fss != null && fss.isConnected())
+                                       return conn;
+                               unconnected = conn;
+                       }
+               }
+
+               return unconnected;
+       }
+
+       public static IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) {
+               IRemoteFileSubSystem candidate = null;
+               IRemoteFileSubSystem otherServiceCandidate = null;
+               IRemoteFileSubSystem[] subSystems =
+RemoteFileUtility.getFileSubSystems(host);
+
+               for (IRemoteFileSubSystem subSystem : subSystems) {
+                       if (subSystem instanceof FileServiceSubSystem) {
+                               if (subSystem.isConnected())
+                                       return subSystem;
+
+                               if (otherServiceCandidate == null)
+                                       otherServiceCandidate = subSystem;
+
+                       } else if (candidate == null || (subSystem.isConnected() && !candidate.isConnected()))
+                               candidate = subSystem;
+
+               }
+               if (candidate != null && candidate.isConnected())
+                       return candidate;
+               if (otherServiceCandidate != null)
+                       return otherServiceCandidate;
+               return null;
+       }
+
+       public static IFileService getConnectedRemoteFileService(IHost connection, IProgressMonitor monitor) throws Exception {
+               return getRemoteMachine(connection).getRemoteFileService(monitor);
+       }
+
+       public static IHostFile[] getRemoteDirContent(IHost connection, String
+remoteParent, String fileFilter, int fileType, IProgressMonitor
+monitor){
+
+               try {
+                       IFileService fileServ = getConnectedRemoteFileService(connection, monitor);
+                       return fileServ.list(remoteParent, fileFilter, fileType, monitor);
+               } catch (SystemMessageException e) {
+                       e.printStackTrace();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               return null;
+       }
+
+       public static IService getConnectedShellService(IHost connection, IProgressMonitor monitor) throws Exception {
+               return getRemoteMachine(connection).getShellService(monitor);
+       }
+
+       public static void handleRunCommandRemote(IHost connection, YoctoCommand cmd, IProgressMonitor monitor){
+               try {
+                       CommandRunnable cmdRun = new CommandRunnable(connection, cmd, monitor);
+                       cmdRun.run();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public static IHostShell runCommandRemote(IHost connection, YoctoCommand cmd,
+                       IProgressMonitor monitor) throws CoreException {
+
+               monitor.beginTask(NLS.bind(Messages.RemoteShellExec_1,
+                               cmd, cmd.getArguments()), 10);
+
+               String remoteCommand = cmd.getCommand() + " " + cmd.getArguments() +
+" ; echo " + TERMINATOR + "; exit ;";
+
+               IShellService shellService;
+               try {
+                       shellService = (IShellService) getConnectedShellService(connection,
+new SubProgressMonitor(monitor, 7));
+
+                       String env[] =
+getRemoteMachine(connection).prepareEnvString(monitor);
+
+                       try {
+                               IHostShell hostShell = shellService.runCommand(cmd.getInitialDirectory(), remoteCommand, env, new SubProgressMonitor(monitor, 3));
+                               return hostShell;
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       }
+               } catch (Exception e1) {
+                       e1.printStackTrace();
+               }
+               return null;
+       }
+
+       public static IHostFile getRemoteHostFile(IHost connection, String remoteFilePath, IProgressMonitor monitor){
+               assert(connection != null);
+               monitor.beginTask(Messages.InfoDownload, 100);
+
+               try {
+                       IFileService fileService = getConnectedRemoteFileService(connection, new SubProgressMonitor(monitor, 10));
+                       Path remotePath = new Path(remoteFilePath);
+                       IHostFile remoteFile = fileService.getFile(remotePath.removeLastSegments(1).toString(), remotePath.lastSegment(), new SubProgressMonitor(monitor, 5));
+                       return remoteFile;
+               } catch (Exception e) {
+                       e.printStackTrace();
+           }finally {
+                       monitor.done();
+               }
+               return null;
+       }
+
+       public static InputStream getRemoteInputStream(IHost connection, String parentPath, String remoteFilePath, IProgressMonitor monitor){
+               assert(connection != null);
+               monitor.beginTask(Messages.InfoDownload, 100);
+
+               try {
+                       IFileService fileService = getConnectedRemoteFileService(connection,
+new SubProgressMonitor(monitor, 10));
+
+                       return fileService.getInputStream(parentPath, remoteFilePath, false, monitor);
+               } catch (Exception e) {
+                       e.printStackTrace();
+           }finally {
+                       monitor.done();
+               }
+               return null;
+       }
+
+       public static URI createNewURI(URI oldURI, String name) {
+               try {
+                       String sep = oldURI.getPath().endsWith("/") ? "" : "/";
+                       return new URI(oldURI.getScheme(), oldURI.getHost(), oldURI.getPath() + sep + name, oldURI.getFragment());
+               } catch (URISyntaxException e) {
+                       e.printStackTrace();
+                       return null;
+               }
+       }
+
+       public static boolean fileExistsRemote(IHost conn, IProgressMonitor monitor, String path) {
+               try {
+                       IFileService fs = getConnectedRemoteFileService(conn, monitor);
+                       int nameStart = path.lastIndexOf("/");
+                       String parentPath = path.substring(0, nameStart);
+                       String name = path.substring(nameStart + 1);
+                       IHostFile hostFile = fs.getFile(parentPath, name, monitor);
+
+                       return hostFile.exists();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               return false;
+       }
 }
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java
new file mode 100644
index 0000000..123a972
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMa
+++ chine.java
@@ -0,0 +1,206 @@
+package org.yocto.remote.utils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status; import
+org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.rse.core.model.IHost; import
+org.eclipse.rse.core.subsystems.ISubSystem;
+import
+org.eclipse.rse.internal.services.local.shells.LocalShellService;
+import
+org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.rse.services.files.IFileService;
+import org.eclipse.rse.services.shells.IHostShell;
+import org.eclipse.rse.services.shells.IShellService;
+import
+org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubS
+ystem; import
+org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShe
+llServiceSubSystem; import org.eclipse.ui.console.MessageConsole;
+
+public class RemoteMachine {
+       public static final String PROXY = "proxy";
+
+       private Map<String, String> environment;
+       private MessageConsole console;
+       private CommandResponseHandler cmdHandler;
+       private IHostShell hostShell;
+       private IShellService shellService;
+       private IHost connection;
+
+       private ISubSystem fileSubSystem;
+       private IFileService fileService;
+
+       public RemoteMachine(IHost connection) {
+               setConnection(connection);
+       }
+
+       public String[] prepareEnvString(IProgressMonitor monitor){
+               String[] env = null;
+               try {
+                       if (shellService instanceof LocalShellService) {
+                               env  = shellService.getHostEnvironment();
+                       } else {
+                               List<String> envList = new ArrayList<String>();
+                               getRemoteEnvProxyVars(monitor);
+                               String value = "";
+                               for (String varName : environment.keySet()){
+                                       value = varName + "=" + environment.get(varName);
+                                       envList.add(value);
+                               }
+                               env = envList.toArray(new String[envList.size()]);
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+
+               return env;
+       }
+       public void getRemoteEnvProxyVars(IProgressMonitor monitor){
+               try {
+                       if (environment != null && !environment.isEmpty())
+                               return;
+
+                       environment = new HashMap<String, String>();
+
+                       IShellService shellService = getShellService(new
+SubProgressMonitor(monitor, 7));
+
+                       ProcessStreamBuffer buffer = null;
+                       try {
+                               SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 3);
+                               IHostShell hostShell = shellService.runCommand("", "env" + " ; echo " + RemoteHelper.TERMINATOR + "; exit;", new String[]{}, subMonitor);
+                               buffer = RemoteHelper.processOutput(subMonitor, hostShell, cmdHandler);
+                               for(int i = 0; i < buffer.getOutputLines().size(); i++) {
+                                       String out = buffer.getOutputLines().get(i);
+                                       String[] tokens = out.split("=");
+                                       if (tokens.length != 2)
+                                               continue;
+                                       String varName = tokens[0];
+                                       String varValue = tokens[1];
+                                       if (varName.contains(PROXY))
+                                               environment.put(varName, varValue);
+                               }
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       }
+
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public Map<String, String> getEnvironment() {
+               return environment;
+       }
+       public void setEnvironment(Map<String, String> environment) {
+               this.environment = environment;
+       }
+       public MessageConsole getConsole() {
+               if (console == null)
+                       console = ConsoleHelper.findConsole(ConsoleHelper.YOCTO_CONSOLE);
+
+               ConsoleHelper.showConsole(console);
+               return console;
+       }
+       public CommandResponseHandler getCmdHandler() {
+               if (cmdHandler == null)
+                       cmdHandler = new CommandResponseHandler(getConsole());
+               return cmdHandler;
+       }
+       public IHostShell getHostShell() {
+               try {
+                       if (hostShell == null) {
+                               hostShell = getShellService(new NullProgressMonitor()).launchShell("", new String[]{}, new NullProgressMonitor());
+                               prepareEnvString(new NullProgressMonitor());
+                       }
+               } catch (SystemMessageException e) {
+                       e.printStackTrace();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               return hostShell;
+       }
+
+       public IShellService getShellService(IProgressMonitor monitor) throws Exception {
+               if (shellService != null)
+                       return shellService;
+
+               final ISubSystem subsystem = getShellSubsystem();
+
+               if (subsystem == null)
+                       throw new Exception(Messages.ErrorNoSubsystem);
+
+               try {
+                       subsystem.connect(monitor, false);
+               } catch (CoreException e) {
+                       throw e;
+               } catch (OperationCanceledException e) {
+                       throw new CoreException(Status.CANCEL_STATUS);
+               }
+
+               if (!subsystem.isConnected())
+                       throw new Exception(Messages.ErrorConnectSubsystem);
+
+               shellService = ((IShellServiceSubSystem) subsystem).getShellService();
+               return shellService;
+       }
+
+       private ISubSystem getShellSubsystem() {
+               if (connection == null)
+                       return null;
+               ISubSystem[] subSystems = connection.getSubSystems();
+               for (int i = 0; i < subSystems.length; i++) {
+                       if (subSystems[i] instanceof IShellServiceSubSystem)
+                               return subSystems[i];
+               }
+               return null;
+       }
+
+       public IHost getConnection() {
+               return connection;
+       }
+       public void setConnection(IHost connection) {
+               this.connection = connection;
+       }
+
+       public IFileService getRemoteFileService(IProgressMonitor monitor) throws Exception {
+               if (fileService == null) {
+
+                       while(getFileSubsystem() == null)
+                               Thread.sleep(2);
+                       try {
+                               getFileSubsystem().connect(monitor, false);
+                       } catch (CoreException e) {
+                               throw e;
+                       } catch (OperationCanceledException e) {
+                               throw new CoreException(Status.CANCEL_STATUS);
+                       }
+
+                       if (!getFileSubsystem().isConnected())
+                               throw new Exception(Messages.ErrorConnectSubsystem);
+
+                       fileService = ((IFileServiceSubSystem) getFileSubsystem()).getFileService();
+               }
+               return fileService;
+       }
+
+       public ISubSystem getFileSubsystem() {
+               if (fileSubSystem == null) {
+                       if (connection == null)
+                               return null;
+                       ISubSystem[] subSystems = connection.getSubSystems();
+                       for (int i = 0; i < subSystems.length; i++) {
+                               if (subSystems[i] instanceof IFileServiceSubSystem) {
+                                       fileSubSystem = subSystems[i];
+                                       break;
+                               }
+                       }
+               }
+               return fileSubSystem;
+       }
+
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java
new file mode 100644
index 0000000..cb14c0b
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.
+++ java
@@ -0,0 +1,117 @@
+package org.yocto.remote.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.rse.core.model.IHost; import
+org.eclipse.rse.services.files.IHostFile;
+
+public abstract class Session {
+       public static final String LT = System.getProperty("line.separator");
+       public static final String EXPORT_CMD = "export
+BB_ENV_EXTRAWHITE=\"DISABLE_SANITY_CHECKS $BB_ENV_EXTRAWHITE\"";
+
+       private final String initCmd;
+       private final IHostFile root;
+
+       public String terminator;
+       private volatile boolean interrupt = false;
+       private Process process;
+       private final OutputStream pos = null;
+       private IHost connection;
+
+       public Session(IHostFile root, String initCmd) throws IOException {
+               this.root = root;
+               this.initCmd  = initCmd;
+               initializeConnection();
+               initializeShell(new NullProgressMonitor());
+       }
+
+       protected abstract void initializeConnection();
+
+       private void initializeShell(IProgressMonitor monitor) throws IOException {
+               try {
+                       if (root != null) {
+                               RemoteHelper.handleRunCommandRemote(connection, new YoctoCommand("source " + initCmd, root.getAbsolutePath(), ""), monitor);
+                               RemoteHelper.handleRunCommandRemote(connection,  new YoctoCommand(EXPORT_CMD, root.getAbsolutePath(), ""), monitor);
+                       } else {
+                               throw new Exception("Root file not found!");
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+       synchronized
+       public void execute(String command, String terminator, ICommandResponseHandler handler) throws IOException {
+               interrupt = false;
+               InputStream errIs = process.getErrorStream();
+               if (errIs.available() > 0) {
+                       clearErrorStream(errIs);
+               }
+               sendToProcessAndTerminate(command);
+
+               BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
+               String std = null;
+
+               do {
+                       if (errIs.available() > 0) {
+                               byte[] msg = new byte[errIs.available()];
+
+                               errIs.read(msg, 0, msg.length);
+                               handler.response(new String(msg), true);
+                       }
+
+                       std = br.readLine();
+
+                       if (std != null && !std.endsWith(terminator)) {
+                               handler.response(std, false);
+                       }
+
+               } while (std != null && !std.endsWith(terminator) && !interrupt);
+
+               if (interrupt) {
+                       process.destroy();
+                       initializeShell(null);
+                       interrupt = false;
+               }
+       }
+
+       private void clearErrorStream(InputStream is) {
+
+               try {
+                       byte b[] = new byte[is.available()];
+                       is.read(b);
+                       System.out.println("clearing: " + new String(b));
+               } catch (IOException e) {
+                       e.printStackTrace();
+                       //Ignore any error
+               }
+       }
+       /**
+        * Send command string to shell process and add special terminator string so
+        * reader knows when output is complete.
+        *
+        * @param command
+        * @throws IOException
+        */
+       private void sendToProcessAndTerminate(String command) throws IOException {
+               pos.write(command.getBytes());
+               pos.write(LT.getBytes());
+               pos.flush();
+               pos.write("echo $?".getBytes());
+               pos.write(terminator.getBytes());
+               pos.write(LT.getBytes());
+               pos.flush();
+       }
+
+       /**
+        * Interrupt any running processes.
+        */
+       public void interrupt() {
+               interrupt = true;
+       }
+}
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java
new file mode 100644
index 0000000..0cd7dcd
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCom
+++ mand.java
@@ -0,0 +1,53 @@
+package org.yocto.remote.utils;
+
+
+public class YoctoCommand {
+       private String command;
+       private String initialDirectory;
+       private String arguments;
+       private ProcessStreamBuffer processBuffer;
+
+       public YoctoCommand(String command, String initialDirectory, String arguments){
+               this.setCommand(command);
+               this.setInitialDirectory(initialDirectory);
+               this.setArguments(arguments);
+               this.setProcessBuffer(new ProcessStreamBuffer(false));
+       }
+
+       public String getCommand() {
+               return command;
+       }
+
+       public void setCommand(String command) {
+               this.command = command;
+       }
+
+       public String getInitialDirectory() {
+               return initialDirectory;
+       }
+
+       public void setInitialDirectory(String initialDirectory) {
+               this.initialDirectory = initialDirectory;
+       }
+
+       public String getArguments() {
+               return arguments;
+       }
+
+       public void setArguments(String arguments) {
+               this.arguments = arguments;
+       }
+
+       public ProcessStreamBuffer getProcessBuffer() {
+               return processBuffer;
+       }
+
+       public void setProcessBuffer(ProcessStreamBuffer processBuffer) {
+               this.processBuffer = processBuffer;
+       }
+
+       @Override
+       public String toString() {
+               return command + " " + arguments;
+       }
+}
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Refactor RFC 9/9] Redirect bitbake environment parsing to file & parse
  2013-06-07  0:27   ` Zhang, Jessica
@ 2013-06-11 11:27     ` Grigoropol, IoanaX
  0 siblings, 0 replies; 20+ messages in thread
From: Grigoropol, IoanaX @ 2013-06-11 11:27 UTC (permalink / raw)
  To: Zhang, Jessica, yocto

Hi Jessica,

The first fixme message is just a left-over. We don't need to perform any waiting actions since the command is ran synchronously.
As for the second fixme, its purpose was to perform some clean-up of the environment file (bitbake.env), and thus will be replaced with a call to "rm -rf".
I have sent a pull request for this change, from poky-contrib, branch: igrigorx/common-remote-refactor

Ioana

________________________________________
From: Zhang, Jessica
Sent: Friday, June 07, 2013 3:27 AM
To: Grigoropol, IoanaX; yocto@yoctoproject.org
Subject: RE: [yocto] [Refactor RFC 9/9] Redirect bitbake environment parsing to file & parse

Ioana,

There're couple fixme in wait for bitbake to finish and clean up the environment file that seems not addressed.  Also, please make sure the changed files have valid license info.

Thanks,
Jessica

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: yocto@yoctoproject.org
Subject: [yocto] [Refactor RFC 9/9] Redirect bitbake environment parsing to file & parse

- when running "bitbake -e" the output is sent to the console, poluting it
- instead, send the output to a file (bitbake.env) and parse the file accordingly
- if an error has occured while running the commad, all the error lines are collected and displayed on the console

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../src/org/yocto/bc/bitbake/BBRecipe.java         |    2 +-
 .../src/org/yocto/bc/bitbake/BBSession.java        |   49 +++++++++++++-------
 .../src/org/yocto/bc/bitbake/ShellSession.java     |   14 +++---
 3 files changed, 40 insertions(+), 25 deletions(-)

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
index 1baf124..6168f8c 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java
@@ -26,7 +26,7 @@ public class BBRecipe extends BBSession {
                super(session.shell, session.pinfo.getOriginalURI());
                this.session = session;
                this.fileURI = filePath;
-               this.parsingCmd = "DISABLE_SANITY_CHECKS=1 bitbake -e -b " + filePath;
+               this.parsingCmd = "DISABLE_SANITY_CHECKS=\"1\" bitbake -e -b " +
+filePath.getPath() + " >& " + BB_ENV_FILE;
        }

        @Override
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
index fcde557..9bc4dcc 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java
@@ -15,6 +15,8 @@ import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
 import java.io.StringReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -33,9 +35,11 @@ import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Status;  import org.eclipse.jface.preference.JFacePreferences;
 import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.rse.core.model.IHost;
 import org.eclipse.ui.console.ConsolePlugin;
 import org.eclipse.ui.console.IConsole;  import org.eclipse.ui.console.IConsoleManager;
@@ -45,6 +49,7 @@ import org.eclipse.ui.progress.WorkbenchJob;

 import org.yocto.bc.ui.model.IModelElement;
 import org.yocto.bc.ui.model.ProjectInfo;
+import org.yocto.remote.utils.RemoteHelper;

 /**
  * BBSession encapsulates a global bitbake configuration and is the primary interface @@ -59,6 +64,7 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
        public static final int TYPE_STATEMENT = 3;
        public static final int TYPE_FLAG = 4;

+       public static final String BB_ENV_FILE = "bitbake.env";
        public static final String BUILDDIR_INDICATORS [] = {
                File.separatorChar + "conf" + File.separatorChar + "local.conf",
                File.separatorChar + "conf" + File.separatorChar + "bblayers.conf", @@ -69,19 +75,21 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
        protected Map<?,?> properties = null;
        protected List <URI> depends = null;
        protected boolean initialized = false;
+       protected boolean errorOccured = false;
        protected MessageConsole sessionConsole;
        private final ReentrantReadWriteLock rwlock = new ReentrantReadWriteLock();
        private final Lock rlock = rwlock.readLock();
        private final Lock wlock = rwlock.writeLock();
        protected String parsingCmd;
        private boolean silent = false;
-
+       private String errorLines = "";
+
        public BBSession(ShellSession ssession, URI projectRoot) throws IOException {
                shell = ssession;
                this.pinfo = new ProjectInfo();
                pinfo.setLocationURI(projectRoot);
                pinfo.setInitScriptPath(ProjectInfoHelper.getInitScriptPath(projectRoot));
-               this.parsingCmd = "DISABLE_SANITY_CHECKS=1 bitbake -e";
+               this.parsingCmd = "DISABLE_SANITY_CHECKS=\"1\" bitbake -e >& " +
+BB_ENV_FILE;
        }

        public BBSession(ShellSession ssession, URI projectRoot, boolean silent) throws IOException { @@ -330,18 +338,17 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
                }
        }

-       protected int checkExecuteError(String result, int code) {
+       protected void checkExecuteError(String result, boolean hasErrors) {
                URI recipeURI = getDefaultDepends();
                String text = "Parsing " + ((recipeURI != null) ? ("recipe " + recipeURI) : "base configurations");
-               if (code != 0) {
+               if (hasErrors) {
                        text = text + " ERROR!\n" + result;
                }else {
                                text = text + " SUCCESS.\n";
                }
                if(!silent) {
-                       displayInConsole(text, code, false);
+                       displayInConsole(text, -1, false);
                }
-               return code;
        }

        protected void displayInConsole(final String result, final int code, boolean clear) { @@ -378,14 +385,21 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
                        }
                        try {
                                if(!initialized) { //recheck
-                                       int [] codes = {-1};
-                                       String result = shell.execute(parsingCmd, codes);
-                                       if(checkExecuteError(result, codes[0]) == 0) {
-                                               properties = parseBBEnvironment(result);
+                                       boolean hasErrors = false;
+                                       String result = shell.execute(parsingCmd, hasErrors);
+
+                                       //FIXME : wait for bitbake to finish
+                                       properties = parseBBEnvironment(result);
+
+                                       if (properties.size() == 0) { // there was an error in sourcing bitbake environment
+                                               shell.printError(errorLines);
+                                               errorOccured = true;
                                        } else {
-                                               properties = parseBBEnvironment("");
+                                               errorLines = "";
+                                               errorOccured = false;
+                                               initialized = true;
                                        }
-                                       initialized = true;
+                                       //FIXME: cleanup BB env file
                                }
                        } finally {
                                //downgrade lock
@@ -440,8 +454,11 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
                }
        }

-       protected void parse(String content, Map outMap) throws Exception {
-               BufferedReader reader = new BufferedReader(new StringReader(content));
+       protected void parse(String bbOutfilePath, Map outMap) throws Exception {
+               IHost connection = shell.getProjectInfo().getConnection();
+               InputStream is = RemoteHelper.getRemoteInputStream(connection, bbOutfilePath, BB_ENV_FILE, new NullProgressMonitor());
+               RemoteHelper.getRemoteHostFile(connection, bbOutfilePath + BB_ENV_FILE, new NullProgressMonitor());
+               BufferedReader reader = new BufferedReader(new
+InputStreamReader(is));
                String line;
                boolean inLine = false;
                StringBuffer sb = null;
@@ -508,11 +525,11 @@ public class BBSession implements IBBSessionListener, IModelElement, Map {
                return null;
        }

-       protected Map parseBBEnvironment(String bbOut) throws Exception {
+       protected Map parseBBEnvironment(String bbOutFilePath) throws
+Exception {
                Map env = new Hashtable();
                this.depends = new ArrayList<URI>();

-               parse(bbOut, env);
+               parse(bbOutFilePath, env);

                String included = (String) env.get("BBINCLUDED");
                if(getDefaultDepends() != null) {
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
index 44b2696..129d1d9 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
@@ -21,6 +21,7 @@ import java.io.Writer;  import org.eclipse.rse.services.files.IHostFile;
 import org.yocto.bc.ui.model.ProjectInfo;
 import org.yocto.remote.utils.ICommandResponseHandler;
+import org.yocto.remote.utils.RemoteHelper;

 /**
  * A class for Linux shell sessions.
@@ -112,11 +113,11 @@ public class ShellSession {

        synchronized
        public String execute(String command) throws IOException {
-               return execute(command, (int [])null);
+               return execute(command, false);
        }

        synchronized
-       public String execute(String command, int[] retCode) throws IOException {
+       public String execute(String command, boolean hasErrors) throws
+IOException {
                String errorMessage = null;
                interrupt = false;
                out.write(command);
@@ -150,12 +151,6 @@ public class ShellSession {
                        process.destroy();
                        initializeShell();
                        interrupt = false;
-               }else if (line != null && retCode != null) {
-                       try {
-                               retCode[0]=Integer.parseInt(line.substring(0,line.lastIndexOf(TERMINATOR)));
-                       }catch (NumberFormatException e) {
-                               throw new IOException("Can NOT get return code" + command + LT + line);
-                       }
                }

                if (errorMessage != null) {
@@ -259,4 +254,7 @@ synchronized
                }

        }
+       public void printError(String errorLines) {
+               RemoteHelper.getCommandHandler(projectInfo.getConnection()).response(errorLines, true);
+       }
 }
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2013-06-11 11:27 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-04 13:25 [Refactor RFC 0/9] Merging of windows-build with master Ioana Grigoropol
2013-06-04 13:26 ` [Refactor RFC 1/9] Rename RSEHelper to RemoteHelper to match usages in org.yocto.bc.ui.plugin Ioana Grigoropol
2013-06-04 13:26 ` [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities Ioana Grigoropol
2013-06-06 23:53   ` Zhang, Jessica
2013-06-07 15:29     ` Grigoropol, IoanaX
2013-06-04 13:26 ` [Refactor RFC 3/9] Remove ICommandResponseHandler from plugin and use org.yocto.remote.utils implementation Ioana Grigoropol
2013-06-06 23:56   ` Zhang, Jessica
2013-06-04 13:26 ` [Refactor RFC 4/9] Remove unused Bitbake Actions Ioana Grigoropol
2013-06-06 23:57   ` Zhang, Jessica
2013-06-07 12:19     ` Grigoropol, IoanaX
2013-06-04 13:26 ` [Refactor RFC 5/9] Remove storing of init script location Ioana Grigoropol
2013-06-07  0:02   ` Zhang, Jessica
2013-06-07 12:18     ` Grigoropol, IoanaX
2013-06-04 13:26 ` [Refactor RFC 6/9] Remove unused method loadInit in Activator Ioana Grigoropol
2013-06-04 13:26 ` [Refactor RFC 7/9] Remove unused getInitScript from ProjectInfoHelper Ioana Grigoropol
2013-06-04 13:26 ` [Refactor RFC 8/9] Use URI for storing project locations Ioana Grigoropol
2013-06-04 13:26 ` [Refactor RFC 9/9] Redirect bitbake environment parsing to file & parse Ioana Grigoropol
2013-06-07  0:27   ` Zhang, Jessica
2013-06-11 11:27     ` Grigoropol, IoanaX
2013-06-07  0:29 ` [Refactor RFC 0/9] Merging of windows-build with master Zhang, Jessica

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.