Skip to content

Commit

Permalink
Make rubocop happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Jun 2, 2016
1 parent b4770c1 commit 353aef3
Show file tree
Hide file tree
Showing 12 changed files with 404 additions and 499 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -5,7 +5,7 @@ before_install:
# disable rvm, use system Ruby
- rvm reset
- wget https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh
- sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2 yast2-country-data" -g "yast-rake gettext simplecov coveralls rubocop:0.29.1"
- sh ./travis_setup.sh -p "rake yast2-devtools yast2 rake yast2-country-data" -g "yast-rake gettext yard rspec:3.3.0 simplecov coveralls rubocop:0.29.1"
script:
- rake check:syntax
- rake check:pot
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
@@ -1,6 +1,6 @@
require "yast/rake"

Yast::Tasks.configuration do |conf|
#lets ignore license check for now
# lets ignore license check for now
conf.skip_license_check << /.*/
end
8 changes: 3 additions & 5 deletions src/clients/ntp-client.rb
Expand Up @@ -13,7 +13,7 @@ class NtpClientClient < Client
def main
Yast.import "UI"

#**
# **
# <h3>Configuration of the ntp-client</h3>

textdomain "ntp-client"
Expand All @@ -27,10 +27,8 @@ def main

Yast.include self, "ntp-client/wizards.rb"


Yast.include self, "ntp-client/commandline.rb"


# main ui function
@ret = CommandLine.Run(@cmdline)
Builtins.y2debug("ret=%1", @ret)
Expand All @@ -39,7 +37,7 @@ def main
Builtins.y2milestone("NtpClient module finished")
Builtins.y2milestone("----------------------------------------")

deep_copy(@ret)
deep_copy(@ret)

# EOF
end
Expand All @@ -48,7 +46,7 @@ def main
# @return [Boolean] true if settings were saved
def GuiHandler
ret = NtpClientSequence()
return false if ret == :abort || ret == :back || ret == nil
return false if ret == :abort || ret == :back || ret.nil?
true
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/clients/ntp-client_auto.rb
Expand Up @@ -118,7 +118,7 @@ def main
Builtins.y2milestone("NtpClient auto finished")
Builtins.y2milestone("----------------------------------------")

deep_copy(@ret)
deep_copy(@ret)

# EOF
end
Expand Down
83 changes: 39 additions & 44 deletions src/clients/ntp-client_proposal.rb
Expand Up @@ -12,7 +12,6 @@ def main
Yast.import "UI"
textdomain "ntp-client"


Yast.import "Address"
Yast.import "NetworkService"
Yast.import "NtpClient"
Expand Down Expand Up @@ -52,11 +51,9 @@ def main
@param
)

# FIXME must go to module to preserve value
# FIXME: must go to module to preserve value
@ntp_was_used = false



if @func == "GetNTPEnabled"
@ret = GetNTPEnabled()
elsif @func == "SetUseNTP"
Expand All @@ -71,7 +68,7 @@ def main
elsif @func == "ui_init"
@rp = Ops.get_term(@param, "replace_point") { Id(:rp) }
@ft = Ops.get_boolean(@param, "first_time", false)
@ret = ui_init(@rp,@ft)
@ret = ui_init(@rp, @ft)
elsif @func == "ui_try_save"
@ret = ui_try_save
elsif @func == "ui_enable_disable_widgets"
Expand All @@ -88,13 +85,18 @@ def main
def ui_help_text
# help text
tmp = _(
"<p>Press <b>Synchronize Now</b>, to get your system time set correctly using the selected NTP server. If you want to make use of NTP permanently, enable the <b>Save NTP Configuration</b> option</p>"
"<p>Press <b>Synchronize Now</b>, to get your system time set correctly " \
"using the selected NTP server. If you want to make use of NTP permanently, " \
"enable the <b>Save NTP Configuration</b> option</p>"
)

tmp = Ops.add(
tmp,
_(
"<p>Enabling <b>Run NTP as daemon</b> option, the NTP service will be started as daemon. Otherwise the system time will be synchronized periodically. The default interval is 15 min. You can change it after installation with the <b>yast2 ntp-client module</b>.</p>"
"<p>Enabling <b>Run NTP as daemon</b> option, the NTP service will be " \
"started as daemon. Otherwise the system time will be synchronized periodically. " \
"The default interval is 15 min. You can change it after installation " \
"with the <b>yast2 ntp-client module</b>.</p>"
)
)

Expand Down Expand Up @@ -122,7 +124,7 @@ def ui_enable_disable_widgets(enabled)
UI.ChangeWidget(Id(:ntp_address), :Enabled, enabled)
UI.ChangeWidget(Id(:run_service), :Enabled, enabled)
if !NetworkService.isNetworkRunning
UI.ChangeWidget(Id(:ntp_now), :Enabled, false)
UI.ChangeWidget(Id(:ntp_now), :Enabled, false)
else
UI.ChangeWidget(Id(:ntp_now), :Enabled, enabled)
end
Expand Down Expand Up @@ -179,13 +181,11 @@ def AddSingleServer(server)
nil
end


def MakeProposal()
def MakeProposal
ntp_items = []

#on the running system, read all the data, otherwise firewall
#and other stuff outside ntp.conf may not be initialized correctly
#(#375877)
# On the running system, read all the data, otherwise firewall and other
# stuff outside ntp.conf may not be initialized correctly (#375877)
if !Stage.initial
progress_orig = Progress.set(false)
NtpClient.Read
Expand Down Expand Up @@ -268,9 +268,7 @@ def ui_init(rp, first_time)
VSpacing(0.3),
# push button label
# bnc#449615: only simple config for inst-sys
Stage.initial ?
Label("") :
Left(PushButton(Id(:ntp_configure), _("&Configure..."))),
Stage.initial ? Label("") : Left(PushButton(Id(:ntp_configure), _("&Configure..."))),
Label("")
)
)
Expand All @@ -279,16 +277,12 @@ def ui_init(rp, first_time)

UI.ReplaceWidget(rp, cont)

if !NetworkService.isNetworkRunning
UI.ChangeWidget(Id(:ntp_now),:Enabled,false);
end
UI.ChangeWidget(Id(:ntp_now), :Enabled, false) if !NetworkService.isNetworkRunning

# ^ createui0

# FIXME is it correct? move out?
ntp_used = first_time && !Stage.initial ?
GetNTPEnabled() :
NtpClient.ntp_selected
# FIXME: is it correct? move out?
ntp_used = first_time && !Stage.initial ? GetNTPEnabled() : NtpClient.ntp_selected

UI.ChangeWidget(Id(:ntp_save), :Value, ntp_used)

Expand Down Expand Up @@ -327,12 +321,13 @@ def WriteNtpSettings(ntp_servers, ntp_server, run_service)
NtpClient.sync_interval = NtpClientClass::DEFAULT_SYNC_INTERVAL
end

#OK, so we stored the server address
#In inst-sys we don't need to care further
#ntp-client_finish will do the job
#In installed system we must write the settings
# OK, so we stored the server address
# In inst-sys we don't need to care further
# ntp-client_finish will do the job
# In installed system we must write the settings
if !Stage.initial
Wizard.OpenAcceptDialog # FIXME so that the progress does not disturb the dialog to be returned to
# FIXME: so that the progress does not disturb the dialog to be returned to
Wizard.OpenAcceptDialog
NtpClient.Write
Wizard.CloseDialog
end
Expand Down Expand Up @@ -367,11 +362,11 @@ def Write(param)

required_package = "ntp"

#In 1st stage, schedule packages for installation
# In 1st stage, schedule packages for installation
if Stage.initial
Yast.import "Packages"
Packages.addAdditionalPackage(required_package)
#Otherwise, prompt user for confirming pkg installation
# Otherwise, prompt user for confirming pkg installation
else
if !PackageSystem.CheckAndInstallPackages([required_package])
Report.Error(
Expand All @@ -387,7 +382,7 @@ def Write(param)

ret = 0
if NetworkService.isNetworkRunning
#Only if network is running try to synchronize the ntp server
# Only if network is running try to synchronize the ntp server
Popup.ShowFeedback("", _("Synchronizing with NTP server..."))

Builtins.y2milestone("Running sntp to sync with %1", ntp_server)
Expand All @@ -399,14 +394,14 @@ def Write(param)
# -l <file>: log to a file to not mess text mode installation
# -c: causes all IP addresses to which ntp_server resolves to be queried in parallel
ret = SCR.Execute(
path(".target.bash"),
"/usr/sbin/sntp -S -K /dev/null -l /var/log/YaST2/sntp.log -t 5 -c '#{String.Quote(ntp_server)}'"
path(".target.bash"),
"/usr/sbin/sntp -S -K /dev/null -l /var/log/YaST2/sntp.log " \
"-t 5 -c '#{String.Quote(ntp_server)}'"
)
Builtins.y2milestone("'sntp %1' returned %2", ntp_server, ret)
Popup.ClearFeedback
end


return :ntpdate_failed if ret != 0

# User wants to more than running sntp (synchronize on boot)
Expand All @@ -430,7 +425,7 @@ def ui_handle(ui)
end
end
if ui == :ntp_now
rv = Write({ "ntpdate_only" => true })
rv = Write("ntpdate_only" => true)
if rv == :invalid_hostname
handle_invalid_hostname(UI.QueryWidget(Id(:ntp_address), :Value))
elsif rv == :success
Expand Down Expand Up @@ -466,22 +461,22 @@ def ui_try_save
# Translators: yes-no popup,
# ntpdate is a command, %1 is the server address
if Popup.YesNo(
Builtins.sformat(
_(
"Test query to server '%1' failed.\n" +
"If server is not yet accessible or network is not configured\n"+
"click 'No' to ignore. Revisit NTP server configuration?"
),
server
)
Builtins.sformat(
_(
"Test query to server '%1' failed.\n" \
"If server is not yet accessible or network is not configured\n" \
"click 'No' to ignore. Revisit NTP server configuration?"
),
server
)
)
return false # loop on
elsif !Ops.get_boolean(argmap, "ntpdate_only", false)
WriteNtpSettings(
[],
server,
Ops.get_boolean(argmap, "run_service", false)
) #may be the server is realy not accessable
) # may be the server is realy not accessable
end
end
# success, exit
Expand Down
4 changes: 2 additions & 2 deletions src/include/ntp-client/clocktypes.rb
Expand Up @@ -8,7 +8,7 @@
# $Id$
module Yast
module NtpClientClocktypesInclude
def initialize_ntp_client_clocktypes(include_target)
def initialize_ntp_client_clocktypes(_include_target)
textdomain "ntp-client"

@clock_types = {
Expand Down Expand Up @@ -282,7 +282,7 @@ def initialize_ntp_client_clocktypes(include_target)
"refid" => "JJY",
"device" => "/dev/jjy%1"
}
}
}

# EOF
end
Expand Down
25 changes: 8 additions & 17 deletions src/include/ntp-client/commandline.rb
Expand Up @@ -10,13 +10,12 @@
# Main file for ntp-client configuration. Uses all other files.
module Yast
module NtpClientCommandlineInclude
def initialize_ntp_client_commandline(include_target)
def initialize_ntp_client_commandline(_include_target)
Yast.import "CommandLine"
Yast.import "NtpClient"

textdomain "ntp-client"


@cmdline = {
"id" => "ntp-client",
# command line help text for NTP client module
Expand Down Expand Up @@ -244,24 +243,19 @@ def updateSyncRecord(options)
# Handler for command line interface
# @param [Hash] options map options from the command line
# @return [Boolean] true if settings have been changed
def NtpStatusHandler(options)
options = deep_copy(options)
def NtpStatusHandler(_options)
CommandLine.Print(
NtpClient.run_service ?
# status information for command line
_("NTP daemon is enabled.") :
# status information for command line
_("NTP daemon is disabled.")
# status information for command line
NtpClient.run_service ? _("NTP daemon is enabled.") : _("NTP daemon is disabled.")
)
false
end

# Handler for command line interface
# @param [Hash] options map options from the command line
# @return [Boolean] true if settings have been changed
def NtpListHandler(options)
options = deep_copy(options)
# FIXME there is some code duplication with the initialization handler of the
def NtpListHandler(_options)
# FIXME: there is some code duplication with the initialization handler of the
# overview widget
types = {
# table cell, NTP relationship type
Expand All @@ -278,7 +272,6 @@ def NtpListHandler(options)
Builtins.foreach(NtpClient.getSyncRecords) do |i|
type = Ops.get_string(i, "type", "")
address = Ops.get_string(i, "address", "")
index = Ops.get_integer(i, "index", -1)
if type == "__clock"
clock_type = getClockType(address)
unit_number = getClockUnitNumber(address)
Expand Down Expand Up @@ -306,8 +299,7 @@ def NtpListHandler(options)
# Handler for command line interface
# @param [Hash] options map options from the command line
# @return [Boolean] true if settings have been changed
def NtpEnableHandler(options)
options = deep_copy(options)
def NtpEnableHandler(_options)
NtpClient.modified = !NtpClient.run_service
NtpClient.run_service = true
true
Expand All @@ -316,8 +308,7 @@ def NtpEnableHandler(options)
# Handler for command line interface
# @param [Hash] options map options from the command line
# @return [Boolean] true if settings have been changed
def NtpDisableHandler(options)
options = deep_copy(options)
def NtpDisableHandler(_options)
NtpClient.modified = NtpClient.run_service
NtpClient.run_service = false
true
Expand Down

0 comments on commit 353aef3

Please sign in to comment.