author | wenzelm |
Wed, 30 Jun 2021 11:35:07 +0200 | |
changeset 73897 | 0ddb5de0506e |
parent 73702 | 7202e12cb324 |
child 73909 | 1d0d9772fff0 |
permissions | -rw-r--r-- |
64123 | 1 |
/* Title: Pure/General/ssh.scala |
2 |
Author: Makarius |
|
3 |
||
64124 | 4 |
SSH client based on JSch (see also http://www.jcraft.com/jsch/examples). |
64123 | 5 |
*/ |
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
73897 | 10 |
import java.util.{Map => JMap, HashMap} |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
11 |
import java.io.{InputStream, OutputStream, ByteArrayOutputStream} |
64131 | 12 |
|
71358 | 13 |
import scala.collection.mutable |
71601 | 14 |
import scala.util.matching.Regex |
64131 | 15 |
|
64222 | 16 |
import com.jcraft.jsch.{JSch, Logger => JSch_Logger, Session => JSch_Session, SftpException, |
71780 | 17 |
OpenSSHConfig, UserInfo, Channel => JSch_Channel, ChannelExec, ChannelSftp, SftpATTRS, |
18 |
JSchException} |
|
64123 | 19 |
|
20 |
||
21 |
object SSH |
|
22 |
{ |
|
64185 | 23 |
/* target machine: user@host syntax */ |
64141 | 24 |
|
64185 | 25 |
object Target |
64141 | 26 |
{ |
71601 | 27 |
val User_Host: Regex = "^([^@]+)@(.+)$".r |
64141 | 28 |
|
29 |
def parse(s: String): (String, String) = |
|
30 |
s match { |
|
71307 | 31 |
case User_Host(user, host) => (user, host) |
64141 | 32 |
case _ => ("", s) |
33 |
} |
|
34 |
||
35 |
def unapplySeq(s: String): Option[List[String]] = |
|
64185 | 36 |
parse(s) match { |
37 |
case (_, "") => None |
|
38 |
case (user, host) => Some(List(user, host)) |
|
39 |
} |
|
64141 | 40 |
} |
41 |
||
64142 | 42 |
val default_port = 22 |
67745
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
43 |
def make_port(port: Int): Int = if (port > 0) port else default_port |
64142 | 44 |
|
71549 | 45 |
def port_suffix(port: Int): String = |
46 |
if (port == default_port) "" else ":" + port |
|
47 |
||
48 |
def user_prefix(user: String): String = |
|
49 |
proper_string(user) match { |
|
50 |
case None => "" |
|
51 |
case Some(name) => name + "@" |
|
52 |
} |
|
53 |
||
64257 | 54 |
def connect_timeout(options: Options): Int = |
55 |
options.seconds("ssh_connect_timeout").ms.toInt |
|
64141 | 56 |
|
64325 | 57 |
def alive_interval(options: Options): Int = |
58 |
options.seconds("ssh_alive_interval").ms.toInt |
|
59 |
||
67273
c573cfb2c407
more robust connection: prefer ServerAliveCountMax=3 (ssh default) instead of 1 (jsch default);
wenzelm
parents:
67067
diff
changeset
|
60 |
def alive_count_max(options: Options): Int = |
c573cfb2c407
more robust connection: prefer ServerAliveCountMax=3 (ssh default) instead of 1 (jsch default);
wenzelm
parents:
67067
diff
changeset
|
61 |
options.int("ssh_alive_count_max") |
c573cfb2c407
more robust connection: prefer ServerAliveCountMax=3 (ssh default) instead of 1 (jsch default);
wenzelm
parents:
67067
diff
changeset
|
62 |
|
64123 | 63 |
|
64257 | 64 |
/* init context */ |
65 |
||
66 |
def init_context(options: Options): Context = |
|
64123 | 67 |
{ |
64130 | 68 |
val config_dir = Path.explode(options.string("ssh_config_dir")) |
64123 | 69 |
if (!config_dir.is_dir) error("Bad ssh config directory: " + config_dir) |
70 |
||
71 |
val jsch = new JSch |
|
72 |
||
64130 | 73 |
val config_file = Path.explode(options.string("ssh_config_file")) |
64123 | 74 |
if (config_file.is_file) |
75 |
jsch.setConfigRepository(OpenSSHConfig.parseFile(File.platform_path(config_file))) |
|
76 |
||
77 |
val known_hosts = config_dir + Path.explode("known_hosts") |
|
78 |
if (!known_hosts.is_file) known_hosts.file.createNewFile |
|
79 |
jsch.setKnownHosts(File.platform_path(known_hosts)) |
|
80 |
||
64130 | 81 |
val identity_files = |
71601 | 82 |
space_explode(':', options.string("ssh_identity_files")).map(Path.explode) |
71780 | 83 |
for (identity_file <- identity_files if identity_file.is_file) { |
84 |
try { jsch.addIdentity(File.platform_path(identity_file)) } |
|
85 |
catch { |
|
86 |
case exn: JSchException => |
|
87 |
error("Error in ssh identity file " + identity_file + ": " + exn.getMessage) |
|
88 |
} |
|
89 |
} |
|
64123 | 90 |
|
64257 | 91 |
new Context(options, jsch) |
64123 | 92 |
} |
93 |
||
71564
03133befa33b
support actual_host for lrzcloud2: the proxy_host/sshd cannot resolve invented hostname (amending 1d8b6c2253e6);
wenzelm
parents:
71562
diff
changeset
|
94 |
def open_session(options: Options, |
03133befa33b
support actual_host for lrzcloud2: the proxy_host/sshd cannot resolve invented hostname (amending 1d8b6c2253e6);
wenzelm
parents:
71562
diff
changeset
|
95 |
host: String, user: String = "", port: Int = 0, actual_host: String = "", |
67771 | 96 |
proxy_host: String = "", proxy_user: String = "", proxy_port: Int = 0, |
97 |
permissive: Boolean = false): Session = |
|
71564
03133befa33b
support actual_host for lrzcloud2: the proxy_host/sshd cannot resolve invented hostname (amending 1d8b6c2253e6);
wenzelm
parents:
71562
diff
changeset
|
98 |
init_context(options).open_session( |
03133befa33b
support actual_host for lrzcloud2: the proxy_host/sshd cannot resolve invented hostname (amending 1d8b6c2253e6);
wenzelm
parents:
71562
diff
changeset
|
99 |
host = host, user = user, port = port, actual_host = actual_host, |
67771 | 100 |
proxy_host = proxy_host, proxy_user = proxy_user, proxy_port = proxy_port, |
101 |
permissive = permissive) |
|
67067 | 102 |
|
64257 | 103 |
class Context private[SSH](val options: Options, val jsch: JSch) |
104 |
{ |
|
105 |
def update_options(new_options: Options): Context = new Context(new_options, jsch) |
|
106 |
||
71549 | 107 |
private def connect_session(host: String, user: String = "", port: Int = 0, |
67770
25f3a278df3d
support for permissive connections, for odd situations where host keys are not accepted;
wenzelm
parents:
67745
diff
changeset
|
108 |
host_key_permissive: Boolean = false, |
71549 | 109 |
nominal_host: String = "", |
110 |
nominal_user: String = "", |
|
67770
25f3a278df3d
support for permissive connections, for odd situations where host keys are not accepted;
wenzelm
parents:
67745
diff
changeset
|
111 |
on_close: () => Unit = () => ()): Session = |
64257 | 112 |
{ |
71383 | 113 |
val session = jsch.getSession(proper_string(user).orNull, host, make_port(port)) |
64257 | 114 |
|
115 |
session.setUserInfo(No_User_Info) |
|
64325 | 116 |
session.setServerAliveInterval(alive_interval(options)) |
67273
c573cfb2c407
more robust connection: prefer ServerAliveCountMax=3 (ssh default) instead of 1 (jsch default);
wenzelm
parents:
67067
diff
changeset
|
117 |
session.setServerAliveCountMax(alive_count_max(options)) |
64257 | 118 |
session.setConfig("MaxAuthTries", "3") |
67770
25f3a278df3d
support for permissive connections, for odd situations where host keys are not accepted;
wenzelm
parents:
67745
diff
changeset
|
119 |
if (host_key_permissive) session.setConfig("StrictHostKeyChecking", "no") |
71549 | 120 |
if (nominal_host != "") session.setHostKeyAlias(nominal_host) |
64257 | 121 |
|
122 |
if (options.bool("ssh_compression")) { |
|
123 |
session.setConfig("compression.s2c", "zlib@openssh.com,zlib,none") |
|
124 |
session.setConfig("compression.c2s", "zlib@openssh.com,zlib,none") |
|
125 |
session.setConfig("compression_level", "9") |
|
126 |
} |
|
67745
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
127 |
session.connect(connect_timeout(options)) |
71549 | 128 |
new Session(options, session, on_close, |
129 |
proper_string(nominal_host) getOrElse host, |
|
130 |
proper_string(nominal_user) getOrElse user) |
|
67745
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
131 |
} |
64257 | 132 |
|
71564
03133befa33b
support actual_host for lrzcloud2: the proxy_host/sshd cannot resolve invented hostname (amending 1d8b6c2253e6);
wenzelm
parents:
71562
diff
changeset
|
133 |
def open_session( |
03133befa33b
support actual_host for lrzcloud2: the proxy_host/sshd cannot resolve invented hostname (amending 1d8b6c2253e6);
wenzelm
parents:
71562
diff
changeset
|
134 |
host: String, user: String = "", port: Int = 0, actual_host: String = "", |
67770
25f3a278df3d
support for permissive connections, for odd situations where host keys are not accepted;
wenzelm
parents:
67745
diff
changeset
|
135 |
proxy_host: String = "", proxy_user: String = "", proxy_port: Int = 0, |
25f3a278df3d
support for permissive connections, for odd situations where host keys are not accepted;
wenzelm
parents:
67745
diff
changeset
|
136 |
permissive: Boolean = false): Session = |
67745
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
137 |
{ |
71564
03133befa33b
support actual_host for lrzcloud2: the proxy_host/sshd cannot resolve invented hostname (amending 1d8b6c2253e6);
wenzelm
parents:
71562
diff
changeset
|
138 |
val connect_host = proper_string(actual_host) getOrElse host |
03133befa33b
support actual_host for lrzcloud2: the proxy_host/sshd cannot resolve invented hostname (amending 1d8b6c2253e6);
wenzelm
parents:
71562
diff
changeset
|
139 |
if (proxy_host == "") connect_session(host = connect_host, user = user, port = port) |
67745
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
140 |
else { |
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
141 |
val proxy = connect_session(host = proxy_host, port = proxy_port, user = proxy_user) |
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
142 |
|
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
143 |
val fw = |
71564
03133befa33b
support actual_host for lrzcloud2: the proxy_host/sshd cannot resolve invented hostname (amending 1d8b6c2253e6);
wenzelm
parents:
71562
diff
changeset
|
144 |
try { proxy.port_forwarding(remote_host = connect_host, remote_port = make_port(port)) } |
73367 | 145 |
catch { case exn: Throwable => proxy.close(); throw exn } |
67745
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
146 |
|
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
147 |
try { |
67770
25f3a278df3d
support for permissive connections, for odd situations where host keys are not accepted;
wenzelm
parents:
67745
diff
changeset
|
148 |
connect_session(host = fw.local_host, port = fw.local_port, |
71549 | 149 |
host_key_permissive = permissive, |
150 |
nominal_host = host, nominal_user = user, user = user, |
|
73367 | 151 |
on_close = () => { fw.close(); proxy.close() }) |
67745
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
152 |
} |
73367 | 153 |
catch { case exn: Throwable => fw.close(); proxy.close(); throw exn } |
67745
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
154 |
} |
64257 | 155 |
} |
156 |
} |
|
64130 | 157 |
|
64123 | 158 |
|
159 |
/* logging */ |
|
160 |
||
73340 | 161 |
def logging(verbose: Boolean = true, debug: Boolean = false): Unit = |
64123 | 162 |
{ |
163 |
JSch.setLogger(if (verbose) new Logger(debug) else null) |
|
164 |
} |
|
165 |
||
166 |
private class Logger(debug: Boolean) extends JSch_Logger |
|
167 |
{ |
|
168 |
def isEnabled(level: Int): Boolean = level != JSch_Logger.DEBUG || debug |
|
169 |
||
73340 | 170 |
def log(level: Int, msg: String): Unit = |
64123 | 171 |
{ |
172 |
level match { |
|
173 |
case JSch_Logger.ERROR | JSch_Logger.FATAL => Output.error_message(msg) |
|
174 |
case JSch_Logger.WARN => Output.warning(msg) |
|
175 |
case _ => Output.writeln(msg) |
|
176 |
} |
|
177 |
} |
|
178 |
} |
|
179 |
||
180 |
||
64128 | 181 |
/* user info */ |
182 |
||
183 |
object No_User_Info extends UserInfo |
|
184 |
{ |
|
185 |
def getPassphrase: String = null |
|
186 |
def getPassword: String = null |
|
187 |
def promptPassword(msg: String): Boolean = false |
|
188 |
def promptPassphrase(msg: String): Boolean = false |
|
189 |
def promptYesNo(msg: String): Boolean = false |
|
190 |
def showMessage(msg: String): Unit = Output.writeln(msg) |
|
191 |
} |
|
192 |
||
193 |
||
65009 | 194 |
/* port forwarding */ |
195 |
||
65010 | 196 |
object Port_Forwarding |
65009 | 197 |
{ |
65636
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
198 |
def open(ssh: Session, ssh_close: Boolean, |
65010 | 199 |
local_host: String, local_port: Int, remote_host: String, remote_port: Int): Port_Forwarding = |
200 |
{ |
|
201 |
val port = ssh.session.setPortForwardingL(local_host, local_port, remote_host, remote_port) |
|
65636
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
202 |
new Port_Forwarding(ssh, ssh_close, local_host, port, remote_host, remote_port) |
65010 | 203 |
} |
204 |
} |
|
205 |
||
206 |
class Port_Forwarding private[SSH]( |
|
207 |
ssh: SSH.Session, |
|
65636
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
208 |
ssh_close: Boolean, |
65010 | 209 |
val local_host: String, |
210 |
val local_port: Int, |
|
211 |
val remote_host: String, |
|
69393
ed0824ef337e
static type for Library.using: avoid Java 11 warnings on "Illegal reflective access";
wenzelm
parents:
69303
diff
changeset
|
212 |
val remote_port: Int) extends AutoCloseable |
65010 | 213 |
{ |
214 |
override def toString: String = |
|
215 |
local_host + ":" + local_port + ":" + remote_host + ":" + remote_port |
|
216 |
||
73340 | 217 |
def close(): Unit = |
65636
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
218 |
{ |
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
219 |
ssh.session.delPortForwardingL(local_host, local_port) |
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
220 |
if (ssh_close) ssh.close() |
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
221 |
} |
65009 | 222 |
} |
223 |
||
224 |
||
64191 | 225 |
/* Sftp channel */ |
226 |
||
227 |
type Attrs = SftpATTRS |
|
228 |
||
69302 | 229 |
sealed case class Dir_Entry(name: String, is_dir: Boolean) |
64191 | 230 |
{ |
69300
8b6ab9989bcd
is_file/is_dir/read_dir: more uniform treatment of errors and boundary cases, notably for symlinks in ssh;
wenzelm
parents:
67771
diff
changeset
|
231 |
def is_file: Boolean = !is_dir |
64191 | 232 |
} |
233 |
||
234 |
||
64132 | 235 |
/* exec channel */ |
236 |
||
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
237 |
private val exec_wait_delay = Time.seconds(0.3) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
238 |
|
69393
ed0824ef337e
static type for Library.using: avoid Java 11 warnings on "Illegal reflective access";
wenzelm
parents:
69303
diff
changeset
|
239 |
class Exec private[SSH](session: Session, channel: ChannelExec) extends AutoCloseable |
64131 | 240 |
{ |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
241 |
override def toString: String = "exec " + session.toString |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
242 |
|
73340 | 243 |
def close(): Unit = channel.disconnect |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
244 |
|
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
245 |
val exit_status: Future[Int] = |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
246 |
Future.thread("ssh_wait") { |
73702
7202e12cb324
tuned signature --- following hints by IntelliJ IDEA;
wenzelm
parents:
73634
diff
changeset
|
247 |
while (!channel.isClosed) exec_wait_delay.sleep() |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
248 |
channel.getExitStatus |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
249 |
} |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
250 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
251 |
val stdin: OutputStream = channel.getOutputStream |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
252 |
val stdout: InputStream = channel.getInputStream |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
253 |
val stderr: InputStream = channel.getErrStream |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
254 |
|
64166 | 255 |
// connect after preparing streams |
256 |
channel.connect(connect_timeout(session.options)) |
|
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
257 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
258 |
def result( |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
259 |
progress_stdout: String => Unit = (_: String) => (), |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
260 |
progress_stderr: String => Unit = (_: String) => (), |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
261 |
strict: Boolean = true): Process_Result = |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
262 |
{ |
73367 | 263 |
stdin.close() |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
264 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
265 |
def read_lines(stream: InputStream, progress: String => Unit): List[String] = |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
266 |
{ |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
267 |
val result = new mutable.ListBuffer[String] |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
268 |
val line_buffer = new ByteArrayOutputStream(100) |
73340 | 269 |
def line_flush(): Unit = |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
270 |
{ |
64326 | 271 |
val line = Library.trim_line(line_buffer.toString(UTF8.charset_name)) |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
272 |
progress(line) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
273 |
result += line |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
274 |
line_buffer.reset |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
275 |
} |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
276 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
277 |
var c = 0 |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
278 |
var finished = false |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
279 |
while (!finished) { |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
280 |
while ({ c = stream.read; c != -1 && c != 10 }) line_buffer.write(c) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
281 |
if (c == 10) line_flush() |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
282 |
else if (channel.isClosed) { |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
283 |
if (line_buffer.size > 0) line_flush() |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
284 |
finished = true |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
285 |
} |
73702
7202e12cb324
tuned signature --- following hints by IntelliJ IDEA;
wenzelm
parents:
73634
diff
changeset
|
286 |
else exec_wait_delay.sleep() |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
287 |
} |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
288 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
289 |
result.toList |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
290 |
} |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
291 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
292 |
val out_lines = Future.thread("ssh_stdout") { read_lines(stdout, progress_stdout) } |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
293 |
val err_lines = Future.thread("ssh_stderr") { read_lines(stderr, progress_stderr) } |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
294 |
|
73340 | 295 |
def terminate(): Unit = |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
296 |
{ |
73367 | 297 |
close() |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
298 |
out_lines.join |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
299 |
err_lines.join |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
300 |
exit_status.join |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
301 |
} |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
302 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
303 |
val rc = |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
304 |
try { exit_status.join } |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
305 |
catch { case Exn.Interrupt() => terminate(); Exn.Interrupt.return_code } |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
306 |
|
73367 | 307 |
close() |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
308 |
if (strict && rc == Exn.Interrupt.return_code) throw Exn.Interrupt() |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
309 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
310 |
Process_Result(rc, out_lines.join, err_lines.join) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
311 |
} |
64131 | 312 |
} |
313 |
||
314 |
||
64123 | 315 |
/* session */ |
316 |
||
67745
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
317 |
class Session private[SSH]( |
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
318 |
val options: Options, |
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
319 |
val session: JSch_Session, |
71549 | 320 |
on_close: () => Unit, |
321 |
val nominal_host: String, |
|
73634 | 322 |
val nominal_user: String) extends System |
64123 | 323 |
{ |
67745
d83efbe52438
support for proxy connection, similar to ProxyCommand in ssh config;
wenzelm
parents:
67273
diff
changeset
|
324 |
def update_options(new_options: Options): Session = |
71549 | 325 |
new Session(new_options, session, on_close, nominal_host, nominal_user) |
64166 | 326 |
|
64347 | 327 |
def host: String = if (session.getHost == null) "" else session.getHost |
71549 | 328 |
|
329 |
override def hg_url: String = |
|
330 |
"ssh://" + user_prefix(nominal_user) + nominal_host + "/" |
|
66570 | 331 |
|
64123 | 332 |
override def toString: String = |
71549 | 333 |
user_prefix(session.getUserName) + host + port_suffix(session.getPort) + |
334 |
(if (session.isConnected) "" else " (disconnected)") |
|
64123 | 335 |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
336 |
|
65009 | 337 |
/* port forwarding */ |
338 |
||
65636
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
339 |
def port_forwarding( |
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
340 |
remote_port: Int, remote_host: String = "localhost", |
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
341 |
local_port: Int = 0, local_host: String = "localhost", |
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
342 |
ssh_close: Boolean = false): Port_Forwarding = |
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65594
diff
changeset
|
343 |
Port_Forwarding.open(this, ssh_close, local_host, local_port, remote_host, remote_port) |
65009 | 344 |
|
345 |
||
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
346 |
/* sftp channel */ |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
347 |
|
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
348 |
val sftp: ChannelSftp = session.openChannel("sftp").asInstanceOf[ChannelSftp] |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
349 |
sftp.connect(connect_timeout(options)) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
350 |
|
73634 | 351 |
override def close(): Unit = { sftp.disconnect; session.disconnect; on_close() } |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
352 |
|
73897 | 353 |
val settings: JMap[String, String] = |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
354 |
{ |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
355 |
val home = sftp.getHome |
73897 | 356 |
JMap.of("HOME", home, "USER_HOME", home) |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
357 |
} |
66570 | 358 |
override def expand_path(path: Path): Path = path.expand_env(settings) |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
359 |
def remote_path(path: Path): String = expand_path(path).implode |
67066 | 360 |
override def bash_path(path: Path): String = Bash.string(remote_path(path)) |
64123 | 361 |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
362 |
def chmod(permissions: Int, path: Path): Unit = sftp.chmod(permissions, remote_path(path)) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
363 |
def mv(path1: Path, path2: Path): Unit = sftp.rename(remote_path(path1), remote_path(path2)) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
364 |
def rm(path: Path): Unit = sftp.rm(remote_path(path)) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
365 |
def mkdir(path: Path): Unit = sftp.mkdir(remote_path(path)) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
366 |
def rmdir(path: Path): Unit = sftp.rmdir(remote_path(path)) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
367 |
|
69302 | 368 |
private def test_entry(path: Path, as_dir: Boolean): Boolean = |
369 |
try { |
|
370 |
val is_dir = sftp.stat(remote_path(path)).isDir |
|
371 |
if (as_dir) is_dir else !is_dir |
|
372 |
} |
|
373 |
catch { case _: SftpException => false } |
|
69300
8b6ab9989bcd
is_file/is_dir/read_dir: more uniform treatment of errors and boundary cases, notably for symlinks in ssh;
wenzelm
parents:
67771
diff
changeset
|
374 |
|
69302 | 375 |
override def is_dir(path: Path): Boolean = test_entry(path, true) |
376 |
override def is_file(path: Path): Boolean = test_entry(path, false) |
|
69300
8b6ab9989bcd
is_file/is_dir/read_dir: more uniform treatment of errors and boundary cases, notably for symlinks in ssh;
wenzelm
parents:
67771
diff
changeset
|
377 |
|
69301 | 378 |
def is_link(path: Path): Boolean = |
379 |
try { sftp.lstat(remote_path(path)).isLink } |
|
380 |
catch { case _: SftpException => false } |
|
381 |
||
72376 | 382 |
override def make_directory(path: Path): Path = |
383 |
{ |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
384 |
if (!is_dir(path)) { |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
385 |
execute( |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
386 |
"perl -e \"use File::Path make_path; make_path('" + remote_path(path) + "');\"") |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
387 |
if (!is_dir(path)) error("Failed to create directory: " + quote(remote_path(path))) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
388 |
} |
72376 | 389 |
path |
390 |
} |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
391 |
|
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
392 |
def read_dir(path: Path): List[Dir_Entry] = |
64191 | 393 |
{ |
69300
8b6ab9989bcd
is_file/is_dir/read_dir: more uniform treatment of errors and boundary cases, notably for symlinks in ssh;
wenzelm
parents:
67771
diff
changeset
|
394 |
if (!is_dir(path)) error("No such directory: " + path.toString) |
8b6ab9989bcd
is_file/is_dir/read_dir: more uniform treatment of errors and boundary cases, notably for symlinks in ssh;
wenzelm
parents:
67771
diff
changeset
|
395 |
|
8b6ab9989bcd
is_file/is_dir/read_dir: more uniform treatment of errors and boundary cases, notably for symlinks in ssh;
wenzelm
parents:
67771
diff
changeset
|
396 |
val dir_name = remote_path(path) |
8b6ab9989bcd
is_file/is_dir/read_dir: more uniform treatment of errors and boundary cases, notably for symlinks in ssh;
wenzelm
parents:
67771
diff
changeset
|
397 |
val dir = sftp.ls(dir_name) |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
398 |
(for { |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
399 |
i <- (0 until dir.size).iterator |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
400 |
a = dir.get(i).asInstanceOf[AnyRef] |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
401 |
name = Untyped.get[String](a, "filename") |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
402 |
attrs = Untyped.get[Attrs](a, "attrs") |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
403 |
if name != "." && name != ".." |
69302 | 404 |
} |
405 |
yield { |
|
406 |
Dir_Entry(name, |
|
407 |
if (attrs.isLink) { |
|
408 |
try { sftp.stat(dir_name + "/" + name).isDir } |
|
409 |
catch { case _: SftpException => false } |
|
410 |
} |
|
411 |
else attrs.isDir) |
|
69427
ff2f39a221d4
clarified operations: uniform sorting of results;
wenzelm
parents:
69393
diff
changeset
|
412 |
}).toList.sortBy(_.name) |
64191 | 413 |
} |
64135
865dda40e1cc
provide execute operation, similar to Isabelle_System.bash;
wenzelm
parents:
64134
diff
changeset
|
414 |
|
69301 | 415 |
def find_files( |
416 |
start: Path, |
|
417 |
pred: Path => Boolean = _ => true, |
|
418 |
include_dirs: Boolean = false, |
|
419 |
follow_links: Boolean = false): List[Path] = |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
420 |
{ |
69301 | 421 |
val result = new mutable.ListBuffer[Path] |
73340 | 422 |
def check(path: Path): Unit = { if (pred(path)) result += path } |
69301 | 423 |
|
73340 | 424 |
def find(dir: Path): Unit = |
69301 | 425 |
{ |
69303 | 426 |
if (include_dirs) check(dir) |
69301 | 427 |
if (follow_links || !is_link(dir)) { |
428 |
for (entry <- read_dir(dir)) { |
|
69302 | 429 |
val path = dir + Path.basic(entry.name) |
430 |
if (entry.is_file) check(path) else find(path) |
|
69301 | 431 |
} |
432 |
} |
|
433 |
} |
|
434 |
if (is_file(start)) check(start) else find(start) |
|
435 |
||
436 |
result.toList |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
437 |
} |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
438 |
|
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
439 |
def open_input(path: Path): InputStream = sftp.get(remote_path(path)) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
440 |
def open_output(path: Path): OutputStream = sftp.put(remote_path(path)) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
441 |
|
73634 | 442 |
override def read_file(path: Path, local_path: Path): Unit = |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
443 |
sftp.get(remote_path(path), File.platform_path(local_path)) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
444 |
def read_bytes(path: Path): Bytes = using(open_input(path))(Bytes.read_stream(_)) |
71601 | 445 |
def read(path: Path): String = using(open_input(path))(File.read_stream) |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
446 |
|
73634 | 447 |
override def write_file(path: Path, local_path: Path): Unit = |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
448 |
sftp.put(File.platform_path(local_path), remote_path(path)) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
449 |
def write_bytes(path: Path, bytes: Bytes): Unit = |
71601 | 450 |
using(open_output(path))(bytes.write_stream) |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
451 |
def write(path: Path, text: String): Unit = |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
452 |
using(open_output(path))(stream => Bytes(text).write_stream(stream)) |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
453 |
|
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
454 |
|
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
455 |
/* exec channel */ |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
456 |
|
64166 | 457 |
def exec(command: String): Exec = |
64129 | 458 |
{ |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
459 |
val channel = session.openChannel("exec").asInstanceOf[ChannelExec] |
64190
c62b99e3ec07
provide USER_HOME, such that symbolic Path.explode("~") can be used remotely;
wenzelm
parents:
64185
diff
changeset
|
460 |
channel.setCommand("export USER_HOME=\"$HOME\"\n" + command) |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64254
diff
changeset
|
461 |
new Exec(this, channel) |
64129 | 462 |
} |
64123 | 463 |
|
66570 | 464 |
override def execute(command: String, |
64191 | 465 |
progress_stdout: String => Unit = (_: String) => (), |
466 |
progress_stderr: String => Unit = (_: String) => (), |
|
73634 | 467 |
settings: Boolean = true, |
64191 | 468 |
strict: Boolean = true): Process_Result = |
469 |
exec(command).result(progress_stdout, progress_stderr, strict) |
|
64137 | 470 |
|
72340 | 471 |
override def isabelle_platform: Isabelle_Platform = Isabelle_Platform(ssh = Some(this)) |
72338 | 472 |
|
64137 | 473 |
|
474 |
/* tmp dirs */ |
|
475 |
||
64306
7b6dc1b36f20
tuned signature, in accordance to Isabelle_System;
wenzelm
parents:
64304
diff
changeset
|
476 |
def rm_tree(dir: Path): Unit = rm_tree(remote_path(dir)) |
7b6dc1b36f20
tuned signature, in accordance to Isabelle_System;
wenzelm
parents:
64304
diff
changeset
|
477 |
|
64137 | 478 |
def rm_tree(remote_dir: String): Unit = |
64304 | 479 |
execute("rm -r -f " + Bash.string(remote_dir)).check |
64137 | 480 |
|
481 |
def tmp_dir(): String = |
|
482 |
execute("mktemp -d -t tmp.XXXXXXXXXX").check.out |
|
483 |
||
73634 | 484 |
override def with_tmp_dir[A](body: Path => A): A = |
64137 | 485 |
{ |
486 |
val remote_dir = tmp_dir() |
|
64233 | 487 |
try { body(Path.explode(remote_dir)) } finally { rm_tree(remote_dir) } |
64137 | 488 |
} |
64123 | 489 |
} |
66570 | 490 |
|
491 |
||
492 |
/* system operations */ |
|
493 |
||
73634 | 494 |
trait System extends AutoCloseable |
66570 | 495 |
{ |
73634 | 496 |
def close(): Unit = () |
497 |
||
66570 | 498 |
def hg_url: String = "" |
499 |
||
500 |
def expand_path(path: Path): Path = path.expand |
|
67066 | 501 |
def bash_path(path: Path): String = File.bash_path(path) |
69300
8b6ab9989bcd
is_file/is_dir/read_dir: more uniform treatment of errors and boundary cases, notably for symlinks in ssh;
wenzelm
parents:
67771
diff
changeset
|
502 |
def is_dir(path: Path): Boolean = path.is_dir |
66570 | 503 |
def is_file(path: Path): Boolean = path.is_file |
72376 | 504 |
def make_directory(path: Path): Path = Isabelle_System.make_directory(path) |
73634 | 505 |
def with_tmp_dir[A](body: Path => A): A = Isabelle_System.with_tmp_dir("tmp")(body) |
506 |
def read_file(path1: Path, path2: Path): Unit = Isabelle_System.copy_file(path1, path2) |
|
507 |
def write_file(path1: Path, path2: Path): Unit = Isabelle_System.copy_file(path2, path1) |
|
66570 | 508 |
|
509 |
def execute(command: String, |
|
510 |
progress_stdout: String => Unit = (_: String) => (), |
|
511 |
progress_stderr: String => Unit = (_: String) => (), |
|
73634 | 512 |
settings: Boolean = true, |
66570 | 513 |
strict: Boolean = true): Process_Result = |
73634 | 514 |
Isabelle_System.bash(command, |
515 |
progress_stdout = progress_stdout, |
|
516 |
progress_stderr = progress_stderr, |
|
517 |
env = if (settings) Isabelle_System.settings() else null, |
|
518 |
strict = strict) |
|
72338 | 519 |
|
72340 | 520 |
def isabelle_platform: Isabelle_Platform = Isabelle_Platform() |
66570 | 521 |
} |
522 |
||
523 |
object Local extends System |
|
64123 | 524 |
} |