Class: Yast::ReportClass

Inherits:
Module
  • Object
show all
Includes:
Logger
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

Instance Method Details

#AnyQuestion(headline, message, yes_button_message, no_button_message, focus) ⇒ Boolean

Question with headline and Yes/No Buttons

Parameters:

  • headline (String)

    Popup Headline

  • message (String)

    Popup Message

  • yes_button_message (String)

    Yes Button Message

  • no_button_message (String)

    No Button Message

  • focus (Symbol)

    Which Button has the focus

Returns:

  • (Boolean)

    True if Yes is pressed, otherwise false


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
388
# File 'library/general/src/modules/Report.rb', line 361

def AnyQuestion(headline, message, yes_button_message, no_button_message, focus)
  Builtins.y2milestone(1, "%1", message) if @log_yesno_messages

  ret = false
  if @display_yesno_messages
    ret = if Ops.greater_than(@timeout_yesno_messages, 0)
      Popup.TimedAnyQuestion(
        headline,
        message,
        yes_button_message,
        no_button_message,
        focus,
        @timeout_yesno_messages
      )
    else
      Popup.AnyQuestion(
        headline,
        message,
        yes_button_message,
        no_button_message,
        focus
      )
    end
  end

  @yesno_messages = Builtins.add(@yesno_messages, message)
  ret
end

#ClearAllvoid

This method returns an undefined value.

Clear all stored messages (errors, messages and warnings)


321
322
323
324
325
326
327
328
# File 'library/general/src/modules/Report.rb', line 321

def ClearAll
  ClearErrors()
  ClearWarnings()
  ClearMessages()
  ClearYesNoMessages()

  nil
end

#ClearErrorsvoid

This method returns an undefined value.

Clear stored errors


305
306
307
308
309
# File 'library/general/src/modules/Report.rb', line 305

def ClearErrors
  @errors = []

  nil
end

#ClearMessagesvoid

This method returns an undefined value.

Clear stored messages


297
298
299
300
301
# File 'library/general/src/modules/Report.rb', line 297

def ClearMessages
  @messages = []

  nil
end

#ClearWarningsvoid

This method returns an undefined value.

Clear stored warnings


313
314
315
316
317
# File 'library/general/src/modules/Report.rb', line 313

def ClearWarnings
  @warnings = []

  nil
end

#ClearYesNoMessagesvoid

This method returns an undefined value.

Clear stored yes/no messages


289
290
291
292
293
# File 'library/general/src/modules/Report.rb', line 289

def ClearYesNoMessages
  @yesno_messages = []

  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.

Parameters:

  • display (Boolean)

    if true then display error popups immediately

  • timeout (Fixnum)

    dialog is automatically closed after timeout seconds. Value 0 means no time out, dialog will be closed only by user.


635
636
637
638
639
# File 'library/general/src/modules/Report.rb', line 635

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.

Parameters:

  • display (Boolean)

    if true then display message popups immediately

  • timeout (Fixnum)

    dialog is automatically closed after timeout seconds. Value 0 means no time out, dialog will be closed only by user.


662
663
664
665
666
# File 'library/general/src/modules/Report.rb', line 662

def DisplayMessages(display, timeout)
  @display_messages = display
  @timeout_messages = 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.

Parameters:

  • display (Boolean)

    if true then display warning popups immediately

  • timeout (Fixnum)

    dialog is automatically closed after timeout seconds. Value 0 means no time out, dialog will be closed only by user.


648
649
650
651
652
# File 'library/general/src/modules/Report.rb', line 648

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.

Parameters:

  • display (Boolean)

    if true then display message popups immediately

  • timeout (Fixnum)

    dialog is automatically closed after timeout seconds. Value 0 means no time out, dialog will be closed only by user.


676
677
678
679
680
# File 'library/general/src/modules/Report.rb', line 676

def DisplayYesNoMessages(display, timeout)
  @display_yesno_messages = display
  @timeout_yesno_messages = timeout
  nil
end

#Error(error_string) ⇒ nil

Note:

Displaying can be globally disabled using Display* methods.

Display and record error string.

Parameters:

  • error_string (String)

    error text, it can contain new line characters ("\n")

Returns:

  • (nil)

587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
# File 'library/general/src/modules/Report.rb', line 587

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

Parameters:

  • headline (String)

    Popup Headline

  • message (String)

    Popup Message

  • yes_button_message (String)

    Yes Button Message

  • no_button_message (String)

    No Button Message

  • focus (Symbol)

    Which Button has the focus

Returns:

  • (Boolean)

    True if Yes is pressed, otherwise false


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
424
# File 'library/general/src/modules/Report.rb', line 397

def ErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus)
  Builtins.y2milestone(1, "%1", message) if @log_yesno_messages

  ret = false
  if @display_yesno_messages
    ret = if Ops.greater_than(@timeout_yesno_messages, 0)
      Popup.TimedErrorAnyQuestion(
        headline,
        message,
        yes_button_message,
        no_button_message,
        focus,
        @timeout_yesno_messages
      )
    else
      Popup.ErrorAnyQuestion(
        headline,
        message,
        yes_button_message,
        no_button_message,
        focus
      )
    end
  end

  @yesno_messages = Builtins.add(@yesno_messages, message)
  ret
end

#ExportHash

Dump the Report settings to a map, for autoinstallation use.

Returns:

  • (Hash)

    Map with settings


262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'library/general/src/modules/Report.rb', line 262

def Export
  {
    "messages"       => {
      "log"     => @log_messages,
      "timeout" => @timeout_messages,
      "show"    => @display_messages
    },
    "errors"         => {
      "log"     => @log_errors,
      "timeout" => @timeout_errors,
      "show"    => @display_errors
    },
    "warnings"       => {
      "log"     => @log_warnings,
      "timeout" => @timeout_warnings,
      "show"    => @display_warnings
    },
    "yesno_messages" => {
      "log"     => @log_yesno_messages,
      "timeout" => @timeout_yesno_messages,
      "show"    => @display_yesno_messages
    }
  }
end

#GetMessages(warnings, errors, messages, yes_no) ⇒ String

Create rich text string from stored warning, message or error messages.

Every new line character "\n" is replaced by string "[BR]".

Parameters:

  • warning (Boolean)

    include warnings in returned string

  • errors (Boolean)

    include errors in returned string

  • messages (Boolean)

    include messages in returned string

  • yes_no (Boolean)

    include Yes/No messages in returned string

Returns:

  • (String)

    rich text string


727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
# File 'library/general/src/modules/Report.rb', line 727

def GetMessages(warnings, errors, messages, yes_no)
  richtext = ""

  if warnings
    # 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 errors
    # 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 messages
    # translators: message summary header
    richtext = Ops.add(
      Ops.add(Ops.add(richtext, "<P><B>"), _("Message:")),
      "</B><BR>"
    )

    Builtins.foreach(@messages) 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 yes_no
    # translators: message summary header
    richtext = Ops.add(
      Ops.add(Ops.add(richtext, "<P><B>"), _("Message:")),
      "</B><BR>"
    )

    Builtins.foreach(@yesno_messages) 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

#GetModifiedBoolean

Functions which returns if the settings were modified

Returns:

  • (Boolean)

    settings were modified


96
97
98
# File 'library/general/src/modules/Report.rb', line 96

def GetModified
  @modified
end

#Import(settings) ⇒ Object

Get all the Report configuration from a map.

the map may be empty.

Parameters:

  • settings (Hash)

    Map with settings (keys: "messages", "errors", "warnings"; values: map

Returns:

  • success


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
258
# File 'library/general/src/modules/Report.rb', line 218

def Import(settings)
  settings = deep_copy(settings)
  @message_settings = Ops.get_map(settings, "messages", {})
  @error_settings = Ops.get_map(settings, "errors", {})
  @warning_settings = Ops.get_map(settings, "warnings", {})
  @yesno_message_settings = 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)
  @display_messages = Ops.get_boolean(@message_settings, "show", true)
  @display_yesno_messages = Ops.get_boolean(
    @yesno_message_settings,
    "show",
    true
  )

  # timeouts
  @timeout_errors = Ops.get_integer(@error_settings, "timeout", 0)
  @timeout_warnings = Ops.get_integer(@warning_settings, "timeout",
    @default_timeout)
  @timeout_messages = Ops.get_integer(@message_settings, "timeout",
    @default_timeout)
  @timeout_yesno_messages = Ops.get_integer(
    @yesno_message_settings,
    "timeout",
    @default_timeout
  )

  # logging flags
  @log_errors = Ops.get_boolean(@error_settings, "log", true)
  @log_warnings = Ops.get_boolean(@warning_settings, "log", true)
  @log_messages = Ops.get_boolean(@message_settings, "log", true)
  @log_yesno_messages = Ops.get_boolean(
    @yesno_message_settings,
    "log",
    true
  )

  true
end

#LogErrors(log) ⇒ void

This method returns an undefined value.

Set warnings logging to .y2log file

Parameters:

  • log (Boolean)

    if log is true then warning messages will be logged


712
713
714
715
716
# File 'library/general/src/modules/Report.rb', line 712

def LogErrors(log)
  @log_errors = log

  nil
end

#LogMessages(log) ⇒ void

This method returns an undefined value.

Set messages logging to .y2log file

Parameters:

  • log (Boolean)

    if log is true then messages will be logged


703
704
705
706
707
# File 'library/general/src/modules/Report.rb', line 703

def LogMessages(log)
  @log_messages = log

  nil
end

#LogWarnings(log) ⇒ void

This method returns an undefined value.

Set warnings logging to .y2log file

Parameters:

  • log (Boolean)

    if log is true then warning messages will be logged


685
686
687
688
689
# File 'library/general/src/modules/Report.rb', line 685

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

Parameters:

  • log (Boolean)

    if log is true then messages will be logged


694
695
696
697
698
# File 'library/general/src/modules/Report.rb', line 694

def LogYesNoMessages(log)
  @log_yesno_messages = log

  nil
end

#LongError(error_string, width: 60, height: 10) ⇒ void

This method returns an undefined value.

Store new error text, the text is displayed in a richtext widget - long lines are automatically wrapped

Parameters:

  • error_string (String)

    error text (it can contain rich text tags)

  • width (Integer) (defaults to: 60)

    width of popup (@see Popup#LongErrorGeometry)

  • height (Integer) (defaults to: 10)

    height of popup (@see Popup#LongErrorGeometry)


610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
# File 'library/general/src/modules/Report.rb', line 610

def LongError(error_string, width: 60, height: 10)
  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.TimedLongErrorGeometry(error_string, @timeout_errors, width, height)
    else
      Popup.LongErrorGeometry(error_string, width, height)
    end
  end

  @errors = Builtins.add(@errors, error_string)

  nil
end

#LongMessage(message_string, width: 60, height: 10) ⇒ void

This method returns an undefined value.

Store new message text, the text is displayed in a richtext widget - long lines are automatically wrapped

Parameters:

  • message_string (String)

    message text (it can contain rich text tags)

  • width (Integer) (defaults to: 60)

    width of popup (@see Popup#LongMessageGeometry)

  • height (Integer) (defaults to: 10)

    height of popup (@see Popup#LongMessageGeometry)


496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'library/general/src/modules/Report.rb', line 496

def LongMessage(message_string, width: 60, height: 10)
  Builtins.y2milestone(1, "%1", message_string) if @log_messages

  if @display_messages
    if Mode.commandline
      CommandLine.Print(message_string)
    elsif Ops.greater_than(@timeout_messages, 0)
      Popup.TimedLongMessageGeometry(message_string, @timeout_messages, width, height)
    else
      Popup.LongMessageGeometry(message_string, width, height)
    end
  end

  @messages = Builtins.add(@messages, message_string)

  nil
end

#LongWarning(warning_string, width: 60, height: 10) ⇒ void

This method returns an undefined value.

Store new warning text, the text is displayed in a richtext widget - long lines are automatically wrapped

Parameters:

  • warning_string (String)

    warning text (it can contain rich text tags)

  • width (Integer) (defaults to: 60)

    width of popup (@see Popup#LongWarningGeometry)

  • height (Integer) (defaults to: 10)

    height of popup (@see Popup#LongWarningGeometry)


564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
# File 'library/general/src/modules/Report.rb', line 564

def LongWarning(warning_string, width: 60, height: 10)
  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.TimedLongWarningGeometry(warning_string, @timeout_warnings, width, height)
    else
      Popup.LongWarningGeometry(warning_string, width, height)
    end
  end

  @warnings = Builtins.add(@warnings, warning_string)

  nil
end

#mainObject


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
84
# File 'library/general/src/modules/Report.rb', line 43

def main
  textdomain "base"

  Yast.import "Mode"
  Yast.import "Popup"
  Yast.import "Summary"
  Yast.import "CommandLine"

  # stored messages
  @errors = []
  @warnings = []
  @messages = []
  @yesno_messages = []

  # display flags
  @display_errors = true
  @display_warnings = true
  @display_messages = true
  @display_yesno_messages = 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
  @timeout_messages = @default_timeout
  @timeout_yesno_messages = @default_timeout

  # logging flags
  @log_errors = true
  @log_warnings = true
  @log_messages = true
  @log_yesno_messages = true

  @message_settings = {}
  @error_settings = {}
  @warning_settings = {}
  @yesno_message_settings = {}

  # default value of settings modified
  @modified = false
end

#Message(message_string) ⇒ void

This method returns an undefined value.

Store new message text

Parameters:

  • message_string (String)

    message text, it can contain new line characters ("\n")


473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'library/general/src/modules/Report.rb', line 473

def Message(message_string)
  Builtins.y2milestone(1, "%1", message_string) if @log_messages

  if @display_messages
    if Mode.commandline
      CommandLine.Print(message_string)
    elsif Ops.greater_than(@timeout_messages, 0)
      Popup.TimedMessage(message_string, @timeout_messages)
    else
      Popup.Message(message_string)
    end
  end

  @messages = Builtins.add(@messages, message_string)

  nil
end

#NumErrorsFixnum

Return number of stored errors

Returns:

  • (Fixnum)

    number of errors


350
351
352
# File 'library/general/src/modules/Report.rb', line 350

def NumErrors
  Builtins.size(@errors)
end

#NumMessagesFixnum

Return number of stored messages

Returns:

  • (Fixnum)

    number of messages


338
339
340
# File 'library/general/src/modules/Report.rb', line 338

def NumMessages
  Builtins.size(@messages)
end

#NumWarningsFixnum

Return number of stored warnings

Returns:

  • (Fixnum)

    number of warnings


344
345
346
# File 'library/general/src/modules/Report.rb', line 344

def NumWarnings
  Builtins.size(@warnings)
end

#NumYesNoMessagesFixnum

Return number of stored yes/no messages

Returns:

  • (Fixnum)

    number of messages


332
333
334
# File 'library/general/src/modules/Report.rb', line 332

def NumYesNoMessages
  Builtins.size(@yesno_messages)
end

#SetModifiedObject

Function sets internal variable, which indicates, that any settings were modified, to "true"


88
89
90
91
92
# File 'library/general/src/modules/Report.rb', line 88

def SetModified
  @modified = true

  nil
end

#ShowText(headline_string, message_string) ⇒ void

This method returns an undefined value.

Store new message text

Parameters:

  • headline_string (String)

    Headline String

  • message_string (String)

    message text, it can contain new line characters ("\n")


518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
# File 'library/general/src/modules/Report.rb', line 518

def ShowText(headline_string, message_string)
  Builtins.y2milestone(1, "%1", message_string) if @log_errors

  if @display_errors
    if Mode.commandline
      CommandLine.Print(headline_string)
      CommandLine.Print("\n\n")
      CommandLine.Print(message_string)
    elsif Ops.greater_than(@timeout_errors, 0)
      Popup.ShowTextTimed(headline_string, message_string, @timeout_errors)
    else
      Popup.ShowText(headline_string, message_string)
    end
  end

  @messages = Builtins.add(@messages, message_string)

  nil
end

#SummaryObject

Summary of current settings

Returns:

  • Html formatted configuration summary


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
210
# File 'library/general/src/modules/Report.rb', line 102

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
      @display_messages ? _("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"), @timeout_messages)
  )
  # 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
      @log_messages ? _("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

Parameters:

  • warning_string (String)

    warning text, it can contain new line characters ("\n")


541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# File 'library/general/src/modules/Report.rb', line 541

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

#yesno_popup(message, extra_args = {}) ⇒ Boolean

Question presented via the Yast2::Popup class

It works like any other method used to present yesno_messages, but it delegates drawing the pop-up to Yast2::Popup.show, in case the message must be presented to the user (which can be configured via #DisplayYesNoMessages).

All the arguments are forwarded to #Yast2::Popup.show almost as-is, but some aspects must be observed:

  • The argument :timeout will be ignored, the timeout fixed in the Report module will always be used instead (again, see #DisplayYesNoMessages).
  • The button ids must be :yes and :no, to honor the Report API.
  • Due to the previous point, if no :buttons argument is provided, the value :yes_no will be used for it.

Like any other method used to present yesno_messages, false is always returned if the system is configured to not display messages, no matter what was selected as the focused default answer.

Parameters:

  • message (String)

    Popup message, forwarded to Yast2::Popup.show

  • extra_args (Hash) (defaults to: {})

    Extra options to be forwarded to Yast2::Popup.show, see description for some considerations

Returns:

  • (Boolean)

    True if :yes is pressed, otherwise false


450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'library/general/src/modules/Report.rb', line 450

def yesno_popup(message, extra_args = {})
  # Use exactly the same y2milestone call than other yesno methods
  Builtins.y2milestone(1, "%1", message) if @log_yesno_messages

  log.warn "Report.yesno_popup will ignore the :timeout argument" if extra_args.key?(:timeout)

  ret =
    if @display_yesno_messages
      args = { buttons: :yes_no }.merge(extra_args)
      args[:timeout] = @timeout_yesno_messages
      answer = Yast2::Popup.show(message, args)
      answer == :yes
    else
      false
    end

  @yesno_messages << message
  ret
end