Skip to content

Commit

Permalink
use class textdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Feb 1, 2016
1 parent 9c61538 commit dc1f1b8
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions library/system/src/lib/yast2/execute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,50 +32,50 @@ class Execute
# use y2log by default
Cheetah.default_options = { logger: Y2Logger.instance }

class << self
include Yast::I18n
# Runs arguments with respect of changed root in installation.
# @see Cheetah.run for parameters
# @raise Cheetah::ExecutionFailed
def on_target(*args)
root = "/"
root = Yast::Installation.destdir if Yast::WFM.scr_chrooted?
extend Yast::I18n
textdomain "base"

if args.last.is_a? ::Hash
args.last[:chroot] = root
else
args.push(chroot: root)
end
# Runs arguments with respect of changed root in installation.
# @see Cheetah.run for parameters
# @raise Cheetah::ExecutionFailed
def self.on_target(*args)
root = "/"
root = Yast::Installation.destdir if Yast::WFM.scr_chrooted?

popup_error { Cheetah.run(*args) }
if args.last.is_a? ::Hash
args.last[:chroot] = root
else
args.push(chroot: root)
end

# Runs arguments without changed root.
# @see Cheetah.run for parameters
# @raise Cheetah::ExecutionFailed
def locally(*args)
popup_error { Cheetah.run(*args) }
end
popup_error { Cheetah.run(*args) }
end

private
# Runs arguments without changed root.
# @see Cheetah.run for parameters
# @raise Cheetah::ExecutionFailed
def self.locally(*args)
popup_error { Cheetah.run(*args) }
end

def popup_error(&block)
block.call
rescue Cheetah::ExecutionFailed => e
Yast.import "Report"
textdomain "base"
Yast::Report.Error(
_(
"Execution of command \"%{command}\" failed.\n"\
"Exit code: %{exitcode}\n"\
"Error output: %{stderr}"
) % {
command: e.commands.inspect,
exitcode: e.status.exitstatus,
stderr: e.stderr
}
)
end
def self.popup_error(&block)
block.call
rescue Cheetah::ExecutionFailed => e
Yast.import "Report"
textdomain "base"
Yast::Report.Error(
_(
"Execution of command \"%{command}\" failed.\n"\
"Exit code: %{exitcode}\n"\
"Error output: %{stderr}"
) % {
command: e.commands.inspect,
exitcode: e.status.exitstatus,
stderr: e.stderr
}
)
end

private_class_method :popup_error
end
end

0 comments on commit dc1f1b8

Please sign in to comment.