Skip to content

Commit 92bb470

Browse files
committed
Cap .'s per line in env building
1 parent 95c1a41 commit 92bb470

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/main/java/org/scijava/plugins/scripting/python/RebuildEnvironment.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.nio.file.Files;
3535
import java.nio.file.Path;
3636
import java.util.Comparator;
37+
import java.util.function.Consumer;
3738
import java.util.stream.Stream;
3839

3940
import org.apposed.appose.Appose;
@@ -55,6 +56,8 @@
5556
@Plugin(type = Command.class, label = "Rebuild Python environment")
5657
public class RebuildEnvironment implements Command {
5758

59+
private static final int _PROGRESS_LENGTH = 80;
60+
5861
@Parameter
5962
private AppService appService;
6063

@@ -70,6 +73,8 @@ public class RebuildEnvironment implements Command {
7073
@Parameter(required = false)
7174
private UIService uiService;
7275

76+
private int progressPrinted = 0;
77+
7378
// -- OptionsPython methods --
7479

7580
@Override
@@ -150,12 +155,25 @@ public void run() {
150155
}
151156

152157
private void reportErr(String s) {
153-
if (s.isEmpty()) System.err.print(".");
154-
else log.error(s);
158+
report(s, log::error);
155159
}
156160

157161
private void reportMsg(String s) {
158-
if (s.isEmpty()) System.err.print(".");
159-
else log.info(s);
162+
report(s, log::info);
160163
}
164+
165+
private void report(String s, Consumer<String> reporter) {
166+
if (s.isEmpty()) {
167+
System.err.print(".");
168+
progressPrinted++;
169+
if (progressPrinted >= _PROGRESS_LENGTH) {
170+
System.err.println();
171+
progressPrinted = 0;
172+
}
173+
}
174+
else {
175+
progressPrinted = 0;
176+
reporter.accept(s);
177+
}
178+
}
161179
}

0 commit comments

Comments
 (0)