Class: Yast::CrashClass
- Inherits:
-
Module
- Object
- Module
- Yast::CrashClass
- Defined in:
- ../../library/general/src/modules/Crash.rb
Instance Method Summary (collapse)
-
- (Boolean) AskRun(op, question)
Check whether operation was last run in moment of last fail.
-
- (Boolean) Failed(op)
Check whether operation failed.
-
- (Boolean) FailedLast(op)
Check whether operation was last started when failed.
-
- (Object) Finish(op)
Finish operation.
-
- (String) LastFinished
Get last finished operation.
- - (Object) main
-
- (Object) Read
Read settings from data file to variables.
-
- (Object) Run(op)
Start operation.
-
- (Object) Write
Write data stored in variables to data files.
Instance Method Details
- (Boolean) AskRun(op, question)
Check whether operation was last run in moment of last fail. Return whether operation shall be run If not, return true (no reason to think that operation is unsafe), Otherwise ask user
154 155 156 157 158 159 |
# File '../../library/general/src/modules/Crash.rb', line 154 def AskRun(op, question) ret = true Read() ret = Popup.YesNo(question) if FailedLast(op) ret end |
- (Boolean) Failed(op)
Check whether operation failed
127 128 129 130 |
# File '../../library/general/src/modules/Crash.rb', line 127 def Failed(op) Read() Builtins.contains(@all_failed, op) end |
- (Boolean) FailedLast(op)
Check whether operation was last started when failed
135 136 137 138 |
# File '../../library/general/src/modules/Crash.rb', line 135 def FailedLast(op) Read() Builtins.contains(@last_failed, op) end |
- (Object) Finish(op)
Finish operation
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File '../../library/general/src/modules/Crash.rb', line 110 def Finish(op) Read() @all_failed = Builtins.filter(@all_failed) { |f| f != op } @this_run_active = Builtins.filter(@this_run_active) { |f| f != op } @last_failed = Builtins.filter(@last_failed) { |f| f != op } if Ops.greater_than(Builtins.size(@this_run_active), 0) @last_failed = Builtins.add(@last_failed, Ops.get(@this_run_active, 0)) end @last_done = op Write() nil end |
- (String) LastFinished
Get last finished operation
142 143 144 145 |
# File '../../library/general/src/modules/Crash.rb', line 142 def LastFinished Read() @last_done end |
- (Object) main
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File '../../library/general/src/modules/Crash.rb', line 35 def main Yast.import "Popup" # All operations that failed when were running last time @all_failed = [] # All operations that were the last started when crashed # when running last time @last_failed = [] # Last successfully finished operation @last_done = nil # List of operations which are active during this YaST2 session @this_run_active = [] # Filename of file storing crash settings @filename = "/var/lib/YaST2/crash" end |
- (Object) Read
Read settings from data file to variables
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File '../../library/general/src/modules/Crash.rb', line 57 def Read if SCR.Read(path(".target.size"), @filename) != -1 settings = Convert.convert( SCR.Read(path(".target.ycp"), @filename), :from => "any", :to => "map <string, any>" ) Builtins.y2milestone("Read settings: %1", settings) @all_failed = Ops.get_list(settings, "all_failed", []) @last_failed = Ops.get_list(settings, "last_failed", []) @last_done = Ops.get_string(settings, "last_done") end nil end |
- (Object) Run(op)
Start operation
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File '../../library/general/src/modules/Crash.rb', line 89 def Run(op) Read() if !Builtins.contains(@all_failed, op) @all_failed = Builtins.add(@all_failed, op) end if Ops.greater_than(Builtins.size(@this_run_active), 0) @last_failed = Builtins.filter(@last_failed) do |f| f != Ops.get(@this_run_active, 0) end end @this_run_active = Builtins.prepend(@this_run_active, op) if !Builtins.contains(@last_failed, op) @last_failed = Builtins.add(@last_failed, op) end Write() nil end |
- (Object) Write
Write data stored in variables to data files
74 75 76 77 78 79 80 81 82 83 84 85 |
# File '../../library/general/src/modules/Crash.rb', line 74 def Write settings = { "all_failed" => @all_failed, "last_failed" => @last_failed, "last_done" => @last_done } SCR.Write(path(".target.ycp"), @filename, settings) Builtins.y2milestone("Written settings: %1", settings) SCR.Execute(path(".target.bash"), "/bin/sync") nil end |