annotate SMART/Java/Installer/Old/SmartInstallerTask.java @ 20:c265f13066d8

Deleted selected files
author m-zytnicki
date Mon, 29 Apr 2013 03:24:43 -0400
parents 769e306b7933
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 import java.util.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 import java.awt.event.ActionEvent;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 import java.awt.event.ActionListener;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 import java.io.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 import javax.swing.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 import javax.swing.filechooser.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 import javax.swing.border.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 import javax.swing.SwingUtilities;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 import java.net.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 import java.util.Stack;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 import java.util.zip.ZipEntry;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 import java.util.zip.ZipInputStream;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 public class SmartInstallerTask extends SwingWorker<Boolean, String> {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 int BUFFER = 1024;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 int architecture = 0;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 String installDirectoryName = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 JTextArea logArea = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 boolean[] selectedPrograms = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 // program chooser buttons
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 String programChoosers[] = {"R", "R Color Brewer Package", "R HMisc Package", "MySQL", "MySQL account", "Python 2.6", "Python DB", "S-MART"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 // Web addresses for the tools
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 String packageAddresses[][] = {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 {"http://cran.cict.fr/bin/windows/base/R-2.11.0-win32.exe", "http://cran.cict.fr/bin/windows64/base/R-2.11.0-win64.exe"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 {"", ""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30 {"", ""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 {"http://mirrors.ircam.fr/pub/mysql/Downloads/MySQL-5.1/mysql-essential-5.1.47-win32.msi", "http://mirrors.ircam.fr/pub/mysql/Downloads/MySQL-5.1/mysql-essential-5.1.47-winx64.msi"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 {"", ""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 {"http://www.python.org/ftp/python/2.6.5/python-2.6.5.msi", "http://www.python.org/ftp/python/2.6.5/python-2.6.5.amd64.msi"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 {"http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe", "http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 {"http://urgi.versailles.inra.fr/download/s-mart/s-mart.zip", "http://urgi.versailles.inra.fr/download/s-mart/s-mart.zip"}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 };
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 // Packages to install
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 String rPackages[] = {"RColorBrewer", "Hmisc"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 // Script lines
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 String scriptLines[][] = {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 {"\"<INSTALLDIR>\\R-2.11.0-win32.exe\"", "\"<INSTALLDIR>\\R-2.11.0-win64.exe\""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44 {"\"<RFILE>\" CMD BATCH \"<INSTALLDIR>\\installRColorBrewer.R\"", "\"<RFILE>\" CMD BATCH \"<INSTALLDIR>\\installRColorBrewer.R\""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45 {"\"<RFILE>\" CMD BATCH \"<INSTALLDIR>\\installHmisc.R\"", "\"<RFILE>\" CMD BATCH \"<INSTALLDIR>\\installHmisc.R\""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 {"msiexec /i \"<INSTALLDIR>\\mysql-essential-5.1.47-win32.msi\"", "msiexec /i \"<INSTALLDIR>\\mysql-essential-5.1.47-winx64.msi\""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 {"", ""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 {"msiexec /i \"<INSTALLDIR>\\python-2.6.5.msi\"", "msiexec /i \"<INSTALLDIR>\\python-2.6.5.amd64.msi\""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 {"<INSTALLDIR>\\MySQL-python-1.2.2.win32-py2.6.exe", "<INSTALLDIR>\\MySQL-python-1.2.2.win32-py2.6.exe"},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 {"", ""}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 };
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53 // Files to uncompress
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 String compressedFiles[][] = {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 {"", ""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 {"", ""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57 {"", ""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 {"", ""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 {"", ""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60 {"", ""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 {"", ""},
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62 {"<INSTALLDIR>\\s-mart.zip", "<INSTALLDIR>\\s-mart.zip"}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63 };
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66 public SmartInstallerTask(JTextArea ta, boolean[] b, String s, int a) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67 logArea = ta;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 selectedPrograms = b;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69 installDirectoryName = s;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70 architecture = a;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 @Override
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 public Boolean doInBackground() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 boolean installOk;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77 publish("Starting install\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78 writeFiles();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79 for (int i = 0; i < selectedPrograms.length; i++) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 if (selectedPrograms[i]) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81 if (! install(i)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82 return Boolean.FALSE;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 removeFiles();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87 setEnvironmentVariables();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88 publish("Ending install\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89 return Boolean.TRUE;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93 @Override
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 protected void process(List<String> chunks) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95 for (String chunk: chunks) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96 logArea.append(chunk);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101 private boolean launch(String command) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102 return realLaunch(new ProcessBuilder(command), command);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105 private boolean launch(String[] command) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 return realLaunch(new ProcessBuilder(command), Arrays.toString(command));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109 private boolean realLaunch(ProcessBuilder pb, String command) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110 BufferedReader outputReader;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 pb = pb.redirectErrorStream(true);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112 Process process = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113 publish(" Starting command '" + command + "'\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 process = pb.start();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 BufferedInputStream outputStream = new BufferedInputStream(process.getInputStream());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 InputStream is = process.getInputStream();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118 InputStreamReader isr = new InputStreamReader(is);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119 outputReader = new BufferedReader(isr);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121 catch (Exception exception) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 publish(" !Process cannot be started (command is '" + command + "')!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123 exception.printStackTrace();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126 if (outputReader == null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 publish(" !Problem in the output of the command!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 else {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131 publish(" Output is:\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133 publish(" ---\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134 String line;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135 while ((line = outputReader.readLine()) != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 publish(" " + line + "\r\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138 publish(" ---\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140 catch (IOException e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141 publish(" !Cannot get the output of the command!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145 int exitValue = process.exitValue();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146 if (exitValue != 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147 publish(" !Problem during the execution of the command '" + command + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150 publish(" Ending command '" + command + "'\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155 private File lookForFile(String fileName, String[] putativePlaces) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156 publish(" Looking for file " + fileName + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157 for (String place: putativePlaces) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 File file = new File(place, fileName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159 publish(" Look at " + file.getAbsolutePath() + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160 if (file.exists()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161 publish(" Found it in expected place " + file.getAbsolutePath() + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162 return file;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165 Stack<File> files = new Stack<File>();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166 files.push(new File("\\"));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 while (! files.empty()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168 File file = files.pop();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169 for (File childFile: file.listFiles()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 if (childFile.isDirectory()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 files.push(childFile);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173 else {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 if (fileName.compareToIgnoreCase(childFile.getName()) == 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175 publish(" Found it in unexpected place " + childFile.getAbsolutePath() + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176 return childFile;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181 publish(" !Cannot file file '" + fileName + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182 return null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186 private boolean writeFile(String fileName, String content) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 FileWriter fw = new FileWriter(fileName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189 BufferedWriter bw = new BufferedWriter(fw);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190 bw.write(content);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 bw.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192 fw.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194 catch (Exception e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195 publish(" !Cannot write file '" + fileName + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202 private boolean removeFile(String fileName) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 File file = new File(fileName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204 if (file.exists()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205 if (! file.delete()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206 publish(" !Cannot delete file '" + file.getAbsolutePath() + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214 private boolean writeFiles() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215 for (String rPackage: rPackages) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216 String fileName = installDirectoryName + File.separator + "install" + rPackage + ".R";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217 String content = "install.packages(\"" + rPackage + "\", repos = \"http://cran.cict.fr\", dependencies = TRUE)\n";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 if (! writeFile(fileName, content)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 publish(" !Cannot write file for R package '" + rPackage + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223 String fileName = installDirectoryName + File.separator + "createUser.sql";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224 String content = "CREATE USER 'smart'@'localhost';\nGRANT ALL PRIVILEGES ON *.* TO 'smart'@'localhost' WITH GRANT OPTION;\nCREATE DATABASE smart;\nGRANT ALL ON smart.* TO 'smart'@'localhost';\n";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
225 if (! writeFile(fileName, content)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
226 publish(" !Cannot write mySQL configuration file!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
227 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
228 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
229 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
230 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
231
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
232 private boolean removeFiles() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
233 for (String rPackage: rPackages) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
234 File file = new File(installDirectoryName + File.separator + "install" + rPackage + ".R");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
235 if (! file.delete()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
236 publish("!Cannot delete R install file for " + rPackage + "!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
237 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
238 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
239 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
240 File file = new File(installDirectoryName + File.separator + "createUser.sql");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
241 if (! file.delete()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
242 publish("!Cannot delete mySQL configuration file!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
243 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
244 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
245 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
246 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
247
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
248 private boolean install(int element) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
249 publish(" Starting install of " + programChoosers[element] + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
250 downloadPackage(element);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
251 executeInstall(element);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
252 uncompressPackage(element);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
253 removePackage(element);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
254 postProcess(element);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
255 publish(" Ending install of " + programChoosers[element] + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
256 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
257 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
258
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
259
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
260 private String getLocalName(String remoteName) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
261 String localName = installDirectoryName + File.separator + (new File(remoteName)).getName();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
262 int position = localName.indexOf("?");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
263 if (position >= 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
264 localName = localName.substring(0, position);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
265 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
266 return localName;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
267 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
268
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
269
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
270 private boolean downloadPackage(int element) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
271 String fileName = packageAddresses[element][architecture];
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
272 if (! "".equals(fileName)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
273 publish(" Starting download of " + programChoosers[element] + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
274 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
275 BufferedInputStream bis = new BufferedInputStream(new URL(fileName).openStream());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
276 FileOutputStream fos = new FileOutputStream(getLocalName(fileName));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
277 BufferedOutputStream bos = new BufferedOutputStream(fos, BUFFER);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
278 byte[] data = new byte[BUFFER];
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
279 int x = 0;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
280 while((x = bis.read(data, 0, BUFFER)) >= 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
281 bos.write(data, 0, x);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
282 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
283 bos.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
284 fos.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
285 bis.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
286 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
287 catch (IOException e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
288 publish(" !Cannot download file '" + fileName + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
289 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
290 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
291 publish(" Ending download of " + programChoosers[element] + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
292 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
293 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
294 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
295
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
296
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
297 private String replaceSubstring(String line) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
298 if (line.contains("<INSTALLDIR>")) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
299 String protectedDirectory = installDirectoryName.replaceAll("\\\\", "\\\\\\\\");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
300 line = line.replaceAll("<INSTALLDIR>", protectedDirectory);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
301 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
302 if (line.contains("<RFILE>")) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
303 String userName = System.getenv().get("USERNAME");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
304 String[] possibleRDirectories = {"C:\\Program Files\\R-2.11.0", "C:\\Documents and Settings\\" + userName + "\\Mes documents\\R\\R-2.11.0\\bin", "C:\\Documents and Settings\\" + userName + "\\My documents\\R\\R-2.11.0\\bin"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
305 String rDirectory = lookForFile("'.exe", possibleRDirectories).getAbsolutePath();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
306 rDirectory = rDirectory.replaceAll("\\\\", "\\\\\\\\");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
307 line = line.replaceAll("<RFILE>", rDirectory);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
308 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
309 if (line.contains("<MYSQLFILE>")) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
310 String userName = System.getenv().get("USERNAME");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
311 String[] possibleRDirectories = {"C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin", "C:\\Documents and Settings\\" + userName + "\\Mes documents\\MySQL\\MySQL Server 5.1\\bin", "C:\\Documents and Settings\\" + userName + "\\My documents\\MySQL\\MySQL Server 5.1\\bin"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
312 String rDirectory = lookForFile("mysql.exe", possibleRDirectories).getAbsolutePath();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
313 rDirectory = rDirectory.replaceAll("\\\\", "\\\\\\\\");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
314 line = line.replaceAll("<MYSQLFILE>", rDirectory);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
315 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
316 return line;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
317 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
318
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
319
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
320 private boolean executeInstall(int element) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
321 String commands = scriptLines[element][architecture];
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
322 if (! "".equals(commands)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
323 for (String command: commands.split(";")) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
324 command = replaceSubstring(command);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
325 publish(" Starting command '" + command + "'\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
326 Process process = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
327 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
328 process = Runtime.getRuntime().exec(command);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
329 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
330 catch (IOException e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
331 publish(" !Cannot execute command '" + command + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
332 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
333 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
334 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
335 process.waitFor();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
336 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
337 catch (InterruptedException e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
338 publish(" !Cannot wait for the end of the command '" + command + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
339 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
340 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
341 int exitValue = process.exitValue();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
342 if (exitValue != 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
343 publish(" !Problem during the execution of the command '" + command + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
344 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
345 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
346 publish(" Ending command '" + command + "'\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
347 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
348 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
349 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
350 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
351
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
352
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
353 private boolean uncompressPackage(int element) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
354 String file = compressedFiles[element][architecture];
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
355 if (! "".equals(file)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
356 file = replaceSubstring(file);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
357 publish(" Starting uncompressing file '" + file + "'\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
358 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
359 FileInputStream fis = new FileInputStream(file);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
360 BufferedInputStream bis = new BufferedInputStream(fis);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
361 ZipInputStream zis = new ZipInputStream(bis);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
362 ZipEntry entry;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
363 while ((entry = zis.getNextEntry()) != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
364 if (! entry.isDirectory()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
365 File newFile = new File(installDirectoryName + File.separator + entry.getName());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
366 // create parent directories
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
367 File upDirectory = newFile.getParentFile();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
368 while (upDirectory != null){
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
369 if (! upDirectory.exists()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
370 upDirectory.mkdir();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
371 publish(" Creating directory '" + upDirectory.getAbsolutePath() + "'\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
372 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
373 upDirectory = upDirectory.getParentFile();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
374 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
375 // write the files to the disk
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
376 publish(" Extracting '" + entry.getName() + "' to '" + newFile.getAbsolutePath() + "'\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
377 int count;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
378 byte data[] = new byte[BUFFER];
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
379 FileOutputStream fos = new FileOutputStream(newFile);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
380 BufferedOutputStream bos = new BufferedOutputStream(fos, BUFFER);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
381 while ((count = zis.read(data, 0, BUFFER)) != -1){
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
382 bos.write(data, 0, count);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
383 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
384 bos.flush();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
385 bos.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
386 fos.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
387 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
388 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
389 zis.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
390 bis.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
391 fis.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
392 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
393 catch(FileNotFoundException e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
394 publish(" !Cannot find file '" + file + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
395 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
396 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
397 catch(Exception e){
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
398 publish(" !Cannot uncompress file '" + file + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
399 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
400 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
401 publish(" Ending uncompressing file '" + file + "'\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
402 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
403 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
404 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
405
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
406
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
407 private boolean removePackage(int element) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
408 String packageName = packageAddresses[element][architecture];
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
409 if ("".equals(packageName)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
410 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
411 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
412 String fileName = getLocalName(packageAddresses[element][architecture]);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
413 return removeFile(fileName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
414 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
415
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
416
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
417 private boolean postProcess(int element) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
418 switch (element) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
419 case 4:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
420 // Create mySQL user
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
421 PasswordAsker pa = new PasswordAsker();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
422 if (! pa.waitForPassword()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
423 publish("Problem in the password asker!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
424 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
425 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
426 String command = "\"<MYSQLFILE>\" --user=root --password=" + pa.getPassword() + " -e \"source <INSTALLDIR>\\createUser.sql\"";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
427 command = replaceSubstring(command);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
428 if (! launch(command)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
429 publish(" !Cannot create SQL accounts!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
430 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
431 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
432 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
433 case 7:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
434 // Move S-MART files to parent directory
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
435 File installDirectory = new File(installDirectoryName + File.separator + "S-Mart");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
436 for (File file: installDirectory.listFiles()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
437 File destinationFile = new File(file.getParentFile().getParentFile(), file.getName());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
438 if (! file.renameTo(destinationFile)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
439 publish(" !Cannot move '" + file.getAbsolutePath() + "' to '" + destinationFile.getAbsolutePath() + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
440 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
441 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
442 if (! installDirectory.delete()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
443 publish(" !Cannot remove installation S-MART directory '" + installDirectory.getAbsolutePath() + "'!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
444 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
445 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
446 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
447 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
448
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
449
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
450 private boolean setEnvironmentVariables() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
451 String[] command = {"REG", "ADD", "HKCU\\Environment", "/v", "PYTHONPATH", "/t", "REG_SZ", "/d", "\"" + installDirectoryName + "\\Python\"", "/f"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
452 return launch(command);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
453 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
454 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
455