Class: Yast::ReportClass
- Inherits:
-
Module
- Object
- Module
- Yast::ReportClass
- Defined in:
- library/general/src/modules/Report.rb
Overview
Report module is universal reporting module. It properly display messages in CLI, TUI, GUI or even in automatic installation. It also collects warnings and errors. Collected messages can be displayed later.
Instance Method Summary collapse
-
#AnyQuestion(headline, message, yes_button_message, no_button_message, focus) ⇒ Boolean
Question with headline and Yes/No Buttons.
-
#ClearAll ⇒ void
Clear all stored messages (errors, messages and warnings).
-
#ClearErrors ⇒ void
Clear stored errors.
-
#ClearMessages ⇒ void
Clear stored messages.
-
#ClearWarnings ⇒ void
Clear stored warnings.
-
#ClearYesNoMessages ⇒ void
Clear stored yes/no messages.
-
#DisplayErrors(display, timeout) ⇒ void
Error popup dialog can displayed immediately when new error is stored.
-
#DisplayMessages(display, timeout) ⇒ void
Message popup dialog can be displayed immediately when a new message is stored.
-
#DisplayWarnings(display, timeout) ⇒ void
Warning popup dialog can displayed immediately when new warningr is stored.
-
#DisplayYesNoMessages(display, timeout) ⇒ void
Yes/No Message popup dialog can be displayed immediately when a new message is stored.
-
#Error(error_string) ⇒ nil
Display and record error string.
-
#ErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus) ⇒ Boolean
Question with headline and Yes/No Buttons.
-
#Export ⇒ Hash
Dump the Report settings to a map, for autoinstallation use.
-
#GetMessages(w, e, m, ynm) ⇒ String
Create rich text string from stored warning, message or error messages.
-
#GetModified ⇒ Boolean
Functions which returns if the settings were modified.
-
#Import(settings) ⇒ Object
Get all the Report configuration from a map.
-
#LogErrors(log) ⇒ void
Set warnings logging to .y2log file.
-
#LogMessages(log) ⇒ void
Set messages logging to .y2log file.
-
#LogWarnings(log) ⇒ void
Set warnings logging to .y2log file.
-
#LogYesNoMessages(log) ⇒ void
Set yes/no messages logging to .y2log file.
-
#LongError(error_string) ⇒ void
Store new error text, the text is displayed in a richtext widget - long lines are automatically wrapped.
-
#LongMessage(message_string) ⇒ void
Store new message text, the text is displayed in a richtext widget - long lines are automatically wrapped.
-
#LongWarning(warning_string) ⇒ void
Store new warning text, the text is displayed in a richtext widget - long lines are automatically wrapped.
- #main ⇒ Object
-
#Message(message_string) ⇒ void
Store new message text.
-
#NumErrors ⇒ Fixnum
Return number of stored errors.
-
#NumMessages ⇒ Fixnum
Return number of stored messages.
-
#NumWarnings ⇒ Fixnum
Return number of stored warnings.
-
#NumYesNoMessages ⇒ Fixnum
Return number of stored yes/no messages.
-
#SetModified ⇒ Object
Function sets internal variable, which indicates, that any settings were modified, to “true”.
-
#ShowText(headline_string, message_string) ⇒ void
Store new message text.
-
#Summary ⇒ Object
Summary of current settings.
-
#Warning(warning_string) ⇒ void
Store new warning text.
Instance Method Details
#AnyQuestion(headline, message, yes_button_message, no_button_message, focus) ⇒ Boolean
Question with headline and Yes/No Buttons
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'library/general/src/modules/Report.rb', line 360 def AnyQuestion(headline, , , , focus) Builtins.y2milestone(1, "%1", ) if ret = false if ret = if Ops.greater_than(, 0) Popup.TimedAnyQuestion( headline, , , , focus, ) else Popup.AnyQuestion( headline, , , , focus ) end end = Builtins.add(, ) ret end |
#ClearAll ⇒ void
This method returns an undefined value.
Clear all stored messages (errors, messages and warnings)
320 321 322 323 324 325 326 327 |
# File 'library/general/src/modules/Report.rb', line 320 def ClearAll ClearErrors() ClearWarnings() ClearMessages() ClearYesNoMessages() nil end |
#ClearErrors ⇒ void
This method returns an undefined value.
Clear stored errors
304 305 306 307 308 |
# File 'library/general/src/modules/Report.rb', line 304 def ClearErrors @errors = [] nil end |
#ClearMessages ⇒ void
This method returns an undefined value.
Clear stored messages
296 297 298 299 300 |
# File 'library/general/src/modules/Report.rb', line 296 def ClearMessages = [] nil end |
#ClearWarnings ⇒ void
This method returns an undefined value.
Clear stored warnings
312 313 314 315 316 |
# File 'library/general/src/modules/Report.rb', line 312 def ClearWarnings @warnings = [] nil end |
#ClearYesNoMessages ⇒ void
This method returns an undefined value.
Clear stored yes/no messages
288 289 290 291 292 |
# File 'library/general/src/modules/Report.rb', line 288 def ClearYesNoMessages = [] nil end |
#DisplayErrors(display, timeout) ⇒ void
This method returns an undefined value.
Error popup dialog can displayed immediately when new error is stored.
This function enables or diables popuping of dialogs.
572 573 574 575 576 |
# File 'library/general/src/modules/Report.rb', line 572 def DisplayErrors(display, timeout) @display_errors = display @timeout_errors = timeout nil end |
#DisplayMessages(display, timeout) ⇒ void
This method returns an undefined value.
Message popup dialog can be displayed immediately when a new message is stored.
This function enables or diables popuping of dialogs.
599 600 601 602 603 |
# File 'library/general/src/modules/Report.rb', line 599 def DisplayMessages(display, timeout) = display = timeout nil end |
#DisplayWarnings(display, timeout) ⇒ void
This method returns an undefined value.
Warning popup dialog can displayed immediately when new warningr is stored.
This function enables or diables popuping of dialogs.
585 586 587 588 589 |
# File 'library/general/src/modules/Report.rb', line 585 def DisplayWarnings(display, timeout) @display_warnings = display @timeout_warnings = timeout nil end |
#DisplayYesNoMessages(display, timeout) ⇒ void
This method returns an undefined value.
Yes/No Message popup dialog can be displayed immediately when a new message is stored.
This function enables or diables popuping of dialogs.
613 614 615 616 617 |
# File 'library/general/src/modules/Report.rb', line 613 def DisplayYesNoMessages(display, timeout) = display = timeout nil end |
#Error(error_string) ⇒ nil
Displaying can be globally disabled using Display* methods.
Display and record error string.
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
# File 'library/general/src/modules/Report.rb', line 528 def Error(error_string) Builtins.y2error(1, "%1", error_string) if @log_errors if @display_errors if Mode.commandline CommandLine.Print "Error: #{error_string}" elsif Ops.greater_than(@timeout_errors, 0) Popup.TimedError(error_string, @timeout_errors) else Popup.Error(error_string) end end @errors = Builtins.add(@errors, error_string) nil end |
#ErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus) ⇒ Boolean
Question with headline and Yes/No Buttons
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'library/general/src/modules/Report.rb', line 396 def ErrorAnyQuestion(headline, , , , focus) Builtins.y2milestone(1, "%1", ) if ret = false if ret = if Ops.greater_than(, 0) Popup.TimedErrorAnyQuestion( headline, , , , focus, ) else Popup.ErrorAnyQuestion( headline, , , , focus ) end end = Builtins.add(, ) ret end |
#Export ⇒ Hash
Dump the Report settings to a map, for autoinstallation use.
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'library/general/src/modules/Report.rb', line 261 def Export { "messages" => { "log" => , "timeout" => , "show" => }, "errors" => { "log" => @log_errors, "timeout" => @timeout_errors, "show" => @display_errors }, "warnings" => { "log" => @log_warnings, "timeout" => @timeout_warnings, "show" => @display_warnings }, "yesno_messages" => { "log" => , "timeout" => , "show" => } } end |
#GetMessages(w, e, m, ynm) ⇒ String
Create rich text string from stored warning, message or error messages.
Every new line character “n” is replaced by string “[BR]”.
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 |
# File 'library/general/src/modules/Report.rb', line 664 def GetMessages(w, e, m, ynm) richtext = "" if w # translators: warnings summary header richtext = Ops.add( Ops.add(Ops.add(richtext, "<P><B>"), _("Warning:")), "</B><BR>" ) Builtins.foreach(@warnings) do |s| strs = Builtins.splitstring(s, "\n") Builtins.foreach(strs) do |line| richtext = Ops.add(Ops.add(richtext, line), "<BR>") end end richtext = Ops.add(richtext, "</P>") end if e # translators: errors summary header richtext = Ops.add( Ops.add(Ops.add(richtext, "<P><B>"), _("Error:")), "</B><BR>" ) Builtins.foreach(@errors) do |s| strs = Builtins.splitstring(s, "\n") Builtins.foreach(strs) do |line| richtext = Ops.add(Ops.add(richtext, line), "<BR>") end end richtext = Ops.add(richtext, "</P>") end if m # translators: message summary header richtext = Ops.add( Ops.add(Ops.add(richtext, "<P><B>"), _("Message:")), "</B><BR>" ) Builtins.foreach() do |s| strs = Builtins.splitstring(s, "\n") Builtins.foreach(strs) do |line| richtext = Ops.add(Ops.add(richtext, line), "<BR>") end end richtext = Ops.add(richtext, "</P>") end if ynm # translators: message summary header richtext = Ops.add( Ops.add(Ops.add(richtext, "<P><B>"), _("Message:")), "</B><BR>" ) Builtins.foreach() do |s| strs = Builtins.splitstring(s, "\n") Builtins.foreach(strs) do |line| richtext = Ops.add(Ops.add(richtext, line), "<BR>") end end richtext = Ops.add(richtext, "</P>") end richtext end |
#GetModified ⇒ Boolean
Functions which returns if the settings were modified
95 96 97 |
# File 'library/general/src/modules/Report.rb', line 95 def GetModified @modified end |
#Import(settings) ⇒ Object
Get all the Report configuration from a map.
the map may be empty.
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'library/general/src/modules/Report.rb', line 217 def Import(settings) settings = deep_copy(settings) = Ops.get_map(settings, "messages", {}) @error_settings = Ops.get_map(settings, "errors", {}) @warning_settings = Ops.get_map(settings, "warnings", {}) = Ops.get_map(settings, "yesno_messages", {}) # display flags @display_errors = Ops.get_boolean(@error_settings, "show", true) @display_warnings = Ops.get_boolean(@warning_settings, "show", true) = Ops.get_boolean(, "show", true) = Ops.get_boolean( , "show", true ) # timeouts @timeout_errors = Ops.get_integer(@error_settings, "timeout", 0) @timeout_warnings = Ops.get_integer(@warning_settings, "timeout", @default_timeout) = Ops.get_integer(, "timeout", @default_timeout) = Ops.get_integer( , "timeout", @default_timeout ) # logging flags @log_errors = Ops.get_boolean(@error_settings, "log", true) @log_warnings = Ops.get_boolean(@warning_settings, "log", true) = Ops.get_boolean(, "log", true) = Ops.get_boolean( , "log", true ) true end |
#LogErrors(log) ⇒ void
This method returns an undefined value.
Set warnings logging to .y2log file
649 650 651 652 653 |
# File 'library/general/src/modules/Report.rb', line 649 def LogErrors(log) @log_errors = log nil end |
#LogMessages(log) ⇒ void
This method returns an undefined value.
Set messages logging to .y2log file
640 641 642 643 644 |
# File 'library/general/src/modules/Report.rb', line 640 def LogMessages(log) = log nil end |
#LogWarnings(log) ⇒ void
This method returns an undefined value.
Set warnings logging to .y2log file
622 623 624 625 626 |
# File 'library/general/src/modules/Report.rb', line 622 def LogWarnings(log) @log_warnings = log nil end |
#LogYesNoMessages(log) ⇒ void
This method returns an undefined value.
Set yes/no messages logging to .y2log file
631 632 633 634 635 |
# File 'library/general/src/modules/Report.rb', line 631 def LogYesNoMessages(log) = log nil end |
#LongError(error_string) ⇒ void
This method returns an undefined value.
Store new error text, the text is displayed in a richtext widget - long lines are automatically wrapped
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'library/general/src/modules/Report.rb', line 549 def LongError(error_string) Builtins.y2error(1, "%1", error_string) if @log_errors if @display_errors if Ops.greater_than(@timeout_errors, 0) Popup.TimedLongError(error_string, @timeout_errors) else Popup.LongError(error_string) end end @errors = Builtins.add(@errors, error_string) nil end |
#LongMessage(message_string) ⇒ void
This method returns an undefined value.
Store new message text, the text is displayed in a richtext widget - long lines are automatically wrapped
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
# File 'library/general/src/modules/Report.rb', line 447 def LongMessage() Builtins.y2milestone(1, "%1", ) if if if Ops.greater_than(, 0) Popup.TimedLongMessage(, ) else Popup.LongMessage() end end = Builtins.add(, ) nil end |
#LongWarning(warning_string) ⇒ void
This method returns an undefined value.
Store new warning text, the text is displayed in a richtext widget - long lines are automatically wrapped
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
# File 'library/general/src/modules/Report.rb', line 507 def LongWarning(warning_string) Builtins.y2warning(1, "%1", warning_string) if @log_warnings if @display_warnings if Ops.greater_than(@timeout_warnings, 0) Popup.TimedLongWarning(warning_string, @timeout_warnings) else Popup.LongWarning(warning_string) end end @warnings = Builtins.add(@warnings, warning_string) nil end |
#main ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'library/general/src/modules/Report.rb', line 42 def main textdomain "base" Yast.import "Mode" Yast.import "Popup" Yast.import "Summary" Yast.import "CommandLine" # stored messages @errors = [] @warnings = [] = [] = [] # display flags @display_errors = true @display_warnings = true = true = true # timeouts # AutoYaST has different timeout (bnc#887397) @default_timeout = (Mode.auto || Mode.config) ? 10 : 0 @timeout_errors = 0 # default: Errors stop the installation @timeout_warnings = @default_timeout = @default_timeout = @default_timeout # logging flags @log_errors = true @log_warnings = true = true = true = {} @error_settings = {} @warning_settings = {} = {} # default value of settings modified @modified = false end |
#Message(message_string) ⇒ void
This method returns an undefined value.
Store new message text
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
# File 'library/general/src/modules/Report.rb', line 428 def Message() Builtins.y2milestone(1, "%1", ) if if if Ops.greater_than(, 0) Popup.TimedMessage(, ) else Popup.Message() end end = Builtins.add(, ) nil end |
#NumErrors ⇒ Fixnum
Return number of stored errors
349 350 351 |
# File 'library/general/src/modules/Report.rb', line 349 def NumErrors Builtins.size(@errors) end |
#NumMessages ⇒ Fixnum
Return number of stored messages
337 338 339 |
# File 'library/general/src/modules/Report.rb', line 337 def NumMessages Builtins.size() end |
#NumWarnings ⇒ Fixnum
Return number of stored warnings
343 344 345 |
# File 'library/general/src/modules/Report.rb', line 343 def NumWarnings Builtins.size(@warnings) end |
#NumYesNoMessages ⇒ Fixnum
Return number of stored yes/no messages
331 332 333 |
# File 'library/general/src/modules/Report.rb', line 331 def NumYesNoMessages Builtins.size() end |
#SetModified ⇒ Object
Function sets internal variable, which indicates, that any settings were modified, to “true”
87 88 89 90 91 |
# File 'library/general/src/modules/Report.rb', line 87 def SetModified @modified = true nil end |
#ShowText(headline_string, message_string) ⇒ void
This method returns an undefined value.
Store new message text
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
# File 'library/general/src/modules/Report.rb', line 467 def ShowText(headline_string, ) Builtins.y2milestone(1, "%1", ) if @log_errors if @display_errors if Ops.greater_than(@timeout_errors, 0) Popup.ShowTextTimed(headline_string, , @timeout_errors) else Popup.ShowText(headline_string, ) end end = Builtins.add(, ) nil end |
#Summary ⇒ Object
Summary of current settings
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'library/general/src/modules/Report.rb', line 101 def Summary summary = "" # translators: summary header for messages generated through autoinstallation summary = Summary.AddHeader(summary, _("Messages")) summary = Summary.OpenList(summary) # Report configuration - will be normal messages displayed? # '%1' will be replaced by translated string "Yes" or "No" summary = Summary.AddListItem( summary, Builtins.sformat( _("Display Messages: %1"), # translators: summary if the messages should be displayed ? _("Yes") : _("No") ) ) # Report configuration - will have normal messages timeout? # '%1' will be replaced by number of seconds summary = Summary.AddListItem( summary, Builtins.sformat(_("Time-out Messages: %1"), ) ) # Report configuration - will be normal messages logged to file? # '%1' will be replaced by translated string "Yes" or "No" summary = Summary.AddListItem( summary, Builtins.sformat( _("Log Messages: %1"), # translators: summary if the messages should be written to log file ? _("Yes") : _("No") ) ) summary = Summary.CloseList(summary) # translators: summary header for warnings generated through autoinstallation summary = Summary.AddHeader(summary, _("Warnings")) summary = Summary.OpenList(summary) # Report configuration - will be warning messages displayed? # '%1' will be replaced by translated string "Yes" or "No" summary = Summary.AddListItem( summary, Builtins.sformat( _("Display Warnings: %1"), # translators: summary if the warnings should be displayed @display_warnings ? _("Yes") : _("No") ) ) # Report configuration - will have warning messages timeout? # '%1' will be replaced by number of seconds summary = Summary.AddListItem( summary, Builtins.sformat(_("Time-out Warnings: %1"), @timeout_warnings) ) # Report configuration - will be warning messages logged to file? # '%1' will be replaced by translated string "Yes" or "No" summary = Summary.AddListItem( summary, Builtins.sformat( _("Log Warnings: %1"), # translators: summary if the warnings should be written to log file @log_warnings ? _("Yes") : _("No") ) ) summary = Summary.CloseList(summary) # translators: summary header for errors generated through autoinstallation summary = Summary.AddHeader(summary, _("Errors")) summary = Summary.OpenList(summary) # Report configuration - will be error messages displayed? # '%1' will be replaced by translated string "Yes" or "No" summary = Summary.AddListItem( summary, Builtins.sformat( _("Display Errors: %1"), # translators: summary if the errors should be displayed @display_errors ? _("Yes") : _("No") ) ) # Report configuration - will have error messages timeout? # '%1' will be replaced by number of seconds summary = Summary.AddListItem( summary, Builtins.sformat(_("Time-out Errors: %1"), @timeout_errors) ) # Report configuration - will be error messages logged to file? # '%1' will be replaced by translated string "Yes" or "No" summary = Summary.AddListItem( summary, Builtins.sformat( _("Log Errors: %1"), # translators: summary if the errors should be written to log file @log_errors ? _("Yes") : _("No") ) ) summary = Summary.CloseList(summary) # summary = Summary::AddHeader(summary, _("Yes or No Messages (Critical Messages)")); # summary = Summary::OpenList(summary); # // Report configuration - will be error messages displayed? # // '%1' will be replaced by translated string "Yes" or "No" # summary = Summary::AddListItem(summary, sformat(_("Display Yes or No Messages: %1"), (display_yesno_messages) ? # _("Yes") : _("No"))); # // Report configuration - will have error messages timeout? # // '%1' will be replaced by number of seconds # summary = Summary::AddListItem(summary, sformat(_("Time-out Yes or No Messages: %1"), timeout_yesno_messages)); # // Report configuration - will be error messages logged to file? # // '%1' will be replaced by translated string "Yes" or "No" # summary = Summary::AddListItem(summary, sformat(_("Log Yes or No Messages: %1"), (log_yesno_messages) ? # _("Yes") : _("No"))); # summary = Summary::CloseList(summary); summary end |
#Warning(warning_string) ⇒ void
This method returns an undefined value.
Store new warning text
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
# File 'library/general/src/modules/Report.rb', line 486 def Warning(warning_string) Builtins.y2warning(1, "%1", warning_string) if @log_warnings if @display_warnings if Mode.commandline CommandLine.Print "Warning: #{warning_string}" elsif Ops.greater_than(@timeout_warnings, 0) Popup.TimedWarning(warning_string, @timeout_warnings) else Popup.Warning(warning_string) end end @warnings = Builtins.add(@warnings, warning_string) nil end |