| author | wenzelm |
| Wed, 15 Oct 2025 15:52:29 +0200 | |
| changeset 83285 | ec2bd302560c |
| parent 83284 | a1caad269354 |
| child 83286 | f772c9234f7f |
| permissions | -rw-r--r-- |
| 61276 | 1 |
/* Title: Pure/System/progress.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Progress context for system processes. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
| 73897 | 10 |
import java.util.{Map => JMap}
|
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
11 |
import scala.collection.mutable |
| 64201 | 12 |
|
13 |
||
| 75393 | 14 |
object Progress {
|
| 78503 | 15 |
/* output */ |
16 |
||
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
17 |
sealed abstract class Msg {
|
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
18 |
def verbose: Boolean |
|
83285
ec2bd302560c
support explicit message status, e.g. for specific output;
wenzelm
parents:
83284
diff
changeset
|
19 |
def status: Boolean |
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
20 |
def message: Message |
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
21 |
} |
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
22 |
|
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
23 |
type Output = List[Msg] |
| 78155 | 24 |
|
| 83284 | 25 |
def output_theory(msg: Msg): Msg = |
26 |
msg match {
|
|
27 |
case thy: Theory if thy.verbose => thy.copy(verbose = false) |
|
28 |
case _ => msg |
|
29 |
} |
|
30 |
||
| 78611 | 31 |
enum Kind { case writeln, warning, error_message }
|
| 78503 | 32 |
sealed case class Message( |
| 78611 | 33 |
kind: Kind, |
| 78503 | 34 |
text: String, |
|
83285
ec2bd302560c
support explicit message status, e.g. for specific output;
wenzelm
parents:
83284
diff
changeset
|
35 |
override val verbose: Boolean = false, |
|
ec2bd302560c
support explicit message status, e.g. for specific output;
wenzelm
parents:
83284
diff
changeset
|
36 |
override val status: Boolean = false |
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
37 |
) extends Msg {
|
| 78503 | 38 |
override def message: Message = this |
39 |
||
| 83270 | 40 |
lazy val output_text: String = |
|
77502
2e2b2bd6b2d2
clarified signature: require just one "override def echo(message: Progress.Message): Unit";
wenzelm
parents:
77499
diff
changeset
|
41 |
kind match {
|
|
2e2b2bd6b2d2
clarified signature: require just one "override def echo(message: Progress.Message): Unit";
wenzelm
parents:
77499
diff
changeset
|
42 |
case Kind.writeln => Output.writeln_text(text) |
|
2e2b2bd6b2d2
clarified signature: require just one "override def echo(message: Progress.Message): Unit";
wenzelm
parents:
77499
diff
changeset
|
43 |
case Kind.warning => Output.warning_text(text) |
|
2e2b2bd6b2d2
clarified signature: require just one "override def echo(message: Progress.Message): Unit";
wenzelm
parents:
77499
diff
changeset
|
44 |
case Kind.error_message => Output.error_message_text(text) |
|
2e2b2bd6b2d2
clarified signature: require just one "override def echo(message: Progress.Message): Unit";
wenzelm
parents:
77499
diff
changeset
|
45 |
} |
|
2e2b2bd6b2d2
clarified signature: require just one "override def echo(message: Progress.Message): Unit";
wenzelm
parents:
77499
diff
changeset
|
46 |
|
|
2e2b2bd6b2d2
clarified signature: require just one "override def echo(message: Progress.Message): Unit";
wenzelm
parents:
77499
diff
changeset
|
47 |
override def toString: String = output_text |
|
2e2b2bd6b2d2
clarified signature: require just one "override def echo(message: Progress.Message): Unit";
wenzelm
parents:
77499
diff
changeset
|
48 |
} |
|
2e2b2bd6b2d2
clarified signature: require just one "override def echo(message: Progress.Message): Unit";
wenzelm
parents:
77499
diff
changeset
|
49 |
|
| 78503 | 50 |
sealed case class Theory( |
51 |
theory: String, |
|
52 |
session: String = "", |
|
| 83223 | 53 |
percentage: Option[Int] = None, |
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
54 |
total_time: Time = Time.zero, |
|
83285
ec2bd302560c
support explicit message status, e.g. for specific output;
wenzelm
parents:
83284
diff
changeset
|
55 |
override val verbose: Boolean = true, |
|
ec2bd302560c
support explicit message status, e.g. for specific output;
wenzelm
parents:
83284
diff
changeset
|
56 |
override val status: Boolean = false |
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
57 |
) extends Msg {
|
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
58 |
override def message: Message = |
| 83223 | 59 |
Message(Kind.writeln, print_session + print_theory + print_percentage + print_total_time, |
|
83285
ec2bd302560c
support explicit message status, e.g. for specific output;
wenzelm
parents:
83284
diff
changeset
|
60 |
verbose = verbose, status = status) |
| 68987 | 61 |
|
| 77504 | 62 |
def print_session: String = if_proper(session, session + ": ") |
| 68987 | 63 |
def print_theory: String = "theory " + theory |
64 |
def print_percentage: String = |
|
65 |
percentage match { case None => "" case Some(p) => " " + p + "%" }
|
|
| 83223 | 66 |
def print_total_time: String = |
67 |
if (total_time.is_relevant) " (" + total_time.message + " elapsed time)" else ""
|
|
| 68957 | 68 |
} |
|
83214
911fbc338de7
clarified signature: more explicit type Progress.Nodes_Status;
wenzelm
parents:
83205
diff
changeset
|
69 |
|
|
911fbc338de7
clarified signature: more explicit type Progress.Nodes_Status;
wenzelm
parents:
83205
diff
changeset
|
70 |
sealed case class Nodes_Status( |
|
911fbc338de7
clarified signature: more explicit type Progress.Nodes_Status;
wenzelm
parents:
83205
diff
changeset
|
71 |
domain: List[Document.Node.Name], |
| 83223 | 72 |
document_status: Document_Status.Nodes_Status, |
| 83227 | 73 |
session: String = "", |
74 |
old: Option[Document_Status.Nodes_Status] = None |
|
|
83214
911fbc338de7
clarified signature: more explicit type Progress.Nodes_Status;
wenzelm
parents:
83205
diff
changeset
|
75 |
) {
|
| 83223 | 76 |
def apply(name: Document.Node.Name): Document_Status.Node_Status = |
77 |
document_status(name) |
|
78 |
||
79 |
def theory(name: Document.Node.Name): Theory = {
|
|
80 |
val node_status = apply(name) |
|
| 83229 | 81 |
Theory(theory = name.theory, session = session, |
82 |
percentage = Some(node_status.percentage), |
|
83 |
total_time = node_status.total_timing.elapsed) |
|
| 83223 | 84 |
} |
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
85 |
|
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
86 |
def theory_progress(name: Document.Node.Name, check: (Int, Int) => Boolean): Option[Theory] = {
|
| 83283 | 87 |
val thy = theory(name) |
88 |
val thy_percentage = thy.percentage.getOrElse(0) |
|
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
89 |
val old_percentage = if (old.isEmpty) 0 else old.get(name).percentage |
| 83283 | 90 |
if (check(thy_percentage, old_percentage)) Some(thy) else None |
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
91 |
} |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
92 |
|
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
93 |
def completed_theories: List[Theory] = |
| 83283 | 94 |
domain.flatMap(theory_progress(_, (p, q) => p != q && p == 100)) |
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
95 |
|
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
96 |
def status_theories: List[Theory] = {
|
| 83283 | 97 |
val result = new mutable.ListBuffer[Theory] |
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
98 |
// pending theories |
| 83283 | 99 |
for (name <- domain; thy <- theory_progress(name, (p, q) => p == q && p > 0)) result += thy |
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
100 |
// running theories |
| 83283 | 101 |
for (name <- domain; thy <- theory_progress(name, (p, q) => p != q && p < 100)) result += thy |
|
83285
ec2bd302560c
support explicit message status, e.g. for specific output;
wenzelm
parents:
83284
diff
changeset
|
102 |
result.toList.map(thy => thy.copy(status = true)) |
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
103 |
} |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
104 |
} |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
105 |
|
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
106 |
|
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
107 |
/* status lines (e.g. at bottom of output) */ |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
108 |
|
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
109 |
trait Status extends Progress {
|
| 83280 | 110 |
def status_detailed: Boolean = false |
| 83271 | 111 |
def status_hide(status: Progress.Output): Unit = () |
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
112 |
|
| 83271 | 113 |
protected var _status: Progress.Output = Nil |
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
114 |
|
| 83271 | 115 |
def status_clear(): Progress.Output = synchronized {
|
116 |
val status = _status |
|
117 |
_status = Nil |
|
118 |
status_hide(status) |
|
119 |
status |
|
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
120 |
} |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
121 |
|
| 83271 | 122 |
def status_output(status: Progress.Output): Unit = synchronized {
|
123 |
_status = Nil |
|
124 |
output(status) |
|
125 |
_status = status |
|
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
126 |
} |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
127 |
|
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
128 |
override def output(msgs: Progress.Output): Unit = synchronized {
|
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
129 |
if (msgs.exists(do_output)) {
|
| 83271 | 130 |
val status = status_clear() |
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
131 |
super.output(msgs) |
| 83271 | 132 |
status_output(status) |
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
133 |
} |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
134 |
} |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
135 |
|
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
136 |
override def nodes_status(nodes_status: Progress.Nodes_Status): Unit = synchronized {
|
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
137 |
status_clear() |
| 83271 | 138 |
output(nodes_status.completed_theories) |
| 83280 | 139 |
status_output(if (status_detailed) nodes_status.status_theories else Nil) |
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
140 |
} |
|
83214
911fbc338de7
clarified signature: more explicit type Progress.Nodes_Status;
wenzelm
parents:
83205
diff
changeset
|
141 |
} |
|
68410
4e27f5c361d2
clarified signature: more uniform theory_message (see also d7920eb7de54);
wenzelm
parents:
68330
diff
changeset
|
142 |
} |
|
4e27f5c361d2
clarified signature: more uniform theory_message (see also d7920eb7de54);
wenzelm
parents:
68330
diff
changeset
|
143 |
|
| 75393 | 144 |
class Progress {
|
| 78876 | 145 |
def now(): Date = Date.now() |
146 |
val start: Date = now() |
|
147 |
||
|
77509
3bc49507bae5
clarified treatment of "verbose" messages, e.g. Progress.theory();
wenzelm
parents:
77507
diff
changeset
|
148 |
def verbose: Boolean = false |
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
149 |
final def do_output(msg: Progress.Msg): Boolean = !msg.verbose || verbose |
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
150 |
|
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
151 |
def output(msgs: Progress.Output): Unit = {}
|
|
77509
3bc49507bae5
clarified treatment of "verbose" messages, e.g. Progress.theory();
wenzelm
parents:
77507
diff
changeset
|
152 |
|
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
153 |
final def output_text(msgs: Progress.Output, terminate: Boolean = false): String = {
|
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
154 |
val lines = msgs.flatMap(msg => if (do_output(msg)) Some(msg.message.output_text) else None) |
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
155 |
if (terminate) Library.terminate_lines(lines) else cat_lines(lines) |
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
156 |
} |
|
77502
2e2b2bd6b2d2
clarified signature: require just one "override def echo(message: Progress.Message): Unit";
wenzelm
parents:
77499
diff
changeset
|
157 |
|
|
77509
3bc49507bae5
clarified treatment of "verbose" messages, e.g. Progress.theory();
wenzelm
parents:
77507
diff
changeset
|
158 |
final def echo(msg: String, verbose: Boolean = false): Unit = |
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
159 |
output(List(Progress.Message(Progress.Kind.writeln, msg, verbose = verbose))) |
|
77509
3bc49507bae5
clarified treatment of "verbose" messages, e.g. Progress.theory();
wenzelm
parents:
77507
diff
changeset
|
160 |
final def echo_warning(msg: String, verbose: Boolean = false): Unit = |
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
161 |
output(List(Progress.Message(Progress.Kind.warning, msg, verbose = verbose))) |
|
77509
3bc49507bae5
clarified treatment of "verbose" messages, e.g. Progress.theory();
wenzelm
parents:
77507
diff
changeset
|
162 |
final def echo_error_message(msg: String, verbose: Boolean = false): Unit = |
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
163 |
output(List(Progress.Message(Progress.Kind.error_message, msg, verbose = verbose))) |
|
77502
2e2b2bd6b2d2
clarified signature: require just one "override def echo(message: Progress.Message): Unit";
wenzelm
parents:
77499
diff
changeset
|
164 |
|
|
77506
a8175b950173
more robust signature: avoid totally adhoc overriding (see also Build_Process.progress vs. build_progress);
wenzelm
parents:
77504
diff
changeset
|
165 |
final def echo_if(cond: Boolean, msg: String): Unit = if (cond) echo(msg) |
|
77499
8fc94efa954a
clarified signature: more uniform Progress.verbose, avoid adhoc "override def theory()";
wenzelm
parents:
77498
diff
changeset
|
166 |
|
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
167 |
final def theory(theory: Progress.Theory): Unit = output(List(theory)) |
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
168 |
|
|
83214
911fbc338de7
clarified signature: more explicit type Progress.Nodes_Status;
wenzelm
parents:
83205
diff
changeset
|
169 |
def nodes_status(nodes_status: Progress.Nodes_Status): Unit = {}
|
| 64909 | 170 |
|
| 78432 | 171 |
final def capture[A](e: => A, msg: String, err: Throwable => String): Exn.Result[A] = {
|
172 |
echo(msg) |
|
173 |
try { Exn.Res(e) }
|
|
174 |
catch { case exn: Throwable => echo_error_message(err(exn)); Exn.Exn[A](exn) }
|
|
175 |
} |
|
176 |
||
|
77506
a8175b950173
more robust signature: avoid totally adhoc overriding (see also Build_Process.progress vs. build_progress);
wenzelm
parents:
77504
diff
changeset
|
177 |
final def timeit[A]( |
|
a8175b950173
more robust signature: avoid totally adhoc overriding (see also Build_Process.progress vs. build_progress);
wenzelm
parents:
77504
diff
changeset
|
178 |
body: => A, |
|
a8175b950173
more robust signature: avoid totally adhoc overriding (see also Build_Process.progress vs. build_progress);
wenzelm
parents:
77504
diff
changeset
|
179 |
message: Exn.Result[A] => String = null, |
|
a8175b950173
more robust signature: avoid totally adhoc overriding (see also Build_Process.progress vs. build_progress);
wenzelm
parents:
77504
diff
changeset
|
180 |
enabled: Boolean = true |
|
77509
3bc49507bae5
clarified treatment of "verbose" messages, e.g. Progress.theory();
wenzelm
parents:
77507
diff
changeset
|
181 |
): A = Timing.timeit(body, message = message, enabled = enabled, output = echo(_)) |
| 65921 | 182 |
|
| 77524 | 183 |
@volatile private var is_stopped = false |
| 73367 | 184 |
def stop(): Unit = { is_stopped = true }
|
| 75393 | 185 |
def stopped: Boolean = {
|
| 73367 | 186 |
if (Thread.interrupted()) is_stopped = true |
|
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71601
diff
changeset
|
187 |
is_stopped |
|
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71601
diff
changeset
|
188 |
} |
|
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71601
diff
changeset
|
189 |
|
|
77506
a8175b950173
more robust signature: avoid totally adhoc overriding (see also Build_Process.progress vs. build_progress);
wenzelm
parents:
77504
diff
changeset
|
190 |
final def interrupt_handler[A](e: => A): A = POSIX_Interrupt.handler { stop() } { e }
|
|
a8175b950173
more robust signature: avoid totally adhoc overriding (see also Build_Process.progress vs. build_progress);
wenzelm
parents:
77504
diff
changeset
|
191 |
final def expose_interrupt(): Unit = if (stopped) throw Exn.Interrupt() |
| 61276 | 192 |
override def toString: String = if (stopped) "Progress(stopped)" else "Progress" |
| 64201 | 193 |
|
|
77506
a8175b950173
more robust signature: avoid totally adhoc overriding (see also Build_Process.progress vs. build_progress);
wenzelm
parents:
77504
diff
changeset
|
194 |
final def bash(script: String, |
| 80230 | 195 |
ssh: SSH.System = SSH.Local, |
|
80224
db92e0b6a11a
clarified signature: prefer symbolic isabelle.Path over physical java.io.File;
wenzelm
parents:
79887
diff
changeset
|
196 |
cwd: Path = Path.current, |
| 82706 | 197 |
env: JMap[String, String] = Isabelle_System.Settings.env(), // ignored for remote ssh |
| 64201 | 198 |
redirect: Boolean = false, |
| 65930 | 199 |
echo: Boolean = false, |
| 80236 | 200 |
watchdog_time: Time = Time.zero, |
| 75393 | 201 |
strict: Boolean = true |
202 |
): Process_Result = {
|
|
| 72599 | 203 |
val result = |
| 80230 | 204 |
Isabelle_System.bash(script, ssh = ssh, cwd = cwd, env = env, redirect = redirect, |
| 72599 | 205 |
progress_stdout = echo_if(echo, _), |
206 |
progress_stderr = echo_if(echo, _), |
|
| 80236 | 207 |
watchdog = Bash.Watchdog(watchdog_time, _ => stopped), |
| 72599 | 208 |
strict = strict) |
209 |
if (strict && stopped) throw Exn.Interrupt() else result |
|
| 64201 | 210 |
} |
| 61276 | 211 |
} |
212 |
||
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
213 |
class Console_Progress( |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
214 |
override val verbose: Boolean = false, |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
215 |
detailed: Boolean = false, |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
216 |
stderr: Boolean = false) |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
217 |
extends Progress with Progress.Status {
|
| 83280 | 218 |
override def status_detailed: Boolean = detailed |
| 83271 | 219 |
override def status_hide(status: Progress.Output): Unit = synchronized {
|
220 |
val txt = output_text(status, terminate = true) |
|
221 |
Output.delete_lines(Library.count_newlines(txt), stdout = !stderr) |
|
|
83266
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
222 |
} |
|
2f75f2495e3e
more detailed Console_Progress via Progress.Status;
wenzelm
parents:
83229
diff
changeset
|
223 |
|
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
224 |
override def output(msgs: Progress.Output): Unit = synchronized {
|
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
225 |
for (msg <- msgs if do_output(msg)) {
|
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
226 |
Output.output(msg.message.output_text, stdout = !stderr, include_empty = true) |
|
77509
3bc49507bae5
clarified treatment of "verbose" messages, e.g. Progress.theory();
wenzelm
parents:
77507
diff
changeset
|
227 |
} |
| 78874 | 228 |
} |
| 77503 | 229 |
|
230 |
override def toString: String = super.toString + ": console" |
|
| 61276 | 231 |
} |
| 65888 | 232 |
|
| 77507 | 233 |
class File_Progress(path: Path, override val verbose: Boolean = false) |
| 83282 | 234 |
extends Progress with Progress.Status {
|
|
83269
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
235 |
override def output(msgs: Progress.Output): Unit = synchronized {
|
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
236 |
val txt = output_text(msgs, terminate = true) |
|
f6de20fbf55f
clarified Progress.output and related operations: prefer bulk messages of general type Progress.Msg;
wenzelm
parents:
83266
diff
changeset
|
237 |
if (txt.nonEmpty) File.append(path, txt) |
| 78874 | 238 |
} |
| 65888 | 239 |
|
| 77503 | 240 |
override def toString: String = super.toString + ": " + path.toString |
| 65888 | 241 |
} |