diff options
author | Norbert Preining <preining@logic.at> | 2018-10-06 08:23:40 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2018-10-06 08:23:40 +0000 |
commit | 7b0783b59d3e5ae474862fe9a3b6df60c4e4bf06 (patch) | |
tree | a29cfdeac8f2409d4acd8b516299995e2da1c3d2 /Master/texmf-dist/source/support | |
parent | ab3121ce87e3466683261ae386429ab3138c775b (diff) |
update tlcockpit 1.0
git-svn-id: svn://tug.org/texlive/trunk@48838 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/support')
6 files changed, 88 insertions, 12 deletions
diff --git a/Master/texmf-dist/source/support/tlcockpit/build.sbt b/Master/texmf-dist/source/support/tlcockpit/build.sbt index 8de4ff3e483..737ee577c2b 100644 --- a/Master/texmf-dist/source/support/tlcockpit/build.sbt +++ b/Master/texmf-dist/source/support/tlcockpit/build.sbt @@ -1,13 +1,15 @@ name := "tlcockpit" -version := "0.9" +version := "1.0" -scalaVersion := "2.12.3" +scalaVersion := "2.12.7" -libraryDependencies += "org.scalafx" % "scalafx_2.12" % "8.0.102-R11" +libraryDependencies += "org.scalafx" % "scalafx_2.12" % "8.0.181-R13" libraryDependencies += "io.spray" %% "spray-json" % "1.3.3" libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.7.2" libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3" +libraryDependencies += "org.json4s" %% "json4s-native" % "3.6.0-M3" +libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.6.0-M3" mainClass in assembly := Some("TLCockpit.ApplicationMain") diff --git a/Master/texmf-dist/source/support/tlcockpit/project/assembly.sbt b/Master/texmf-dist/source/support/tlcockpit/project/assembly.sbt index 15a88b09365..d6540b84c5a 100644 --- a/Master/texmf-dist/source/support/tlcockpit/project/assembly.sbt +++ b/Master/texmf-dist/source/support/tlcockpit/project/assembly.sbt @@ -1 +1 @@ -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5") +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.8") diff --git a/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TLCockpit/ApplicationMain.scala b/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TLCockpit/ApplicationMain.scala index dadb8c516df..8ba576002bd 100644 --- a/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TLCockpit/ApplicationMain.scala +++ b/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TLCockpit/ApplicationMain.scala @@ -10,6 +10,7 @@ import javafx.scene.Node import TLCockpit.Utils._ import TeXLive._ +import TeXLive.OsTools._ import scala.collection.{immutable, mutable} import scala.collection.mutable.ArrayBuffer @@ -49,6 +50,9 @@ import scalafx.collections.ObservableMap // JSON support - important load TLPackageJsonProtocol later! import spray.json._ import TeXLive.JsonProtocol._ +import org.json4s._ +import org.json4s.jackson.JsonMethods._ + // logging import com.typesafe.scalalogging.LazyLogging @@ -84,6 +88,42 @@ object ApplicationMain extends JFXApp with LazyLogging { logger.trace("starting program tlcockpit") + val javaVersion = System.getProperty("java.version") + val javaVersionSplit: Array[String] = javaVersion.split('.') + logger.debug(s"Got javaVersion ${javaVersion}") + if (javaVersionSplit.length == 1) { + logger.warn(s"Cannot find Java version from ${javaVersion}, continuing anyway!") + } else { + val major = toInt(javaVersionSplit(0)) + val minor = toInt(javaVersionSplit(1)) + major match { + case Some(i) => + if (major.get == 1) { + minor match { + case Some(j) => + if (minor.get < 8) { + logger.error(s"Java version ${javaVersion} too old, need >= 1.8, terminating!") + Platform.exit() + sys.exit(1) + } + case None => + logger.warn(s"Cannot find Java version from ${javaVersion}, continuing anyway!") + } + } else { + if (major.get > 9) { + logger.warn(s"Currently Java versions > 8 (1.8) are not supported (${javaVersion}), trying anyway!") + } else { + logger.warn(s"Strange version number, please report: ${javaVersion}, continuing anyway!") + } + } + case None => + logger.warn(s"Cannot find Java version from ${javaVersion}, continuing anyway!") + } + // in all other cases just hope it is fine + logger.info(s"Running on Java Version ${javaVersion}") + } + + var tlmgrBusy = BooleanProperty(false) // necessary action when Window is closed with X or some other operation @@ -274,11 +314,12 @@ object ApplicationMain extends JFXApp with LazyLogging { // outputText.append(s"Running ${ss.mkString(" ")}" + (if (unbuffered) " (unbuffered)" else " (buffered)")) val foo = Future { ss.foreach { s => + val runcmd = if (isCygwin) "bash -l -c \"" + s + "\"" else s Platform.runLater { outputText.append(s"Running ${s}" + (if (unbuffered) " (unbuffered)" else " (buffered)")) actionLabel.text = s"[${s}]" } - s ! ProcessLogger( + runcmd ! ProcessLogger( line => if (unbuffered) Platform.runLater(outputText.append(line)) else OutputBuffer.synchronized(OutputBuffer.append(line + "\n")), line => Platform.runLater(logText.append(line)) @@ -755,6 +796,7 @@ tlmgr> logger.debug(s"load tlpdb update (no json) pkgs: got status ${status}") logger.trace(s"load tlpdb update (no json) pkgs: got lines = " + lines.head) val newtlpkgs: Map[String, TLPackageShort] = lines.map(l => { + // logger.debug(s"got line >>>${l}<<<") val fields = l.split(",",8) val pkgname = fields(0) val shortdesc = fields(7).stripPrefix(""""""").stripSuffix(""""""").replaceAll("""\\"""",""""""") @@ -1525,7 +1567,9 @@ tlmgr> def tlmgr_run_one_cmd(s: String, onCompleteFunc: (String, Array[String]) => Unit): Unit = { currentPromise = Promise[(String, Array[String])]() tlmgrBusy.value = true - actionLabel.text = s"[${s}]" + Platform.runLater { + actionLabel.text = s"[${s}]" + } currentPromise.future.onComplete { case Success((a, b)) => logger.debug("tlmgr run one cmd: current future completed!") @@ -1544,7 +1588,8 @@ tlmgr> def tlmgr_send(s: String, onCompleteFunc: (String, Array[String]) => Unit): Unit = { // logText.clear() outputText.clear() - outerrpane.expanded = false + // don't close debug panel when it is open + // outerrpane.expanded = false if (!currentPromise.isCompleted) { logger.debug(s"tlmgr busy, put onto pending jobs: $s") logger.debug("Currently running job: " + currentPromise) diff --git a/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TLCockpit/Utils.scala b/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TLCockpit/Utils.scala index aae40d5db37..0753e127c6b 100644 --- a/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TLCockpit/Utils.scala +++ b/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TLCockpit/Utils.scala @@ -21,4 +21,12 @@ object Utils { f"${fileSize/Math.pow(1024, digitGroup)}%3.1f ${units(digitGroup)}" } + def toInt(s: String): Option[Int] = { + try { + Some(s.toInt) + } catch { + case e: Exception => None + } + } + } diff --git a/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TeXLive/OsTools.scala b/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TeXLive/OsTools.scala index 45a50ae884c..1e0aa0f03ce 100644 --- a/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TeXLive/OsTools.scala +++ b/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TeXLive/OsTools.scala @@ -11,20 +11,30 @@ import sys.process._ object OsTools { val OS: String = System.getProperty("os.name").map(_.toLower) + val CygwinRootIsSet: Boolean = + sys.env.get("CYGWIN_ROOT") match { + case Some(_) => true + case None => false + } def isWindows: Boolean = { - OS.startsWith("windows") + OS.startsWith("windows") && !CygwinRootIsSet + } + def isCygwin: Boolean = { + OS.startsWith("windows") && CygwinRootIsSet } def isApple: Boolean = { OS.startsWith("mac os") } def isUnix: Boolean = { - !(isWindows || isApple) + !(isWindows || isApple || isCygwin) } def openFileCmd(f: String): Seq[String] = { val absf = new java.io.File(f).getCanonicalPath if (isWindows) { Seq("cmd", "/c", "start", absf) + } else if (isCygwin) { + Seq("cygstart", absf) } else if (isApple) { Seq("open", absf) } else { diff --git a/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TeXLive/TlmgrProcess.scala b/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TeXLive/TlmgrProcess.scala index 5776daef76d..3040d3abf74 100644 --- a/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TeXLive/TlmgrProcess.scala +++ b/Master/texmf-dist/source/support/tlcockpit/src/main/scala/TeXLive/TlmgrProcess.scala @@ -52,7 +52,18 @@ class TlmgrProcess(updout: String => Unit, upderr: String => Unit) extends Lazy if (process == null) { logger.debug("tlmgr process: start_process: creating procIO") val procIO = new ProcessIO(inputFn, outputFn(_, updout), outputFn(_, upderr)) - val processBuilder: ProcessBuilder = Seq({if (isWindows) "tlmgr.bat" else "tlmgr"}, "-v", "--machine-readable", "shell") + val startCmd = + if (isWindows) { + logger.debug("detected Windows, using tlmgr.bat") + Seq("tlmgr.bat", "-v", "--machine-readable", "shell") + } else if (isCygwin) { + logger.debug("detected Cygwin, using bash -l -c tlmgr") + Seq("bash", "-l", "-c", "tlmgr -v --machine-readable shell") + } else { + logger.debug("detected Unixish, using tlmgr") + Seq("tlmgr", "-v", "--machine-readable", "shell") + } + val processBuilder: ProcessBuilder = startCmd logger.debug("tlmgr process: start_process: running new tlmgr process") process = processBuilder.run(procIO) } @@ -90,8 +101,8 @@ class TlmgrProcess(updout: String => Unit, upderr: String => Unit) extends Lazy stdin.close() } catch { case exc: Throwable => - stdin.close() logger.warn("Exception in inputFn thread: " + exc + "\n") + stdin.close() } } @@ -112,8 +123,8 @@ class TlmgrProcess(updout: String => Unit, upderr: String => Unit) extends Lazy outStr.close() } catch { case exc: Throwable => - outStr.close() logger.warn("Exception in outputFn thread: " + exc + "\n") + outStr.close() } } } |