From 3340ae2796a4653ad12f0a893479c8711e6aa380 Mon Sep 17 00:00:00 2001 From: tgoff0 Date: Fri, 22 May 2015 00:54:09 +0000 Subject: [PATCH] printed CEL messages to stdout when running in batch mode. Aborted current session when in batch mode and a FATAL event is received from the daemon --- gui/api.tcl | 9 +++++++-- gui/core.tcl | 3 ++- gui/exceptions.tcl | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/gui/api.tcl b/gui/api.tcl index f6f72457..cd2ed179 100644 --- a/gui/api.tcl +++ b/gui/api.tcl @@ -1480,8 +1480,13 @@ proc parseEventMessage { data len flags channel } { if { $eventtype == 4 } { ;# entered the runtime state if { $g_traffic_start_opt == 1 } { startTrafficScripts } if { $execMode == "batch" } { - global g_current_session - puts "disconnecting. Session id is $g_current_session" + global g_current_session g_abort_session + if {$g_abort_session} { + puts "Current session ($g_current_session) aborted. Disconnecting." + shutdownSession + } else { + puts "Session running. Session id is $g_current_session. Disconnecting." + } exit.real } } elseif { $eventtype == 6 } { ;# shutdown state diff --git a/gui/core.tcl b/gui/core.tcl index c1407d69..8ed9c90a 100644 --- a/gui/core.tcl +++ b/gui/core.tcl @@ -126,6 +126,7 @@ loadPluginsConf checkCommandLineAddressPort autoConnectPlugins +set g_abort_session 0 # # Initialization should be complete now, so let's start doing something... @@ -176,7 +177,7 @@ if {$execMode == "interactive"} { after 100 { loadCfg $cfg deployCfgAPI $sock - puts "waiting to enter RUNTIME state..." + puts "Waiting to enter RUNTIME state..." } global vwaitdummy vwait vwaitdummy diff --git a/gui/exceptions.tcl b/gui/exceptions.tcl index 5b61d5a3..22f3be2f 100644 --- a/gui/exceptions.tcl +++ b/gui/exceptions.tcl @@ -12,11 +12,21 @@ set g_cel_blink_state "off" # receive an exception into the g_exceptions array from an Exception Message proc receiveException { valuelist } { - global g_exceptions EXCEPTION_LEVELS + global g_exceptions EXCEPTION_LEVELS execMode set idx [expr {1 + [array size g_exceptions]}] array set g_exceptions [list $idx $valuelist] - # exceptions with level ERROR or FATAL will throw the CEL array set vals $valuelist + # print exception message on stdout if in batch mode + if { $execMode == "batch" } { + puts "\nFrom $vals(src): $vals(txt)" + + # Abort the session if a fatal exception is reported + if { $vals(level) <= [lsearch -exact $EXCEPTION_LEVELS "FATAL" ] } { + global g_current_session g_abort_session + set g_abort_session 1 + } + } + # exceptions with level ERROR or FATAL will throw the CEL if { $vals(level) <= [lsearch -exact $EXCEPTION_LEVELS "ERROR"] } { throwCEL false if { $vals(level) <= [lsearch -exact $EXCEPTION_LEVELS "FATAL" ] } {