Skip to content

Commit

Permalink
Merge branch 'master' of github.com:yast/yast-yast2 into sshd_enablement
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Apr 2, 2014
2 parents 286de51 + 315cb7c commit 5d445f7
Show file tree
Hide file tree
Showing 73 changed files with 1,879 additions and 1,377 deletions.
28 changes: 18 additions & 10 deletions library/desktop/src/clients/menu.rb
Expand Up @@ -330,37 +330,45 @@ def ShowNcursesHelp
"Select or activate elements with [SPACE] or [ENTER].\n" +
"Some elements use arrow keys (e.g., to scroll in lists).</p>"
) +
# NCurses Control Center help 2/9
# NCurses Control Center help 2/10
_(
"<p>Tree navigation is also done by arrow keys. To open or close a " +
"branch use [SPACE]. For modules showing a tree (might look like a list) " +
"of configuration items on the left side use [ENTER] to get corresponding " +
"dialog on the right.</p>"
) +
# NCurses Control Center help 3/10
_(
"<p>Buttons are equipped with shortcut keys (the highlighted\nletter). Use [ALT] and the letter to activate the button.</p>"
) +
# NCurses Control Center help 3/9
# NCurses Control Center help 4/10
_(
"<p>Press [ESC] to close selection pop-ups (e.g., from\nmenu buttons) without choosing anything.</p>\n"
) +
# NCurses Control Center help 4/9
# NCurses Control Center help 5/10
_(
"<p>2) <i>Substitution of Keystrokes</i><br>\n" +
"<p>Because the environment can affect the use of the keyboard,\n" +
"there is more than one way to navigate the dialog pages.\n" +
"If [TAB] and [SHIFT] (or [ALT]) + [TAB] do not work,\n" +
"move focus forward with [CTRL] + [F] and backward with [CTRL] + [B].</p>"
) +
# NCurses Control Center help 5/9
# NCurses Control Center help 6/10
_(
"<p>If [ALT] + [letter] does not work,\n" +
"try [ESC] + [letter]. Example: [ESC] + [H] for [ALT] + [H].\n" +
"[ESC] + [TAB] is also a substitute for [ALT] + [TAB].</p>"
) +
# NCurses Control Center help 6/9
# NCurses Control Center help 7/10
_(
"<p>3) <i>Function Keys</i><br>\n" +
"F keys provide a quick access to main functions.\n" +
"Press F1 to get the function key bindings for the current dialog.</p>"
"F keys provide a quick access to main functions. " +
"The function key bindings for the current dialog are " +
"shown in the bottom line.</p>"
) +
# NCurses Control Center help 7/9
# NCurses Control Center help 8/10
_("<p>The F keys are usually connected to a certain action:</p>") +
# NCurses Control Center help 8/9
# NCurses Control Center help 9/10
_(
"F1 = Help<br>\n" +
"F2 = Info or Description<br>\n" +
Expand All @@ -373,7 +381,7 @@ def ShowNcursesHelp
"F9 = Abort or Cancel<br>\n" +
"F10 = OK, Next, Finish, or Accept<br>"
) +
# NCurses Control Center help 9/9
# NCurses Control Center help 10/10
_("<p>In some environments, all or some\nF keys are not available.</p>")

Popup.LongText(headline, RichText(help), 60, 20)
Expand Down
24 changes: 23 additions & 1 deletion library/general/src/modules/OSRelease.rb
Expand Up @@ -30,17 +30,39 @@ module Yast

import "Misc"
import "Stage"
import "FileUtils"

class OSReleaseFileMissingError < StandardError
def initialize(message)
super message
end
end

class OSReleaseClass < Module
include Yast::Logger

def initialize
@file_path = "/etc/os-release"
end

# Get information about the OS release
# Throws exception Yast::OSReleaseFileMissingError if release file
# is missing.
#
# @param [String] directory containing the installed system (/ in installed system)
# @return [String] the release information
def ReleaseInformation(directory)
MakeNiceName(Misc.CustomSysconfigRead("PRETTY_NAME", "?", directory + @file_path))
release_file = File.join(directory, @file_path)

if !FileUtils.Exists(release_file)
log.info "Release file #{release_file} not found"
raise(
OSReleaseFileMissingError,
_("Release file %{file} not found") % { :file => release_file }
)
end

MakeNiceName(Misc.CustomSysconfigRead("PRETTY_NAME", "?", release_file))
end

# Get information about the OS name
Expand Down
14 changes: 14 additions & 0 deletions library/general/src/modules/Popup.rb
Expand Up @@ -1173,6 +1173,20 @@ def ShowFeedback(headline, message)
nil
end

# Run the block with a feeback popup
# The popup is automatically closed at the end
# (even when an exception is raised)
# @see {ShowFeedback} and {ClearFeedback} for details
# @param headline [String] popup headline (displayed in bold)
# @param message [String] message with details, displayed below the headline
# @param block block to execute
def Feedback(headline, message, &block)
ShowFeedback(headline, message)
yield
ensure
ClearFeedback()
end

# Show a simple message and wait until user clicked "OK".
#
#
Expand Down
6 changes: 4 additions & 2 deletions library/general/test/Makefile.am
@@ -1,9 +1,11 @@
TESTS = \
asciifile_test.rb \
linuxrc_test.rb \
hooks_test.rb
hooks_test.rb \
os_release_test.rb \
popup_test.rb

TEST_EXTENSIONS = .rb
RB_LOG_COMPILER = rspec
VERBOSE = 1
EXTRA_DIST = $(TESTS)
EXTRA_DIST = $(TESTS) test_helper.rb
2 changes: 1 addition & 1 deletion library/general/test/asciifile_test.rb
@@ -1,6 +1,6 @@
#! /usr/bin/env rspec

ENV["Y2DIR"] = File.expand_path("../../src", __FILE__)
require File.expand_path("../test_helper.rb", __FILE__)

require "yast"
include Yast
Expand Down
2 changes: 1 addition & 1 deletion library/general/test/hooks_test.rb
@@ -1,6 +1,6 @@
#! /usr/bin/env rspec

ENV["Y2DIR"] = File.expand_path("../../src", __FILE__)
require File.expand_path("../test_helper.rb", __FILE__)

require "yast"

Expand Down
2 changes: 1 addition & 1 deletion library/general/test/linuxrc_test.rb
@@ -1,6 +1,6 @@
#! /usr/bin/rspec

ENV["Y2DIR"] = File.expand_path("../../src", __FILE__)
require File.expand_path("../test_helper.rb", __FILE__)

require "yast"
include Yast
Expand Down
26 changes: 26 additions & 0 deletions library/general/test/os_release_test.rb
@@ -0,0 +1,26 @@
#! /usr/bin/env rspec

require File.expand_path("../test_helper.rb", __FILE__)

require "yast"

Yast.import "OSRelease"
Yast.import "FileUtils"
Yast.import "Misc"

describe Yast::OSRelease do
describe "#ReleaseInformation" do
it "returns product name if release file exists" do
Yast::FileUtils.stub(:Exists).and_return(true)
Yast::Misc.stub(:CustomSysconfigRead).and_return("openSUSE 13.1 (Bottle) (x86_64)")
expect(Yast::OSRelease.ReleaseInformation("/mnt")).to eq "openSUSE 13.1"
end

it "throws exception Yast::OSReleaseFileMissingError if release file does not exist" do
Yast::FileUtils.stub(:Exists).and_return(false)
expect { Yast::OSRelease.ReleaseInformation("/mnt") }.to raise_error(
Yast::OSReleaseFileMissingError
)
end
end
end
42 changes: 42 additions & 0 deletions library/general/test/popup_test.rb
@@ -0,0 +1,42 @@
#! /usr/bin/env rspec

require File.expand_path("../test_helper.rb", __FILE__)

require "yast"
include Yast

Yast.import "Popup"

describe "Popup" do
let(:ui) { double("Yast::UI") }

before do
# generic UI stubs for the progress dialog
stub_const("Yast::UI", ui)
end

describe ".Feedback" do
before do
expect(ui).to receive(:OpenDialog)
expect(ui).to receive(:CloseDialog)
allow(ui).to receive(:BusyCursor)
allow(ui).to receive(:GetDisplayInfo).and_return({})
end

it "opens a popup dialog and closes it at the end" do
# just pass an empty block
Popup.Feedback("Label", "Message") {}
end

it "closes the popup even when an exception occurs in the block" do
# raise an exception in the block
expect{Popup.Feedback("Label", "Message") { raise "TEST"}}.to raise_error(RuntimeError, "TEST")
end

it "raises exception when the block parameter is missing" do
# no block passed
expect{Popup.Feedback("Label", "Message")}.to raise_error(LocalJumpError)
end
end

end
5 changes: 5 additions & 0 deletions library/general/test/test_helper.rb
@@ -0,0 +1,5 @@

top_srcdir = File.expand_path("../../../..", __FILE__)
inc_dirs = Dir.glob("#{top_srcdir}/library/*/src")
ENV["Y2DIR"] = inc_dirs.join(":")

21 changes: 19 additions & 2 deletions library/network/src/modules/CWMFirewallInterfaces.rb
Expand Up @@ -833,7 +833,16 @@ def OpenFirewallInit(widget, key)
end
services = Ops.get_list(widget, "services", [])
InitAllInterfacesList()
InitAllowedInterfaces(services)

begin
InitAllowedInterfaces(services)
rescue SuSEFirewalServiceNotFound => e
Report.Error(
# TRANSLATORS: Error message, do not translate %{details}
_("Error checking service status:\n%{details}") % { :details => e.message }
)
end

open_firewall = Ops.greater_than(Builtins.size(@allowed_interfaces), 0)
firewall_enabled = SuSEFirewall.GetEnableService &&
Ops.greater_than(Builtins.size(@all_interfaces), 0)
Expand All @@ -859,7 +868,15 @@ def OpenFirewallStore(widget, key, event)
return
end
services = Ops.get_list(widget, "services", [])
StoreAllowedInterfaces(services)

begin
StoreAllowedInterfaces(services)
rescue SuSEFirewalServiceNotFound => e
Report.Error(
# TRANSLATORS: Error message, do not translate %{details}
_("Error setting service status:\n%{details}") % { :details => e.message }
)
end

nil
end
Expand Down
5 changes: 0 additions & 5 deletions library/network/src/modules/SuSEFirewall.rb
Expand Up @@ -2168,11 +2168,6 @@ def IsServiceSupportedInZone(service, zone)
return nil if !IsKnownZone(zone)

needed = SuSEFirewallServices.GetNeededPortsAndProtocols(service)
# unknown service
if needed == nil
Builtins.y2error("Undefined service '%1'", service)
return nil
end

# SuSEFirewall feature FW_PROTECT_FROM_INT
# should not be protected and searched zones include also internal (or the zone IS internal, sure)
Expand Down

0 comments on commit 5d445f7

Please sign in to comment.