Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
Conflicts:
	package/yast2.changes
  • Loading branch information
jsrain committed May 2, 2014
2 parents 1df38db + 1f853ad commit 915883d
Show file tree
Hide file tree
Showing 19 changed files with 814 additions and 428 deletions.
4 changes: 2 additions & 2 deletions library/cwm/src/modules/DialogTree.rb
Expand Up @@ -292,9 +292,9 @@ def Run(settings)
# @return [Symbol] wizard sequencer symbol
def RunAndHide(settings)
settings = deep_copy(settings)
ret = Run(settings)
Run(settings)
ensure
UI.CloseDialog
ret
end

# Display the dialog and run its event loop
Expand Down
95 changes: 50 additions & 45 deletions library/cwm/src/modules/TablePopup.rb
Expand Up @@ -503,16 +503,19 @@ def askForNewOption(possible, editable, descr)
HSpacing(1)
)
UI.OpenDialog(widget)
UI.SetFocus(Id(:optname))
ret = nil
option = nil
while ret != :_tp_ok && ret != :_tp_cancel
ret = UI.UserInput
if ret == :_tp_ok
option = Convert.to_string(UI.QueryWidget(Id(:optname), :Value))
begin
UI.SetFocus(Id(:optname))
ret = nil
option = nil
while ret != :_tp_ok && ret != :_tp_cancel
ret = UI.UserInput
if ret == :_tp_ok
option = Convert.to_string(UI.QueryWidget(Id(:optname), :Value))
end
end
ensure
UI.CloseDialog
end
UI.CloseDialog
return nil if ret == :_tp_cancel
return option if Ops.get(known_keys, option, false)
Ops.get(val2key, option, option)
Expand Down Expand Up @@ -563,54 +566,56 @@ def singleOptionEditPopup(option)
HSpacing(1)
)
UI.OpenDialog(contents)
if Ops.get(popup_descr, "init") != nil
toEval = Convert.convert(
Ops.get(popup_descr, "init"),
:from => "any",
:to => "void (any, string)"
)
toEval.call(opt_id, opt_key)
end
ret = nil
event_descr = {}
while ret != :_tp_ok && ret != :_tp_cancel
event_descr2 = UI.WaitForEvent
event_descr2 = { "ID" => :_tp_ok } if Mode.test
ret = Ops.get(event_descr2, "ID")
if Ops.get(popup_descr, "handle") != nil
begin
if Ops.get(popup_descr, "init") != nil
toEval = Convert.convert(
Ops.get(popup_descr, "handle"),
Ops.get(popup_descr, "init"),
:from => "any",
:to => "void (any, string, map)"
:to => "void (any, string)"
)
toEval.call(opt_id, opt_key, event_descr2)
toEval.call(opt_id, opt_key)
end
if ret == :_tp_ok
val_type = Ops.get_symbol(popup_descr, "validate_type")
if val_type == :function
ret = nil
event_descr = {}
while ret != :_tp_ok && ret != :_tp_cancel
event_descr2 = UI.WaitForEvent
event_descr2 = { "ID" => :_tp_ok } if Mode.test
ret = Ops.get(event_descr2, "ID")
if Ops.get(popup_descr, "handle") != nil
toEval = Convert.convert(
Ops.get(popup_descr, "validate_function"),
Ops.get(popup_descr, "handle"),
:from => "any",
:to => "boolean (any, string, map)"
:to => "void (any, string, map)"
)
if toEval != nil
ret = nil if !toEval.call(opt_id, opt_key, event_descr2)
toEval.call(opt_id, opt_key, event_descr2)
end
if ret == :_tp_ok
val_type = Ops.get_symbol(popup_descr, "validate_type")
if val_type == :function
toEval = Convert.convert(
Ops.get(popup_descr, "validate_function"),
:from => "any",
:to => "boolean (any, string, map)"
)
if toEval != nil
ret = nil if !toEval.call(opt_id, opt_key, event_descr2)
end
elsif !CWM.validateWidget(popup_descr, event_descr2, opt_key)
ret = nil
end
elsif !CWM.validateWidget(popup_descr, event_descr2, opt_key)
ret = nil
end
end
if ret == :_tp_ok && Ops.get(popup_descr, "store") != nil
toEval = Convert.convert(
Ops.get(popup_descr, "store"),
:from => "any",
:to => "void (any, string)"
)
toEval.call(opt_id, opt_key)
end
ensure
UI.CloseDialog
end
if ret == :_tp_ok && Ops.get(popup_descr, "store") != nil
toEval = Convert.convert(
Ops.get(popup_descr, "store"),
:from => "any",
:to => "void (any, string)"
)
toEval.call(opt_id, opt_key)
end

UI.CloseDialog
Convert.to_symbol(ret)
end

Expand Down
23 changes: 16 additions & 7 deletions library/general/src/modules/Hooks.rb
@@ -1,5 +1,6 @@
require 'pathname'
require 'ostruct'
require 'yast'

## Description
#
Expand Down Expand Up @@ -59,6 +60,8 @@
module Yast
class HooksClass < Module

include Yast::Logger

attr_reader :hooks, :last, :search_path

private :hooks
Expand Down Expand Up @@ -94,7 +97,7 @@ def exists? hook_name

def create hook_name, source_file
if hooks[hook_name]
Builtins.y2warning "Hook '#{hook_name}' has already been run from #{hooks[hook_name].caller_path}"
log.warn "Hook '#{hook_name}' has already been run from #{hooks[hook_name].caller_path}"
hooks[hook_name]
else
hooks[hook_name] = Hook.new(hook_name, source_file, search_path)
Expand Down Expand Up @@ -146,15 +149,17 @@ def set_default_path
end

class Hook
include Yast::Logger

attr_reader :name, :results, :files, :caller_path, :search_path

def initialize name, caller_path, search_path
log.debug "Creating hook '#{name}' from '#{self.caller_path}'"
search_path.verify!
@search_path = search_path
@name = name
@files = find_hook_files(name).map {|path| HookFile.new(path) }
@caller_path = caller_path.split(':in').first
Builtins.y2milestone "Creating hook '#{name}' from '#{self.caller_path}'"
end

def execute
Expand All @@ -181,28 +186,32 @@ def failed?
private

def find_hook_files hook_name
Builtins.y2milestone "Searching for hook files in '#{search_path}'..."
log.debug "Searching for hook files in '#{search_path}'..."
hook_files = search_path.children.select do |file|
file.basename.fnmatch?("#{hook_name}_[0-9][0-9]_*")
end
Builtins.y2milestone "Found #{hook_files.size} hook files: " +
"#{hook_files.map {|f| f.basename.to_s}.join(', ')}"
unless hook_files.empty?
log.info "Found #{hook_files.size} hook files: " +
"#{hook_files.map {|f| f.basename.to_s}.join(', ')}"
end
hook_files.sort
end
end

class HookFile
include Yast::Logger

attr_reader :path, :content, :result

def initialize path
@path = path
end

def execute
Builtins.y2milestone "Executing hook file '#{path}'"
log.info "Executing hook file '#{path}'"
@result = OpenStruct.new(SCR.Execute(Path.new(".target.bash_output"), path.to_s))
if failed?
Builtins.y2error "Hook file '#{path.basename}' failed with stderr: #{result.stderr}"
log.error "Hook file '#{path.basename}' failed with stderr: #{result.stderr}"
end
result
end
Expand Down
7 changes: 6 additions & 1 deletion library/network/src/modules/NetworkService.rb
Expand Up @@ -179,7 +179,7 @@ def Read
when "wicked"
@current_name = :wicked
else
if Mode.installation || Mode.config
if running_installer?
Builtins.y2milestone("Running in installer, use default: wicked")
@current_name = :wicked
else
Expand Down Expand Up @@ -420,6 +420,11 @@ def systemctl_reload_restart
nil
end

# Check if currently runs in installer
def running_installer?
Mode.installation || Mode.config || Mode.update
end

publish :function => :Read, :type => "void ()"
publish :function => :Modified, :type => "boolean ()"
publish :function => :is_backend_available, :type => "boolean (symbol)"
Expand Down

0 comments on commit 915883d

Please sign in to comment.