diff options
author | Noel Power <npower@openoffice.org> | 2003-02-20 18:23:19 +0000 |
---|---|---|
committer | Noel Power <npower@openoffice.org> | 2003-02-20 18:23:19 +0000 |
commit | 5b92c2d56ddf3ff3f547926b8994ed2b5895d8e8 (patch) | |
tree | 75083e6613bc71f02a3bd42a8821d81c10583b3f /scripting/workben/installer | |
parent | c6a562262e396d7dfd7d4e68c7de6222757d1f5f (diff) |
Added new class ExecCmd, this class flushes io from execed programs (ensures they do not hang), Register modified to use ExecCmd. Installer works on windows again.
Diffstat (limited to 'scripting/workben/installer')
-rw-r--r-- | scripting/workben/installer/ExecCmd.java | 78 | ||||
-rw-r--r-- | scripting/workben/installer/Register.java | 36 |
2 files changed, 92 insertions, 22 deletions
diff --git a/scripting/workben/installer/ExecCmd.java b/scripting/workben/installer/ExecCmd.java new file mode 100644 index 000000000000..416d644fe126 --- /dev/null +++ b/scripting/workben/installer/ExecCmd.java @@ -0,0 +1,78 @@ +package installer; +import java.util.*; +import java.io.*; +public class ExecCmd +{ + + public boolean exec( String cmd, String[] env ) + { + System.out.println("About to exectute " + cmd); + final Process p; + boolean result = false; + try + { + Runtime rt = Runtime.getRuntime(); + p=rt.exec( cmd, env ); + new Thread(new Runnable() { + public void run() + { + try + { + BufferedReader br_in = new BufferedReader(new InputStreamReader(p.getInputStream())); + String buff = null; + while ((buff = br_in.readLine()) != null) + { + System.out.println("Process out :" + buff); + /*try + { + Thread.sleep(100); + } + catch(Exception e) {}*/ + } + br_in.close(); + System.out.println("finished reading out"); + } + catch (IOException ioe) + { + System.out.println("Exception caught printing javac result"); + ioe.printStackTrace(); + } + } } ).start(); + + new Thread(new Runnable() { + public void run() { + try { + BufferedReader br_err = new BufferedReader(new InputStreamReader(p.getErrorStream())); + String buff = null; + while ((buff = br_err.readLine()) != null) { + System.out.println("Process err :" + buff); + /*try {Thread.sleep(100); } catch(Exception e) {}*/ + } + br_err.close(); + System.out.println("finished reading err"); + } catch (IOException ioe) { + System.out.println("Exception caught printing javac result"); + ioe.printStackTrace(); + } + } }).start(); + int exitcode = p.waitFor(); + if ( exitcode != 0 ) + { + System.out.println("cmd [" + cmd + "] failed" ); + result= false; + } + else + { + System.out.println("cmd [" + cmd + "] completed successfully"); + result= true; + } + } + catch (Exception e) { + System.out.println("Exception"); + e.printStackTrace(); + } + System.out.println("command complete"); + return result; + } +} + diff --git a/scripting/workben/installer/Register.java b/scripting/workben/installer/Register.java index 22e5391a1d0a..2ec4b6e571a2 100644 --- a/scripting/workben/installer/Register.java +++ b/scripting/workben/installer/Register.java @@ -3,7 +3,6 @@ package installer; import java.lang.String; import java.io.*; import javax.swing.*; - public class Register{ private static String[] singletonDefParams = { "drafts.com.sun.star.script.framework.theScriptRuntimeForJava=drafts.com.sun.star.script.framework.ScriptRuntimeForJava", "drafts.com.sun.star.script.framework.storage.theScriptStorageManager=drafts.com.sun.star.script.framework.storage.ScriptStorageManager", @@ -17,28 +16,24 @@ public class Register{ } private static boolean regSingletons( String path, String progPath, String opSys, JLabel statusLabel ) { try{ - int exitcode=0; - Runtime rt = Runtime.getRuntime(); - Process p; + boolean goodResult = false; String[] env = new String[1]; String regCmd = null; + ExecCmd command = new ExecCmd(); for ( int i=0; i<singletonDefParams.length; i++){ if ( opSys.indexOf( "Windows" ) == -1 ){ // Not windows env[0] = "LD_LIBRARY_PATH=" + progPath; - p=rt.exec("chmod a+x " + progPath + "regsingleton"); - exitcode=p.waitFor(); + command.exec( "chmod a+x " + progPath + "regsingleton", null ); regCmd = progPath + "regsingleton " + path + "user" + File.separator + "uno_packages" + File.separator + "cache" + File.separator + "services.rdb " + singletonDefParams[i]; - p=rt.exec( regCmd, env ); + goodResult = command.exec( regCmd, env ); } else { // Windows regCmd = quotedString( progPath + "regsingleton.exe" ) + " " + quotedString( path + "user" + File.separator + "uno_packages" + File.separator + "cache" + File.separator + "services.rdb" ) + " " + quotedString( singletonDefParams[i] ); - - p=rt.exec( regCmd ); + goodResult = command.exec( regCmd,null ); } - exitcode = p.waitFor(); - if ( exitcode != 0 ){ + if ( !goodResult ){ System.out.println("Regsingleton cmd failed, cmd: " + regCmd ); statusLabel.setText("Regsingleton ScriptRuntimeForJava Failed, please view SFrameworkInstall.log"); return false; @@ -61,14 +56,13 @@ public class Register{ try { String s=null; - int exitcode=0; + boolean goodResult = false; String env[] = new String[1]; - Runtime rt = Runtime.getRuntime(); + ExecCmd command = new ExecCmd(); boolean isWindows = (System.getProperty("os.name").indexOf("Windows") != -1); String progpath = path.concat("program" + File.separator); - Process p; statusLabel.setText("Registering Scripting Framework..."); @@ -82,14 +76,13 @@ public class Register{ if (!isWindows) { env[0]="LD_LIBRARY_PATH=" + progpath; - p = rt.exec("chmod a+x " + progpath + "pkgchk"); - exitcode = p.waitFor(); + goodResult = command.exec("chmod a+x " + progpath + "pkgchk", null ); - if (exitcode == 0){ + if ( goodResult ){ cmd = progpath + "pkgchk " + progpath + packages[i]; System.err.println(cmd); - p=rt.exec(cmd, env); + goodResult = command.exec(cmd, env); } } else { @@ -97,11 +90,10 @@ public class Register{ packages[i] + "\""; System.err.println(cmd); - p=rt.exec(cmd); - } + goodResult =command.exec(cmd,null); - exitcode = p.waitFor(); - if (exitcode != 0) { + } + if (!goodResult) { System.err.println("\nPkgChk Failed"); if(!isWindows) |