Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Commit 46f4ced

Browse files
committed
Minor fixes
1 parent 5cc818e commit 46f4ced

1 file changed

Lines changed: 4 additions & 28 deletions

File tree

‎src/main/java/org/scijava/jupyter/evaluator/DefaultEvaluator.java‎

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,16 @@
2323
import java.io.IOException;
2424
import java.io.Reader;
2525
import java.io.StringReader;
26-
import java.io.StringWriter;
27-
import java.io.Writer;
2826
import java.lang.reflect.InvocationTargetException;
2927
import java.util.ArrayList;
3028
import java.util.List;
31-
import javax.script.ScriptContext;
3229
import javax.script.ScriptEngine;
3330

3431
import org.scijava.Context;
3532
import org.scijava.convert.ConvertService;
3633
import org.scijava.log.LogService;
3734
import org.scijava.module.ModuleException;
3835
import org.scijava.module.ModuleItem;
39-
import org.scijava.module.ModuleService;
4036
import org.scijava.plugin.Parameter;
4137
import org.scijava.script.ScriptInfo;
4238
import org.scijava.script.ScriptLanguage;
@@ -89,9 +85,6 @@ public void setShellOptions(KernelParameters kp) throws IOException {
8985
public AutocompleteResult autocomplete(String code, int i) {
9086
List<String> matches = new ArrayList<>();
9187
matches.add("Autocompletion does not work yet.");
92-
matches.add("Test Autocompletion 1");
93-
matches.add("Test Autocompletion 2");
94-
matches.add("Test Autocompletion 3");
9588
int startIndex = 0;
9689
AutocompleteResult ac = new AutocompleteResult(matches, startIndex);
9790
return ac;
@@ -100,7 +93,7 @@ public AutocompleteResult autocomplete(String code, int i) {
10093
@Override
10194
public void killAllThreads() {
10295
log.debug("Kill All Threads");
103-
// Ugly !
96+
// Ugly and not working :-(
10497
System.exit(0);
10598
}
10699

@@ -119,6 +112,8 @@ public void startWorker() {
119112
@Override
120113
public void exit() {
121114
log.debug("Exiting DefaultEvaluator");
115+
// Ugly and not working :-(
116+
System.exit(0);
122117
}
123118

124119
private void setLanguage(String languageName) {
@@ -144,9 +139,6 @@ public class Worker implements Runnable {
144139
@Parameter
145140
private LogService log;
146141

147-
@Parameter
148-
private ModuleService moduleService;
149-
150142
@Parameter
151143
private Context context;
152144

@@ -173,8 +165,6 @@ public void setup(SimpleEvaluationObject seo, String code) {
173165
@Override
174166
public void run() {
175167

176-
final Writer output = new StringWriter();
177-
final Writer error = new StringWriter();
178168
final Reader input = new StringReader(this.code);
179169

180170
ScriptInfo info = new ScriptInfo(context, "dummy.py", input);
@@ -191,21 +181,16 @@ public void run() {
191181
this.engine.put(ScriptEngine.FILENAME, path);
192182
this.engine.put(ScriptModule.class.getName(), module);
193183

194-
final ScriptContext scriptContext = engine.getContext();
195-
196184
// Populate input annotation values
197185
for (final ModuleItem<?> item : info.inputs()) {
198186
final String name = item.getName();
199187
this.engine.put(name, module.getInput(name));
200188
}
201189

202-
this.engine.put("test_context", context);
203-
204190
// Execute the code
205191
Object returnValue = null;
206192
try {
207-
final Reader reader = info.getReader();
208-
returnValue = engine.eval(reader);
193+
returnValue = this.engine.eval(info.getReader());
209194
this.seo.finished(returnValue);
210195

211196
} catch (Throwable e) {
@@ -236,15 +221,6 @@ public void run() {
236221
//module.setOutput(name, typed);
237222
}
238223

239-
// flush output and error streams
240-
if (output != null) {
241-
try {
242-
output.flush();
243-
} catch (final IOException e) {
244-
log.error(e);
245-
}
246-
}
247-
248224
} catch (ModuleException ex) {
249225
log.error(ex);
250226
}

0 commit comments

Comments
 (0)