Module: Yast::WFM

Extended by:
Logger
Defined in:
src/ruby/yast/wfm.rb

Overview

Wrapper class for WFM component in Yast See yast documentation for WFM

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger

log

Class Method Details

.Args(*args) ⇒ Object

Returns list of arguments passed to client or element at given index

Examples:

Get all args

Yast::WFM.Args

Get only first argument

Yast::WFM.Args 0


23
24
25
# File 'src/ruby/yast/wfm.rb', line 23

def self.Args(*args)
  call_builtin_wrapper("Args", *args)
end

.CallFunction(client, args = []) ⇒ Object

calls client of given name with passed args

Examples:

call inst_moust client living in $Y2DIR/clients/inst_mouse.rb with parameter true

Yast::WFM.CallFunction("inst_mouse", [true])


187
188
189
190
191
192
193
194
195
196
# File 'src/ruby/yast/wfm.rb', line 187

def self.CallFunction(client, args = [])
  if !client.is_a?(::String)
    raise ArgumentError, "CallFunction first parameter('#{client.inspect}') have to be String."
  end
  if !args.is_a?(::Array)
    raise ArgumentError, "CallFunction second parameter('#{args.inspect}') have to be Array."
  end

  call_builtin_wrapper("CallFunction", client, args)
end

.ClientExists(client) ⇒ true, false

Note:

useful for checking before calling given client

Checks if client of given name exists on system

Examples:

Check if there is client "inst_bootloader"

Yast::WFM.ClientExists "inst_bootloader"

See Also:



35
36
37
# File 'src/ruby/yast/wfm.rb', line 35

def self.ClientExists(client)
  call_builtin_wrapper("ClientExists", client)
end

.Execute(path, *args) ⇒ Object

Note:

very limited use-case. It is needed only if installer switched to scr on target system and agent from inst-sys must be called

Runs execute on local system agent operating on inst-sys

Examples:

Run command in bash in inst-sys

Yast::WFM.Execute(Yast::Path.new(".local.bash"), "halt -p")

See Also:



51
52
53
# File 'src/ruby/yast/wfm.rb', line 51

def self.Execute(path, *args)
  call_builtin_wrapper("Execute", Yast.path(path), *args)
end

.GetEncodingString

Deprecated.

enconding is now always UTF-8

Returns current encoding code as string



59
60
61
# File 'src/ruby/yast/wfm.rb', line 59

def self.GetEncoding
  call_builtin_wrapper("GetEncoding")
end

.GetEnvironmentEncodingString

Returns enconding of environment where Yast start



66
67
68
# File 'src/ruby/yast/wfm.rb', line 66

def self.GetEnvironmentEncoding
  call_builtin_wrapper("GetEnvironmentEncoding")
end

.GetLanguageString

Returns current language without modifiers as string

Examples:

return value

Yast::WFM.GetLanguage
  => "en_US.UTF-8"


76
77
78
# File 'src/ruby/yast/wfm.rb', line 76

def self.GetLanguage
  call_builtin_wrapper("GetLanguage")
end

.Read(path, *args) ⇒ Object

Note:

very limited use-case. It is needed only if installer switched to scr on target system and agent from inst-sys must be called

Runs read on local system agent operating on inst-sys

Examples:

Read kernel cmdline

Yast::WFM.Read(path(".local.string"), "/proc/cmdline")

See Also:



92
93
94
# File 'src/ruby/yast/wfm.rb', line 92

def self.Read(path, *args)
  call_builtin_wrapper("Read", Yast.path(path), *args)
end

.scr_chrooted?Boolean

Tests if scr instance is pointed to chroot



118
119
120
# File 'src/ruby/yast/wfm.rb', line 118

def self.scr_chrooted?
  SCRGetName(SCRGetDefault()) != "scr"
end

.scr_rootString

Returns root on which scr operates. or "/mnt" when installation was switched.



125
126
127
128
129
130
131
132
133
134
# File 'src/ruby/yast/wfm.rb', line 125

def self.scr_root
  case SCRGetName(SCRGetDefault())
  when "scr"
    "/"
  when /chroot=(.*):scr/
    Regexp.last_match(1)
  else
    raise "invalid SCR instance #{SCRGetName(SCRGetDefault())}"
  end
end

.SCRClose(handle) ⇒ Object

Closes SCR handle obtained via SCROpen

If SCR is set as default, then try to switch to another reasonable SCR openned



100
101
102
# File 'src/ruby/yast/wfm.rb', line 100

def self.SCRClose(handle)
  call_builtin_wrapper("SCRClose", handle)
end

.SCRGetDefaultObject

Gets handle of current default SCR



105
106
107
# File 'src/ruby/yast/wfm.rb', line 105

def self.SCRGetDefault
  call_builtin_wrapper("SCRGetDefault")
end

.SCRGetName(handle) ⇒ String

Gets name of SCR associated with handle



112
113
114
# File 'src/ruby/yast/wfm.rb', line 112

def self.SCRGetName(handle)
  call_builtin_wrapper("SCRGetName", handle)
end

.SCROpen(name, check_version) ⇒ Object

Creates new SCR instance

It is useful for installation where agents start operation on installed system

Examples:

open SCR instance on /mnt root without version check

Yast::WFM.SCROpen("chroot=/mnt:scr", false)


148
149
150
# File 'src/ruby/yast/wfm.rb', line 148

def self.SCROpen(name, check_version)
  call_builtin_wrapper("SCROpen", name, check_version)
end

.SCRSetDefault(handle) ⇒ Object

Sets the default SCR to given handle



153
154
155
# File 'src/ruby/yast/wfm.rb', line 153

def self.SCRSetDefault(handle)
  call_builtin_wrapper("SCRSetDefault", handle)
end

.SetLanguage(language, *args) ⇒ Object

Sets language for translate with optional enconding



158
159
160
# File 'src/ruby/yast/wfm.rb', line 158

def self.SetLanguage(language, *args)
  call_builtin_wrapper("SetLanguage", language, *args)
end

.Write(path, *args) ⇒ Object

Note:

very limited use-case. It is needed only if installer switched to scr on target system and agent from inst-sys must be called

Runs write on local system agent operating on inst-sys

Examples:

Write yast inf file in inst-sys

Yast::WFM.Write(path(".local.string"), "/etc/yast.inf", yast_inf)

See Also:



174
175
176
# File 'src/ruby/yast/wfm.rb', line 174

def self.Write(path, *args)
  call_builtin_wrapper("Write", Yast.path(path), *args)
end

Instance Method Details

#call(client, arguments = []) ⇒ Object

Deprecated.


200
# File 'src/ruby/yast/wfm.rb', line 200

singleton_class.send(:alias_method, :call, :CallFunction)

#selfString



217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'src/ruby/yast/wfm.rb', line 217

private_class_method def self.internal_error_msg(e)
  msg = "Internal error. Please report a bug report with logs.\n" \
    "Run save_y2logs to get complete logs.\n"

  if e.is_a?(ArgumentError) && e.message =~ /invalid byte sequence in UTF-8/
    msg += "A string was encountered that is not valid in UTF-8.\n" \
           "The system encoding is #{Encoding.locale_charmap.inspect}.\n" \
           "Refer to https://www.suse.com/support/kb/doc?id=7018056.\n\n"
  end

  msg + "Details: #{e.message}\n" \
        "Caller:  #{e.backtrace.first}"
end