From 624cce0ccfc5c05e0c2de3404f558c18d6fa57bb Mon Sep 17 00:00:00 2001 From: YoonKi Park Date: Tue, 27 Dec 2011 20:38:12 +0900 Subject: [PATCH] [Title] revert ondemand install path --- .../common/connection/debugtools/DebugTool.java | 5 + .../common/connection/debugtools/Messages.java | 133 --------------------- .../common/connection/debugtools/ToolsInstall.java | 74 +++++++----- .../debugtools/ToolsInstallMessages.java | 43 +++++++ .../debugtools/ToolsInstallMessages.properties | 8 ++ .../connection/debugtools/messages.properties | 2 - 6 files changed, 102 insertions(+), 163 deletions(-) delete mode 100644 com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/Messages.java create mode 100644 com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/ToolsInstallMessages.java create mode 100644 com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/ToolsInstallMessages.properties delete mode 100644 com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/messages.properties diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/DebugTool.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/DebugTool.java index 79bf28c..a89badb 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/DebugTool.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/DebugTool.java @@ -25,8 +25,13 @@ */ package com.samsung.tizen.common.connection.debugtools; +import com.samsung.tizen.common.properties.InstallPathConfig; + public class DebugTool { final public static String CONTROL_EXTENSION = ".control"; + final public static String TOOLS_TARGET_PATH = "/home/developer/sdk_tools"; + final public static String TOOLS_HOST_PATH = InstallPathConfig.getSDKPath(); + private String binaryname; private String packagename; private String sourcepath; diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/Messages.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/Messages.java deleted file mode 100644 index 395c2f7..0000000 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/Messages.java +++ /dev/null @@ -1,133 +0,0 @@ -/* -* Common -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: -* Hoon Kang -* YoonKi Park -* - * Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* Contributors: -* - S-Core Co., Ltd -* -*/ -package com.samsung.tizen.common.connection.debugtools; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "com.samsung.tizen.common.connection.debugtools.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - // TODO Auto-generated method stub - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } - - public static String getString(String key, Object binding) { - // TODO Auto-generated method stub - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } - private static String messageBind(String message, Object[] args, String argZero, String argOne) { - int length = message.length(); - //estimate correct size of string buffer to avoid growth - int bufLen = length + (args.length * 5); - if (argZero != null) - bufLen += argZero.length() - 3; - if (argOne != null) - bufLen += argOne.length() - 3; - StringBuffer buffer = new StringBuffer(bufLen < 0 ? 0 : bufLen); - for (int i = 0; i < length; i++) { - char c = message.charAt(i); - switch (c) { - case '{' : - int index = message.indexOf('}', i); - // if we don't have a matching closing brace then... - if (index == -1) { - buffer.append(c); - break; - } - i++; - if (i >= length) { - buffer.append(c); - break; - } - // look for a substitution - int number = -1; - try { - number = Integer.parseInt(message.substring(i, index)); - } catch (NumberFormatException e) { - throw (IllegalArgumentException) new IllegalArgumentException().initCause(e); - } - if (number == 0 && argZero != null) - buffer.append(argZero); - else if (number == 1 && argOne != null) - buffer.append(argOne); - else { - if (number >= args.length || number < 0) { - buffer.append(""); //$NON-NLS-1$ - i = index; - break; - } - buffer.append(args[number]); - } - i = index; - break; - case '\'' : - // if a single quote is the last char on the line then skip it - int nextIndex = i + 1; - if (nextIndex >= length) { - buffer.append(c); - break; - } - char next = message.charAt(nextIndex); - // if the next char is another single quote then write out one - if (next == '\'') { - i++; - buffer.append(c); - break; - } - // otherwise we want to read until we get to the next single quote - index = message.indexOf('\'', nextIndex); - // if there are no more in the string, then skip it - if (index == -1) { - buffer.append(c); - break; - } - // otherwise write out the chars inside the quotes - buffer.append(message.substring(nextIndex, index)); - i = index; - break; - default : - buffer.append(c); - } - } - return buffer.toString(); - } -} diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/ToolsInstall.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/ToolsInstall.java index f609665..7387000 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/ToolsInstall.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/ToolsInstall.java @@ -33,7 +33,9 @@ import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.regex.Pattern; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.swt.SWT; @@ -41,7 +43,6 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import com.samsung.tizen.common.connection.ConnectionPlugin; -import com.samsung.tizen.common.properties.InstallPathConfig; import com.samsung.tizen.sdblib.IDevice; import com.samsung.tizen.sdblib.SdbCommandRejectedException; import com.samsung.tizen.sdblib.SdbShellProcess; @@ -60,15 +61,13 @@ class PackageInstallMonitorDialog extends ProgressMonitorDialog { class InstallProgress implements IRunnableWithProgress { - final private String TOOLS_TARGET_PATH = "/home/root/sdk_tools"; - final private String TOOLS_HOST_PATH = InstallPathConfig.getSDKPath(); final private String CMD_RESULT_CHECK = "; echo $?"; private IDevice device = null; IProgressMonitor monitor = null; - private boolean checkDirectory(String dir) { + private boolean checkDirectory(String dir) throws CoreException { boolean checkResult = false; SdbShellProcess lsProc; try { @@ -84,12 +83,12 @@ class InstallProgress implements IRunnableWithProgress { checkResult = true; } } catch (IOException e) { - return false; + installCoreException(ToolsInstallMessages.CANNOT_CHECK_DIRECTORY, e); } return checkResult; } - private boolean makeDirectory(String dir) { + private void makeDirectory(String dir) throws CoreException { boolean makeResult = false; SdbShellProcess lsProc; try { @@ -107,18 +106,19 @@ class InstallProgress implements IRunnableWithProgress { } br.close(); } catch (IOException e) { - return false; + installCoreException(ToolsInstallMessages.CANNOT_CREATE_DIRECTORY, e); } - return makeResult; + if (makeResult == false) + installCoreException(ToolsInstallMessages.CANNOT_CREATE_DIRECTORY, null); } - private boolean isInstalled(DebugTool dt) { + private boolean isInstalled(DebugTool dt) throws CoreException { boolean ret = false; try { SdbShellProcess echoProc = device .executeShellCommand("cat " - + TOOLS_TARGET_PATH + "/" + dt.getControlFile() + CMD_RESULT_CHECK); + + DebugTool.TOOLS_TARGET_PATH + "/" + dt.getControlFile() + CMD_RESULT_CHECK); BufferedReader br = new BufferedReader(new InputStreamReader( echoProc.getInputStream())); @@ -149,7 +149,7 @@ class InstallProgress implements IRunnableWithProgress { ret = false; br.close(); } catch (IOException e) { - return true; + installCoreException(ToolsInstallMessages.CANNOT_CHECK_INSTALLED, e); } return ret; @@ -164,7 +164,7 @@ class InstallProgress implements IRunnableWithProgress { } private void removeOldPackage(String packagename) { try { - SdbShellProcess echoProc = device.executeShellCommand("rm -rf " + TOOLS_TARGET_PATH + "/" + packagename); + SdbShellProcess echoProc = device.executeShellCommand("rm -rf " + DebugTool.TOOLS_TARGET_PATH + "/" + packagename); BufferedReader br = new BufferedReader(new InputStreamReader(echoProc.getInputStream())); while (null != br.readLine()){ @@ -197,7 +197,7 @@ class InstallProgress implements IRunnableWithProgress { private void unzipPackage(String packageFile) { try { SdbShellProcess tarProc = device.executeShellCommand("cd " - + TOOLS_TARGET_PATH + " && tar -xzf " + packageFile); + + DebugTool.TOOLS_TARGET_PATH + " && tar -xzf " + packageFile); BufferedReader br = new BufferedReader(new InputStreamReader( tarProc.getInputStream())); while (null != br.readLine()) { @@ -212,7 +212,7 @@ class InstallProgress implements IRunnableWithProgress { try { SdbShellProcess echoProc = device .executeShellCommand("echo 'version:"+version+ "' >" - + TOOLS_TARGET_PATH + "/" + controlFile ); + + DebugTool.TOOLS_TARGET_PATH + "/" + controlFile ); BufferedReader br = new BufferedReader(new InputStreamReader( echoProc.getInputStream())); while (null != br.readLine()) { @@ -226,7 +226,7 @@ class InstallProgress implements IRunnableWithProgress { private void removeTar(String packageFile) { try { SdbShellProcess echoProc = device.executeShellCommand("cd " - + TOOLS_TARGET_PATH + " && rm " + packageFile); + + DebugTool.TOOLS_TARGET_PATH + " && rm " + packageFile); BufferedReader br = new BufferedReader(new InputStreamReader( echoProc.getInputStream())); @@ -237,17 +237,17 @@ class InstallProgress implements IRunnableWithProgress { } } - final private void installPackage(DebugTool tool) { - String local = TOOLS_HOST_PATH+"/"+tool.getSourcepath() + "/" + tool.getBinaryname(); - String remote = TOOLS_TARGET_PATH + "/" + tool.getBinaryname(); + final private void installPackage(DebugTool tool) throws CoreException { + String local = DebugTool.TOOLS_HOST_PATH+"/"+tool.getSourcepath() + "/" + tool.getBinaryname(); + String remote = DebugTool.TOOLS_TARGET_PATH + "/" + tool.getBinaryname(); // delete old version try { SdbShellProcess echoProc = device.executeShellCommand("cd " - + TOOLS_TARGET_PATH + " && rm " + tool.getControlFile()); + + DebugTool.TOOLS_TARGET_PATH + " && rm " + tool.getControlFile()); } catch (IOException e) { // TODO Auto-generated catch block - e.printStackTrace(); + installCoreException(ToolsInstallMessages.CANNOT_REMOVE_CONTROLFILE, e); } @@ -265,8 +265,7 @@ class InstallProgress implements IRunnableWithProgress { } @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { final List debugTools = ConnectionPlugin.getDebugTools(device); if (debugTools == null || debugTools.size() ==0) @@ -274,7 +273,12 @@ class InstallProgress implements IRunnableWithProgress { boolean isInstalled = false; for (int i=0 ; i +* YoonKi Park +* + * Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Contributors: +* - S-Core Co., Ltd +* +*/ +package com.samsung.tizen.common.connection.debugtools; + +import org.eclipse.osgi.util.NLS; + +public class ToolsInstallMessages extends NLS { + + static { + NLS.initializeMessages(ToolsInstallMessages.class.getName(), ToolsInstallMessages.class); + } + + public static String DIALOG_INITILIZE; + public static String CANNOT_CREATE_DIRECTORY; + public static String CANNOT_CHECK_DIRECTORY; + public static String CANNOT_CHECK_INSTALLED; + public static String CANNOT_COPY_FILE; + public static String CANNOT_REMOVE_CONTROLFILE; + +} diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/ToolsInstallMessages.properties b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/ToolsInstallMessages.properties new file mode 100644 index 0000000..5d83979 --- /dev/null +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/ToolsInstallMessages.properties @@ -0,0 +1,8 @@ + +DIALOG_INITILIZE=Connection Explorer is initializing now. It might take few minutes. +CANNOT_CREATE_DIRECTORY=Cannot create sdk tools directory +CANNOT_CHECK_DIRECTORY=Cannot check sdk tools directory +CANNOT_CHECK_INSTALLED=Cannot check installed tools +CANNOT_COPY_FILE=Cannot copy file +CANNOT_REMOVE_CONTROLFILE=Cannot copy file + diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/messages.properties b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/messages.properties deleted file mode 100644 index 982fa4b..0000000 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/messages.properties +++ /dev/null @@ -1,2 +0,0 @@ - -debugtools.initilize=Connection Explorer is initializing now. It might take few minutes. -- 2.7.4