Class: Yast::InstErrorClass
- Inherits:
-
Module
- Object
- Module
- Yast::InstErrorClass
- Defined in:
- ../../src/modules/InstError.rb
Instance Method Summary (collapse)
- - (Object) main
- - (Object) SaveLogs
-
- (Object) ShowErrorPopUp(heading, error_text, details)
Function opens a pop-up error message (defined by the parameters).
-
- (Object) ShowErrorPopupWithLogs(error_text)
Function is similar to ShowErrorPopUp but the error details are grabbed automatically from YaST logs.
Instance Method Details
- (Object) main
37 38 39 40 41 42 43 44 45 |
# File '../../src/modules/InstError.rb', line 37 def main Yast.import "UI" textdomain "base" Yast.import "Icon" Yast.import "Label" Yast.import "String" Yast.import "Report" end |
- (Object) SaveLogs
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File '../../src/modules/InstError.rb', line 47 def SaveLogs cmd = Convert.to_map( WFM.Execute(path(".local.bash_output"), "echo ${HOME}") ) homedir = "/" if Ops.get_integer(cmd, "exit", -1) == 0 homedir = Ops.get( Builtins.splitstring(Ops.get_string(cmd, "stdout", "/"), "\n"), 0, "/" ) homedir = "/" if homedir == "" else Builtins.y2warning( "Unable to find out home dir: %1, using %2", cmd, homedir ) end homedir = Builtins.sformat("%1/y2logs.tgz", homedir) savelogsto = UI.AskForSaveFileName( homedir, "*.tgz *.tar.gz *.tar.bz2", _("Save y2logs to...") ) return nil if savelogsto.nil? # Busy message, %1 is replaced with a filename UI.OpenDialog( Label(Builtins.sformat(_("Saving YaST logs to %1..."), savelogsto)) ) Builtins.y2milestone("Saving YaST logs to: %1", savelogsto) cmd = Convert.to_map( WFM.Execute( path(".local.bash_output"), Builtins.sformat("save_y2logs '%1'", String.Quote(savelogsto)) ) ) dialog_ret = nil if Ops.get_integer(cmd, "exit", -1) != 0 Builtins.y2error("Unable to save logs to %1", savelogsto) Report.Error( Builtins.sformat( # Error message, %1 is replaced with a filename # %2 with am error reason (there is a newline between %1 and %2) _("Unable to save YaST logs to %1\n%2"), savelogsto, Ops.get_string(cmd, "stderr", "") ) ) dialog_ret = false else Builtins.y2milestone("Logs have been saved to: %1", savelogsto) dialog_ret = true end UI.CloseDialog dialog_ret end |
- (Object) ShowErrorPopUp(heading, error_text, details)
Function opens a pop-up error message (defined by the parameters). Reports where to report a bug and which logs to attach. It additionally offers to save logs directly from the dialog.
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 '../../src/modules/InstError.rb', line 122 def ShowErrorPopUp(heading, error_text, details) success = UI.OpenDialog( Opt(:decorated, :warncolor), VBox( Left(HBox(HSquash(MarginBox(0.5, 0.2, Icon.Error)), Heading(heading))), MarginBox( 1, 0.5, VBox( Left(Label(error_text)), # `VSpacing (1), Left( if details.nil? Label( Builtins.sformat( # TRANSLATORS: part of an error message # // %1 - logfile, possibly with errors _( "More information can be found near the end of the '%1' file." ), "/var/log/YaST2/y2log" ) ) else MinSize(80, 10, RichText(Opt(:plainText, :hstretch), details)) end ), # `VSpacing (1), Left( Label( Builtins.sformat( # TRANSLATORS: part of an error message # %1 - link to our bugzilla # %2 - directory where YaST logs are stored # %3 - link to the Yast Bug Reporting HOWTO Web page _( "This is worth reporting a bug at %1.\n" \ "Please, attach also all YaST logs stored in the '%2' directory.\n" \ "See %3 for more information about YaST logs." ), "http://bugzilla.novell.com/", "/var/log/YaST2/", # link to the Yast Bug Reporting HOWTO # for translators: use the localized page for your language if it exists, # check the combo box "In other laguages" on top of the page _("http://en.opensuse.org/Bugs/YaST") ) ) ) ) ), ButtonBox( # FIXME: BNC #422612, Use `opt(`noSanityCheck) later PushButton( Id(:save_y2logs), Opt(:cancelButton), _("&Save YaST Logs...") ), PushButton(Id(:ok), Opt(:key_F10), Label.OKButton) ) ) ) if success != true Builtins.y2error( "Cannot open a dialog: %1/%2/%3", heading, error_text, details ) return end uret = nil loop do uret = UI.UserInput if uret == :save_y2logs SaveLogs() else break end end UI.CloseDialog nil end |
- (Object) ShowErrorPopupWithLogs(error_text)
Function is similar to ShowErrorPopUp but the error details are grabbed automatically from YaST logs.
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File '../../src/modules/InstError.rb', line 216 def ShowErrorPopupWithLogs(error_text) cmd = Convert.to_map( WFM.Execute( path(".local.bash_output"), "tail -n 200 /var/log/YaST2/y2log | grep ' <\\(3\\|5\\)> '" ) ) details = cmd["stdout"] if cmd["exit"] == 0 && !cmd["stdout"].empty? ShowErrorPopUp( _("Installation Error"), error_text, details ) nil end |