Skip to contentSkip to conversation

Merging of windows-build with master

RFC In review Ioana Grigoropol 2 participants 20 messages Jun 4, 2013 – Jun 11, 2013

lore
Share & tools
lore
#0 lore raw

cover 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
Signature · 1 line
1.7.9.5
#1 lore raw

RFC 1/9 Rename RSEHelper to RemoteHelper to match usages in org.yocto.bc.ui.plugin

---
 .../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
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RSEHelper.java deleted +0 -344
deleted file mode 100644
index 201c944..0000000
@@ -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;
-			}
-	}
-}
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java new file +344 -0

344 lines not on this page · raw message

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteShellExec.java +1 -1
index a7fe221..711088c 100644
@@ -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();
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/TerminalHandler.java +1 -1
index 1eed7e9..cd89fea 100644
@@ -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();
plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseModel.java +3 -3
index dacd192..b98abd3 100644
@@ -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 {
plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/BaseSettingDialog.java +6 -6
index 7845959..24f4c23 100644
@@ -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))
Signature · 1 line
1.7.9.5
#2 lore raw

RFC 2/9 Add remote tools classes needed for bitbake remote capabilities

In reply to Ioana Grigoropol
---
 .../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
plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF +7 -1
index c7b57fe..06d14f8 100644
@@ -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
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandOutputProcessor.java new file +33 -0
new file mode 100644
index 0000000..4fca662
@@ -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);
+	}
+
+}
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandResponseHandler.java new file +36 -0
new file mode 100644
index 0000000..0785c45
@@ -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
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandRunnable.java new file +34 -0
new file mode 100644
index 0000000..46a3f35
@@ -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();
+		}
+	}
+
+}
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleHelper.java new file +28 -0
new file mode 100644
index 0000000..307e219
@@ -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));
+	}
+}
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleRunnable.java new file +37 -0
new file mode 100644
index 0000000..f3b0ccd
@@ -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
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommandResponseHandler.java new file +15 -0
new file mode 100644
index 0000000..a8a8f95
@@ -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);
+}
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputProcessor.java new file +102 -0

103 lines not on this page · raw message

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessStreamBuffer.java new file +77 -0

77 lines not on this page · raw message

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java +207 -48

315 lines not on this page · raw message

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMachine.java new file +206 -0

206 lines not on this page · raw message

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session.java new file +117 -0

117 lines not on this page · raw message

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCommand.java new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw

Re: [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: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: [email protected]
Subject: [yocto] [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities

---
 .../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
plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF +7 -1
index c7b57fe..06d14f8 100644
@@ -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
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandO new file +0 -0
new file mode 100644
index 0000000..4fca662

+++ 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);
+ }
+
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandR new file +0 -0
new file mode 100644
index 0000000..0785c45

+++ 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

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandR new file +0 -0
new file mode 100644
index 0000000..46a3f35

+++ 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();
+ }
+ }
+
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleH new file +0 -0
new file mode 100644
index 0000000..307e219

+++ 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));
+ }
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleR new file +0 -0
new file mode 100644
index 0000000..f3b0ccd

+++ 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

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommand new file +0 -0
new file mode 100644
index 0000000..a8a8f95

+++ 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); }

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputPr new file +0 -0
new file mode 100644
index 0000000..a06f077

+++ 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

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessS new file +0 -0
new file mode 100644
index 0000000..3fe8731

+++ 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 "";
+ }
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHe renamed from plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java +0 -0
index a1e9a08..e9118d6 100644

+++ 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;
+ }
}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMa new file +0 -0
new file mode 100644
index 0000000..123a972

+++ 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;
+ }
+
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session. new file +0 -0
new file mode 100644
index 0000000..cb14c0b

+++ 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;
+ }
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCom new file +0 -0
new file mode 100644
index 0000000..0cd7dcd

+++ 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
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#4 lore raw

Re: [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities

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; [email protected]
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: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: [email protected]
Subject: [yocto] [Refactor RFC 2/9] Add remote tools classes needed for bitbake remote capabilities

---
 .../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
plugins/org.yocto.remote.utils/META-INF/MANIFEST.MF +7 -1
index c7b57fe..06d14f8 100644
@@ -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
plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandO new file +0 -0
new file mode 100644
index 0000000..4fca662

+++ 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);
+ }
+
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandR new file +0 -0
new file mode 100644
index 0000000..0785c45

+++ 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

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommandR new file +0 -0
new file mode 100644
index 0000000..46a3f35

+++ 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();
+ }
+ }
+
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleH new file +0 -0
new file mode 100644
index 0000000..307e219

+++ 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));
+ }
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ConsoleR new file +0 -0
new file mode 100644
index 0000000..f3b0ccd

+++ 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

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ICommand new file +0 -0
new file mode 100644
index 0000000..a8a8f95

+++ 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); }

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/OutputPr new file +0 -0
new file mode 100644
index 0000000..a06f077

+++ 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

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/ProcessS new file +0 -0
new file mode 100644
index 0000000..3fe8731

+++ 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 "";
+ }
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHe renamed from plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteHelper.java +0 -0
index a1e9a08..e9118d6 100644

+++ 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;
+ }
}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/RemoteMa new file +0 -0
new file mode 100644
index 0000000..123a972

+++ 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;
+ }
+
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/Session. new file +0 -0
new file mode 100644
index 0000000..cb14c0b

+++ 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;
+ }
+}

plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/YoctoCom new file +0 -0
new file mode 100644
index 0000000..0cd7dcd

+++ 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
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#5 lore raw

RFC 3/9 Remove ICommandResponseHandler from plugin and use org.yocto.remote.utils implementation

In reply to Ioana Grigoropol

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

---
 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
plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF +2 -1
index 6366424..3ca62df 100644
@@ -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: .
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java deleted +0 -15
deleted file mode 100644
index 4c44352..0000000
@@ -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);
-}
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java +2 -0
index 4719865..db8f564 100644
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java +1 -2
index 41d5c73..cd4f4c9 100644
@@ -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 {
 
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java +8 -22
index f2cb1da..3130cbf 100644
@@ -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.
Signature · 1 line
1.7.9.5
#6 lore raw

Re: [Refactor RFC 3/9] Remove ICommandResponseHandler from plugin and use org.yocto.remote.utils implementation

Please fix the license for the files.

Thanks,
Jessica

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: [email protected]
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

---
 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
plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF +2 -1
index 6366424..3ca62df 100644
@@ -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: .
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ICommandResponseHandler.java deleted +0 -15
deleted file mode 100644
index 4c44352..0000000
@@ -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);
-}
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java +2 -0
index 4719865..db8f564 100644
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbak renamed from plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java +0 -0
index 41d5c73..cd4f4c9 100644

+++ 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 {

plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/Instal renamed from plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java +0 -0
index f2cb1da..3130cbf 100644

+++ 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
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#7 lore raw

RFC 4/9 Remove unused Bitbake Actions

In reply to Ioana Grigoropol

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

---
 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
plugins/org.yocto.bc.ui/plugin.xml +0 -55
index cb0561c..2e1421f 100644
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java deleted +0 -198

199 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java deleted +0 -24
deleted file mode 100644
index 22ac94c..0000000
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java deleted +0 -26
deleted file mode 100644
index f95117e..0000000
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java deleted +0 -106

107 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java deleted +0 -29
deleted file mode 100644
index c5dedea..0000000
@@ -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
Signature · 1 line
1.7.9.5
#8 lore raw

Re: [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: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: [email protected]
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

---
 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
plugins/org.yocto.bc.ui/plugin.xml +0 -55
index cb0561c..2e1421f 100644
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java deleted +0 -193

194 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java deleted +0 -24
deleted file mode 100644
index 22ac94c..0000000
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java deleted +0 -26
deleted file mode 100644
index f95117e..0000000
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java deleted +0 -104

105 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java deleted +0 -29
deleted file mode 100644
index c5dedea..0000000
@@ -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
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#9 lore raw

Re: [Refactor RFC 4/9] Remove unused Bitbake Actions

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; [email protected]
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: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: [email protected]
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

---
 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
plugins/org.yocto.bc.ui/plugin.xml +0 -55
index cb0561c..2e1421f 100644
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/AbstractBitbakeCommandAction.java deleted +0 -193

194 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeBuildRecipeAction.java deleted +0 -24
deleted file mode 100644
index 22ac94c..0000000
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeCleanRecipeAction.java deleted +0 -26
deleted file mode 100644
index f95117e..0000000
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeImportAction.java deleted +0 -104

105 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/BitbakeRebuildRecipeAction.java deleted +0 -29
deleted file mode 100644
index c5dedea..0000000
@@ -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
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#10 lore raw

RFC 5/9 Remove storing of init script location

In reply to Ioana Grigoropol

- 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

---
 .../org/yocto/bc/bitbake/ProjectInfoHelper.java    |   23 --------------------
 .../BBConfigurationInitializeOperation.java        |    1 -
 .../newproject/CreateBBCProjectOperation.java      |    6 -----
 3 files changed, 30 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java +0 -23
index 25dac97..b8d4b29 100644
@@ -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();
-	}
-
 }
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java +0 -1
index 4f15107..64c3e6e 100644
@@ -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();
 
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java +0 -6
index dc0153b..1d54ea3 100644
@@ -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);
Signature · 1 line
1.7.9.5
#11 lore raw

Re: [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: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: [email protected]
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

---
 .../org/yocto/bc/bitbake/ProjectInfoHelper.java    |   23 --------------------
 .../BBConfigurationInitializeOperation.java        |    1 -
 .../newproject/CreateBBCProjectOperation.java      |    6 -----
 3 files changed, 30 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java +0 -23
index 25dac97..b8d4b29 100644
@@ -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();
-       }
-
 }
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java +0 -1
index 4f15107..64c3e6e 100644
@@ -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();
 
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java +0 -6
index dc0153b..1d54ea3 100644
@@ -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
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#12 lore raw

Re: [Refactor RFC 5/9] Remove storing of init script location

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; [email protected]
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: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: [email protected]
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

---
 .../org/yocto/bc/bitbake/ProjectInfoHelper.java    |   23 --------------------
 .../BBConfigurationInitializeOperation.java        |    1 -
 .../newproject/CreateBBCProjectOperation.java      |    6 -----
 3 files changed, 30 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java +0 -23
index 25dac97..b8d4b29 100644
@@ -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();
-       }
-
 }
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java +0 -1
index 4f15107..64c3e6e 100644
@@ -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();
 
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java +0 -6
index dc0153b..1d54ea3 100644
@@ -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
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#13 lore raw

RFC 6/9 Remove unused method loadInit in Activator

In reply to Ioana Grigoropol
---
 .../src/org/yocto/bc/ui/Activator.java             |   23 --------------------
 1 file changed, 23 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/Activator.java +0 -23
index 505a254..a6c10c6 100644
@@ -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();
Signature · 1 line
1.7.9.5
#14 lore raw

RFC 7/9 Remove unused getInitScript from ProjectInfoHelper

In reply to Ioana Grigoropol
---
 .../org/yocto/bc/bitbake/ProjectInfoHelper.java    |   15 ---------------
 1 file changed, 15 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java +0 -15
index b8d4b29..0d95c01 100644
@@ -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) {
Signature · 1 line
1.7.9.5
#15 lore raw

RFC 8/9 Use URI for storing project locations

In reply to Ioana Grigoropol

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

---
 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
plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF +4 -0
index 3ca62df..7cecce8 100644
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java +9 -15
index 2b355ba..1baf124 100644
@@ -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;
 	}
 }
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java +19 -15
index e998bcd..fcde557 100644
@@ -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;
 					}
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ProjectInfoHelper.java +9 -13
index 0d95c01..c053c28 100644
@@ -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();
 				}
 
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java +14 -2
index db8f564..44b2696 100644
@@ -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) {
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/Activator.java +35 -25

148 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/actions/LaunchVariableWizardAction.java +13 -3
index eaf716e..1899098 100644
@@ -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();
 				}
 			}
 		}
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BBVariableTextHover.java +6 -10
index 9478423..28e98d4 100644
@@ -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;
 		}
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeFileEditor.java +14 -2
index b33f030..7535341 100644
@@ -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);
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeSourceViewerConfiguration.java +12 -2
index 56cd014..2be6f1d 100644
@@ -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;
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFile.java +6 -7
index 85794f1..8340597 100644
@@ -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 {
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java +22 -2
index f0bf449..19c9dbc 100644
@@ -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();
+		}
+	}
 }
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/YoctoLocation.java new file +34 -0
new file mode 100755
index 0000000..ab99177
@@ -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;
+	}
+}
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/model/ProjectInfo.java +67 -8

102 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java +1 -1
index 7e29e7a..d657fd5 100644
@@ -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);
 	}
 
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/importProject/ImportYoctoProjectWizard.java +3 -4
index b1fc841..82c5ab3 100644
@@ -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) {
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java +7 -2
index 3130cbf..f9174e2 100644
@@ -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));
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java +1 -1
index 64c3e6e..20c001a 100644
@@ -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) {
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java +5 -9
index 1d54ea3..41efdb0 100644
@@ -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);
Signature · 1 line
1.7.9.5
#16 lore raw

RFC 9/9 Redirect bitbake environment parsing to file & parse

In reply to Ioana Grigoropol

- 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

---
 .../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(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java +1 -1
index 1baf124..6168f8c 100644
@@ -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
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java +33 -16

130 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java +6 -8
index 44b2696..129d1d9 100644
@@ -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);
+	}
 }
Signature · 1 line
1.7.9.5
#17 lore raw

Re: [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: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: [email protected]
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

---
 .../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(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java +2 -1
index 1baf124..6168f8c 100644
@@ -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

plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java +5 -0
index fcde557..9bc4dcc 100644
@@ -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) {
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java +4 -2
index 44b2696..129d1d9 100644
@@ -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
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#18 lore raw

Re: [Refactor RFC 9/9] Redirect bitbake environment parsing to file & parse

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; [email protected]
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: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: [email protected]
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

---
 .../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(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java +2 -1
index 1baf124..6168f8c 100644
@@ -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

plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java +5 -0
index fcde557..9bc4dcc 100644
@@ -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) {
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java +4 -2
index 44b2696..129d1d9 100644
@@ -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
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#19 lore raw
In reply to Ioana Grigoropol

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: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Tuesday, June 04, 2013 6:26 AM
To: [email protected]
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
[email protected]
https://lists.yoctoproject.org/listinfo/yocto