Commit aaebc8ed by Tomasz Ciesielczyk

output clean

parent c55fc2cf
package psnc.m2dc.rtm.commands.java
val APP_VERSION = "1.0.548_54626"
\ No newline at end of file
val APP_VERSION = "1.0.548_55165"
\ No newline at end of file
package psnc.m2dc.rtm.client
const val APP_VERSION = "1.1.548_54626"
\ No newline at end of file
const val APP_VERSION = "1.1.548_55166"
\ No newline at end of file
......@@ -27,7 +27,7 @@ open class SSHApiImpl private constructor(val resource: Resource) : SSHApi {
init {
val trace = Exception().stackTrace
printConsole("use ssh: ${resource.id} ${trace[3].methodName} -> ${trace[2].methodName} -> ${trace[1].methodName}")
logDebug("use ssh: ${resource.id} ${trace[3].methodName} -> ${trace[2].methodName} -> ${trace[1].methodName}")
}
companion object {
......@@ -244,7 +244,7 @@ open class SSHApiImpl private constructor(val resource: Resource) : SSHApi {
}
fun getOutput(cmd : SSHCommand,process: Process,stdOut : StringBuilder,stdErr:StringBuilder): Pair<Any, Any> {
fun getOutput(cmd: SSHCommand, process: Process, stdOut: StringBuilder, stdErr: StringBuilder): Pair<Any, Any> {
val newFixedThreadPool = Executors.newFixedThreadPool(2)
......@@ -273,7 +273,7 @@ open class SSHApiImpl private constructor(val resource: Resource) : SSHApi {
// process.waitFor();
if (!process.waitFor(SSH_COMMAND_TIMEOUT, TimeUnit.MILLISECONDS)) {
println("Destroy")
logWarn("SSH Command timeout: ${cmd.build().toJson()}" )
logWarn("SSH Command timeout: ${cmd.build().toJson()}")
process.destroy()
}
return Pair(output.get(), error.get())
......@@ -291,7 +291,7 @@ open class SSHApiImpl private constructor(val resource: Resource) : SSHApi {
p = Runtime.getRuntime().exec(array)
// printConsole("pwait for : ${cmd.host}")
this.getOutput(cmd,p,stdOut,stdErr).toJson(true)
this.getOutput(cmd, p, stdOut, stdErr)//.toJson(true)
// p.waitFor(SSH_COMMAND_TIMEOUT, TimeUnit.MILLISECONDS)
// printConsole("pwaited for : ${cmd.host}")
......@@ -340,9 +340,9 @@ open class SSHApiImpl private constructor(val resource: Resource) : SSHApi {
log.debug(stdOut.toString())
// printConsole("output for ${cmd.host} :$stdOut")
return if (stdOut.length > 1)
stdOut.toString().trim().let { printConsole("ssh result: ${it.take(256).replace("\n", " ")}"); it }
stdOut.toString().trim().let { logDebug("${it.take(256).replace("\n", " ")}", true); it }
else {
stdErr.toString().trim().let { printConsole("ssh err ${cmd.build().toJson()} :$it"); it }
stdErr.toString().trim().let { printConsole("ssh err: ${cmd.build().toJson()} :$it"); it }
}
}
......
......@@ -21,7 +21,7 @@ import kotlin.collections.HashMap
* Created by Tomek on 2017-11-06.
*/
val _PRINT_TO_CONSOLE = true
var _PRINT_DEBUG = true
var _PRINT_DEBUG = false
val _MSG_MAX_LENGTH = 1024
val _DATE_FORMAT = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment