[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
Markus Roberts
Markus at reality.com
Wed Jul 14 10:37:19 UTC 2010
The following commit has been merged in the upstream branch:
commit 07b15bf6fa2a2183f73fcb9b6740c7df75c8b47b
Author: Markus Roberts <Markus at reality.com>
Date: Fri Jul 9 18:06:37 2010 -0700
Code smell: Avoid unneeded blocks
Replaced 45 occurances of
(DEF)
begin
(LINES)
rescue(.*)
(LINES)
end
end
with
3 Examples:
The code:
def find(name)
begin
self.const_get(name.to_s.capitalize)
rescue
puts "Unable to find application '#{name.to_s}'."
Kernel::exit(1)
end
end
becomes:
def find(name)
self.const_get(name.to_s.capitalize)
rescue
puts "Unable to find application '#{name.to_s}'."
Kernel::exit(1)
end
The code:
def exit_on_fail(message, code = 1)
begin
yield
rescue RuntimeError, NotImplementedError => detail
puts detail.backtrace if Puppet[:trace]
$stderr.puts "Could not #{message}: #{detail}"
exit(code)
end
end
becomes:
def exit_on_fail(message, code = 1)
yield
rescue RuntimeError, NotImplementedError => detail
puts detail.backtrace if Puppet[:trace]
$stderr.puts "Could not #{message}: #{detail}"
exit(code)
end
The code:
def start
begin
case ssl
when :tls
@connection = LDAP::SSLConn.new(host, port, true)
when true
@connection = LDAP::SSLConn.new(host, port)
else
@connection = LDAP::Conn.new(host, port)
end
@connection.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
@connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
@connection.simple_bind(user, password)
rescue => detail
raise Puppet::Error, "Could not connect to LDAP: #{detail}"
end
end
becomes:
def start
case ssl
when :tls
@connection = LDAP::SSLConn.new(host, port, true)
when true
@connection = LDAP::SSLConn.new(host, port)
else
@connection = LDAP::Conn.new(host, port)
end
@connection.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
@connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
@connection.simple_bind(user, password)
rescue => detail
raise Puppet::Error, "Could not connect to LDAP: #{detail}"
end
diff --git a/install.rb b/install.rb
index a4abcb9..293a4c4 100755
--- a/install.rb
+++ b/install.rb
@@ -371,7 +371,6 @@ rescue SystemCallError
end
def run_tests(test_list)
- begin
require 'test/unit/ui/console/testrunner'
$LOAD_PATH.unshift "lib"
test_list.each do |test|
@@ -386,9 +385,8 @@ def run_tests(test_list)
tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
$LOAD_PATH.shift
- rescue LoadError
+rescue LoadError
puts "Missing testrunner library; skipping tests"
- end
end
##
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index 1a9939b..a32650a 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -212,12 +212,10 @@ class Application
end
def find(name)
- begin
self.const_get(name.to_s.capitalize)
- rescue
+ rescue
puts "Unable to find application '#{name.to_s}'."
Kernel::exit(1)
- end
end
def [](name)
@@ -397,13 +395,11 @@ class Application
private
def exit_on_fail(message, code = 1)
- begin
yield
- rescue RuntimeError, NotImplementedError => detail
+ rescue RuntimeError, NotImplementedError => detail
puts detail.backtrace if Puppet[:trace]
$stderr.puts "Could not #{message}: #{detail}"
exit(code)
- end
end
end
end
diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb
index 634602c..82158e0 100644
--- a/lib/puppet/configurer.rb
+++ b/lib/puppet/configurer.rb
@@ -50,10 +50,9 @@ class Puppet::Configurer
# Initialize and load storage
def dostorage
- begin
Puppet::Util::Storage.load
@compile_time ||= Puppet::Util::Storage.cache(:configuration)[:compile_time]
- rescue => detail
+ rescue => detail
puts detail.backtrace if Puppet[:trace]
Puppet.err "Corrupt state file #{Puppet[:statefile]}: #{detail}"
begin
@@ -62,7 +61,6 @@ class Puppet::Configurer
rescue => detail
raise Puppet::Error.new("Cannot remove #{Puppet[:statefile]}: #{detail}")
end
- end
end
# Just so we can specify that we are "the" instance.
diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb
index c17b83f..0871c4a 100644
--- a/lib/puppet/file_serving/base.rb
+++ b/lib/puppet/file_serving/base.rb
@@ -13,12 +13,10 @@ class Puppet::FileServing::Base
# Does our file exist?
def exist?
- begin
stat
return true
- rescue => detail
+ rescue => detail
return false
- end
end
# Return the full path to our file. Fails if there's no path set.
diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb
index f458ba4..a30b755 100644
--- a/lib/puppet/indirector/node/exec.rb
+++ b/lib/puppet/indirector/node/exec.rb
@@ -41,10 +41,8 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec
# Translate the yaml string into Ruby objects.
def translate(name, output)
- begin
YAML.load(output).inject({}) { |hash, data| hash[symbolize(data[0])] = data[1]; hash }
- rescue => detail
+ rescue => detail
raise Puppet::Error, "Could not load external node results for #{name}: #{detail}"
- end
end
end
diff --git a/lib/puppet/indirector/queue.rb b/lib/puppet/indirector/queue.rb
index 0e9ff96..b831cd6 100644
--- a/lib/puppet/indirector/queue.rb
+++ b/lib/puppet/indirector/queue.rb
@@ -34,15 +34,13 @@ class Puppet::Indirector::Queue < Puppet::Indirector::Terminus
# Place the request on the queue
def save(request)
- begin
result = nil
benchmark :info, "Queued #{indirection.name} for #{request.key}" do
result = client.send_message(queue, request.instance.render(:pson))
end
result
- rescue => detail
+ rescue => detail
raise Puppet::Error, "Could not write #{request.key} to queue: #{detail}\nInstance::#{request.instance}\n client : #{client}"
- end
end
def self.queue
diff --git a/lib/puppet/network/format_handler.rb b/lib/puppet/network/format_handler.rb
index 70e33a0..b5817d5 100644
--- a/lib/puppet/network/format_handler.rb
+++ b/lib/puppet/network/format_handler.rb
@@ -9,14 +9,12 @@ module Puppet::Network::FormatHandler
attr_reader :format
def protect(method, args)
- begin
Puppet::Network::FormatHandler.format(format).send(method, *args)
- rescue => details
+ rescue => details
direction = method.to_s.include?("intern") ? "from" : "to"
error = FormatError.new("Could not #{method} #{direction} #{format}: #{details}")
error.set_backtrace(details.backtrace)
raise error
- end
end
def initialize(format)
diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb
index e192757..2bf30e7 100644
--- a/lib/puppet/network/xmlrpc/client.rb
+++ b/lib/puppet/network/xmlrpc/client.rb
@@ -196,11 +196,9 @@ module Puppet::Network
end
def start
- begin
@http.start unless @http.started?
- rescue => detail
+ rescue => detail
Puppet.err "Could not connect to server: #{detail}"
- end
end
def local
diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb
index 47be431..81d88d0 100644
--- a/lib/puppet/node.rb
+++ b/lib/puppet/node.rb
@@ -56,15 +56,13 @@ class Puppet::Node
# Merge the node facts with parameters from the node source.
def fact_merge
- begin
if facts = Puppet::Node::Facts.find(name)
merge(facts.values)
end
- rescue => detail
+ rescue => detail
error = Puppet::Error.new("Could not retrieve facts for #{name}: #{detail}")
error.set_backtrace(detail.backtrace)
raise error
- end
end
# Merge any random parameters into our parameter list.
diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb
index ec700fb..0ded4c5 100644
--- a/lib/puppet/property.rb
+++ b/lib/puppet/property.rb
@@ -69,11 +69,9 @@ class Puppet::Property < Puppet::Parameter
# Call the provider method.
def call_provider(value)
- begin
provider.send(self.class.name.to_s + "=", value)
- rescue NoMethodError
+ rescue NoMethodError
self.fail "The #{provider.class.name} provider can not handle attribute #{self.class.name}"
- end
end
# Call the dynamically-created method associated with our value, if
diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb
index 592eb43..75337f2 100644
--- a/lib/puppet/provider/naginator.rb
+++ b/lib/puppet/provider/naginator.rb
@@ -24,11 +24,9 @@ class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile
end
def self.parse(text)
- begin
Nagios::Parser.new.parse(text.gsub(NAME_STRING, "_naginator_name"))
- rescue => detail
+ rescue => detail
raise Puppet::Error, "Could not parse configuration for #{resource_type.name}: #{detail}"
- end
end
def self.to_file(records)
diff --git a/lib/puppet/provider/package/hpux.rb b/lib/puppet/provider/package/hpux.rb
index f3283de..4d53946 100644
--- a/lib/puppet/provider/package/hpux.rb
+++ b/lib/puppet/provider/package/hpux.rb
@@ -27,12 +27,10 @@ Puppet::Type.type(:package).provide :hpux, :parent => Puppet::Provider::Package
end
def query
- begin
swlist resource[:name]
{:ensure => :present}
- rescue
+ rescue
{:ensure => :absent}
- end
end
def uninstall
diff --git a/lib/puppet/provider/package/openbsd.rb b/lib/puppet/provider/package/openbsd.rb
index cff599b..4a19a88 100755
--- a/lib/puppet/provider/package/openbsd.rb
+++ b/lib/puppet/provider/package/openbsd.rb
@@ -76,7 +76,6 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
end
def get_version
- begin
execpipe([command(:pkginfo), " -I ", @resource[:name]]) do |process|
# our regex for matching pkg_info output
regex = /^(.*)-(\d[^-]*)[-]?(\D*)(.*)$/
@@ -96,9 +95,8 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
return master_version unless master_version == 0
raise Puppet::Error, "#{version} is not available for this package"
end
- rescue Puppet::ExecutionFailure
+ rescue Puppet::ExecutionFailure
return nil
- end
end
def query
diff --git a/lib/puppet/provider/selmodule/semodule.rb b/lib/puppet/provider/selmodule/semodule.rb
index 0b72618..d6bf09a 100644
--- a/lib/puppet/provider/selmodule/semodule.rb
+++ b/lib/puppet/provider/selmodule/semodule.rb
@@ -13,11 +13,9 @@ Puppet::Type.type(:selmodule).provide(:semodule) do
end
def destroy
- begin
execoutput("#{command(:semodule)} --remove #{@resource[:name]}")
- rescue Puppet::ExecutionFailure => detail
+ rescue Puppet::ExecutionFailure => detail
raise Puppet::Error, "Could not remove policy module: #{detail}";
- end
end
def exists?
@@ -47,11 +45,9 @@ Puppet::Type.type(:selmodule).provide(:semodule) do
end
def syncversion= (dosync)
- begin
execoutput("#{command(:semodule)} --upgrade #{selmod_name_to_filename}")
- rescue Puppet::ExecutionFailure => detail
+ rescue Puppet::ExecutionFailure => detail
raise Puppet::Error, "Could not upgrade policy module: #{detail}";
- end
end
# Helper functions
diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb
index f5f2607..934e96a 100644
--- a/lib/puppet/provider/service/daemontools.rb
+++ b/lib/puppet/provider/service/daemontools.rb
@@ -125,16 +125,14 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
end
def setupservice
- begin
if resource[:manifest]
Puppet.notice "Configuring #{resource[:name]}"
command = [ resource[:manifest], resource[:name] ]
#texecute("setupservice", command)
rv = system("#{command}")
end
- rescue Puppet::ExecutionFailure => detail
+ rescue Puppet::ExecutionFailure => detail
raise Puppet::Error.new( "Cannot config #{self.service} to enable it: #{detail}" )
- end
end
def enabled?
@@ -149,7 +147,6 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
end
def enable
- begin
if ! FileTest.directory?(self.daemon)
Puppet.notice "No daemon dir, calling setupservice for #{resource[:name]}"
self.setupservice
@@ -160,9 +157,8 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
File.symlink(self.daemon, self.service)
end
end
- rescue Puppet::ExecutionFailure => detail
+ rescue Puppet::ExecutionFailure => detail
raise Puppet::Error.new( "No daemon directory found for #{self.service}")
- end
end
def disable
diff --git a/lib/puppet/provider/service/gentoo.rb b/lib/puppet/provider/service/gentoo.rb
index a3d4777..109524b 100644
--- a/lib/puppet/provider/service/gentoo.rb
+++ b/lib/puppet/provider/service/gentoo.rb
@@ -18,11 +18,9 @@ Puppet::Type.type(:service).provide :gentoo, :parent => :init do
end
def disable
- begin
output = update :del, @resource[:name], :default
- rescue Puppet::ExecutionFailure
+ rescue Puppet::ExecutionFailure
raise Puppet::Error, "Could not disable #{self.name}: #{output}"
- end
end
def enabled?
@@ -45,11 +43,9 @@ Puppet::Type.type(:service).provide :gentoo, :parent => :init do
end
def enable
- begin
output = update :add, @resource[:name], :default
- rescue Puppet::ExecutionFailure
+ rescue Puppet::ExecutionFailure
raise Puppet::Error, "Could not enable #{self.name}: #{output}"
- end
end
end
diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb
index b31faa5..3a25db3 100755
--- a/lib/puppet/provider/service/redhat.rb
+++ b/lib/puppet/provider/service/redhat.rb
@@ -22,11 +22,9 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init
# Remove the symlinks
def disable
- begin
output = chkconfig(@resource[:name], :off)
- rescue Puppet::ExecutionFailure
+ rescue Puppet::ExecutionFailure
raise Puppet::Error, "Could not disable #{self.name}: #{output}"
- end
end
def enabled?
@@ -48,11 +46,9 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init
# Don't support them specifying runlevels; always use the runlevels
# in the init scripts.
def enable
- begin
output = chkconfig(@resource[:name], :on)
- rescue Puppet::ExecutionFailure => detail
+ rescue Puppet::ExecutionFailure => detail
raise Puppet::Error, "Could not enable #{self.name}: #{detail}"
- end
end
def initscript
diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb
index 0407c84..ca7af94 100755
--- a/lib/puppet/provider/service/smf.rb
+++ b/lib/puppet/provider/service/smf.rb
@@ -19,7 +19,6 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
commands :svccfg => "/usr/sbin/svccfg"
def setupservice
- begin
if resource[:manifest]
[command(:svcs), "-l", @resource[:name]]
if $CHILD_STATUS.exitstatus == 1
@@ -27,9 +26,8 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
svccfg :import, resource[:manifest]
end
end
- rescue Puppet::ExecutionFailure => detail
+ rescue Puppet::ExecutionFailure => detail
raise Puppet::Error.new( "Cannot config #{self.service} to enable it: #{detail}" )
- end
end
def enable
diff --git a/lib/puppet/provider/service/src.rb b/lib/puppet/provider/service/src.rb
index 135edcb..aed88d5 100755
--- a/lib/puppet/provider/service/src.rb
+++ b/lib/puppet/provider/service/src.rb
@@ -31,7 +31,6 @@ Puppet::Type.type(:service).provide :src, :parent => :base do
end
def restart
- begin
execute([command(:lssrc), "-Ss", @resource[:name]]).each do |line|
args = line.split(":")
@@ -59,13 +58,11 @@ Puppet::Type.type(:service).provide :src, :parent => :base do
end
end
self.fail("No such service found")
- rescue Puppet::ExecutionFailure => detail
+ rescue Puppet::ExecutionFailure => detail
raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}" )
- end
end
def status
- begin
execute([command(:lssrc), "-s", @resource[:name]]).each do |line|
args = line.split
@@ -82,9 +79,8 @@ Puppet::Type.type(:service).provide :src, :parent => :base do
return state
end
self.fail("No such service found")
- rescue Puppet::ExecutionFailure => detail
+ rescue Puppet::ExecutionFailure => detail
raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}" )
- end
end
end
diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb
index a39f59c..a9738e7 100644
--- a/lib/puppet/provider/ssh_authorized_key/parsed.rb
+++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb
@@ -43,11 +43,9 @@ require 'puppet/provider/parsedfile'
end
def target
- begin
@resource.should(:target) || File.expand_path("~#{@resource.should(:user)}/.ssh/authorized_keys")
- rescue
+ rescue
raise Puppet::Error, "Target not defined and/or specified user does not exist yet"
- end
end
def user
diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb
index 880a18b..7c7c9e3 100644
--- a/lib/puppet/provider/user/user_role_add.rb
+++ b/lib/puppet/provider/user/user_role_add.rb
@@ -62,11 +62,9 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source =>
end
def run(cmd, msg)
- begin
execute(cmd)
- rescue Puppet::ExecutionFailure => detail
+ rescue Puppet::ExecutionFailure => detail
raise Puppet::Error, "Could not #{msg} #{@resource.class.name} #{@resource.name}: #{detail}"
- end
end
def transition(type)
diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb
index 90c9f54..b2cdd2a 100644
--- a/lib/puppet/provider/zone/solaris.rb
+++ b/lib/puppet/provider/zone/solaris.rb
@@ -238,11 +238,9 @@ Puppet::Type.type(:zone).provide(:solaris) do
end
def zoneadm(*cmd)
- begin
adm("-z", @resource[:name], *cmd)
- rescue Puppet::ExecutionFailure => detail
+ rescue Puppet::ExecutionFailure => detail
self.fail "Could not #{cmd[0]} zone: #{detail}"
- end
end
def zonecfg(*cmd)
diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb
index 365aa07..3e69900 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -478,13 +478,11 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
# Store the classes in the classfile.
def write_class_file
- begin
::File.open(Puppet[:classfile], "w") do |f|
f.puts classes.join("\n")
end
- rescue => detail
+ rescue => detail
Puppet.err "Could not create class file #{Puppet[:classfile]}: #{detail}"
- end
end
# Produce the graph files if requested.
diff --git a/lib/puppet/type/macauthorization.rb b/lib/puppet/type/macauthorization.rb
index ff87d3a..5fe64fa 100644
--- a/lib/puppet/type/macauthorization.rb
+++ b/lib/puppet/type/macauthorization.rb
@@ -22,11 +22,9 @@ Puppet::Type.newtype(:macauthorization) do
end
def munge_integer(value)
- begin
Integer(value)
- rescue ArgumentError
+ rescue ArgumentError
fail("munge_integer only takes integers")
- end
end
newparam(:name) do
diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb
index 2960998..fc7109c 100644
--- a/lib/puppet/type/resources.rb
+++ b/lib/puppet/type/resources.rb
@@ -78,12 +78,10 @@ Puppet::Type.newtype(:resources) do
end
def able_to_ensure_absent?(resource)
- begin
resource[:ensure] = :absent
- rescue ArgumentError, Puppet::Error => detail
+ rescue ArgumentError, Puppet::Error => detail
err "The 'ensure' attribute on #{self[:name]} resources does not accept 'absent' as a value"
false
- end
end
# Generate any new resources we need to manage. This is pretty hackish
diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb
index e853efc..a60706b 100644
--- a/lib/puppet/type/zone.rb
+++ b/lib/puppet/type/zone.rb
@@ -387,11 +387,9 @@ Puppet::Type.newtype(:zone) do
end
def validate_ip(ip, name)
- begin
IPAddr.new(ip) if ip
- rescue ArgumentError
+ rescue ArgumentError
self.fail "'#{ip}' is an invalid #{name}"
- end
end
validate do
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index a123d97..a950aa5 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -216,12 +216,10 @@ module Util
end
def execfail(command, exception)
- begin
output = execute(command)
return output
- rescue ExecutionFailure
+ rescue ExecutionFailure
raise exception, output
- end
end
# Execute the desired command, and return the status and output.
diff --git a/lib/puppet/util/autoload/file_cache.rb b/lib/puppet/util/autoload/file_cache.rb
index 7303c9a..ce30eed 100644
--- a/lib/puppet/util/autoload/file_cache.rb
+++ b/lib/puppet/util/autoload/file_cache.rb
@@ -83,12 +83,10 @@ module Puppet::Util::Autoload::FileCache
end
def protect(path)
- begin
yield
- rescue => detail
+ rescue => detail
raise unless detail.class.to_s.include?("Errno")
missing_file(path)
return false
- end
end
end
diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb
index 4d7da67..712895f 100755
--- a/lib/puppet/util/filetype.rb
+++ b/lib/puppet/util/filetype.rb
@@ -205,23 +205,19 @@ class Puppet::Util::FileType
newfiletype(:suntab) do
# Read a specific @path's cron tab.
def read
- begin
output = Puppet::Util.execute(%w{crontab -l}, :uid => @path)
return "" if output.include?("can't open your crontab")
raise Puppet::Error, "User #{@path} not authorized to use cron" if output.include?("you are not authorized to use cron")
return output
- rescue => detail
+ rescue => detail
raise Puppet::Error, "Could not read crontab for #{@path}: #{detail}"
- end
end
# Remove a specific @path's cron tab.
def remove
- begin
Puppet::Util.execute(%w{crontab -r}, :uid => @path)
- rescue => detail
+ rescue => detail
raise Puppet::Error, "Could not remove crontab for #{@path}: #{detail}"
- end
end
# Overwrite a specific @path's cron tab; must be passed the @path name
@@ -250,22 +246,18 @@ class Puppet::Util::FileType
newfiletype(:aixtab) do
# Read a specific @path's cron tab.
def read
- begin
output = Puppet::Util.execute(%w{crontab -l}, :uid => @path)
raise Puppet::Error, "User #{@path} not authorized to use cron" if output.include?("You are not authorized to use the cron command")
return output
- rescue => detail
+ rescue => detail
raise Puppet::Error, "Could not read crontab for #{@path}: #{detail}"
- end
end
# Remove a specific @path's cron tab.
def remove
- begin
Puppet::Util.execute(%w{crontab -r}, :uid => @path)
- rescue => detail
+ rescue => detail
raise Puppet::Error, "Could not remove crontab for #{@path}: #{detail}"
- end
end
# Overwrite a specific @path's cron tab; must be passed the @path name
diff --git a/lib/puppet/util/ldap/connection.rb b/lib/puppet/util/ldap/connection.rb
index 4f71069..624bc6f 100644
--- a/lib/puppet/util/ldap/connection.rb
+++ b/lib/puppet/util/ldap/connection.rb
@@ -60,7 +60,6 @@ class Puppet::Util::Ldap::Connection
# Start our ldap connection.
def start
- begin
case ssl
when :tls
@connection = LDAP::SSLConn.new(host, port, true)
@@ -72,8 +71,7 @@ class Puppet::Util::Ldap::Connection
@connection.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
@connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
@connection.simple_bind(user, password)
- rescue => detail
+ rescue => detail
raise Puppet::Error, "Could not connect to LDAP: #{detail}"
- end
end
end
diff --git a/lib/puppet/util/rdoc.rb b/lib/puppet/util/rdoc.rb
index 8207653..ef208ca 100644
--- a/lib/puppet/util/rdoc.rb
+++ b/lib/puppet/util/rdoc.rb
@@ -6,7 +6,6 @@ module Puppet::Util::RDoc
# launch a rdoc documenation process
# with the files/dir passed in +files+
def rdoc(outputdir, files, charset = nil)
- begin
Puppet[:ignoreimport] = true
# then rdoc
@@ -34,9 +33,8 @@ module Puppet::Util::RDoc
# launch the documentation process
r.document(options)
- rescue RDoc::RDocError => e
+ rescue RDoc::RDocError => e
raise Puppet::ParseError.new("RDoc error #{e}")
- end
end
# launch a output to console manifest doc
diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb
index 9d41a71..614c8cc 100644
--- a/lib/puppet/util/rdoc/generators/puppet_generator.rb
+++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb
@@ -52,13 +52,11 @@ module Generators
# loads our own html template file
def load_html_template
- begin
require 'puppet/util/rdoc/generators/template/puppet/puppet'
extend RDoc::Page
- rescue LoadError
+ rescue LoadError
$stderr.puts "Could not find Puppet template '#{template}'"
exit 99
- end
end
def gen_method_index
@@ -171,15 +169,13 @@ module Generators
# generate all the subdirectories, modules, classes and files
def gen_sub_directories
- begin
super
File.makedirs(MODULE_DIR)
File.makedirs(NODE_DIR)
File.makedirs(PLUGIN_DIR)
- rescue
+ rescue
$stderr.puts $ERROR_INFO.message
exit 1
- end
end
# generate the index of modules
diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb
index 48120f3..ceba65a 100755
--- a/test/ral/providers/group.rb
+++ b/test/ral/providers/group.rb
@@ -71,12 +71,10 @@ class TestGroupProvider < Test::Unit::TestCase
end
else
def missing?(group)
- begin
obj = Etc.getgrnam(group)
return false
- rescue ArgumentError
+ rescue ArgumentError
return true
- end
end
def gid(name)
diff --git a/test/ral/providers/user.rb b/test/ral/providers/user.rb
index 0336328..7769e3a 100755
--- a/test/ral/providers/user.rb
+++ b/test/ral/providers/user.rb
@@ -65,12 +65,10 @@ class TestUserProvider < Test::Unit::TestCase
end
else
def missing?(user)
- begin
obj = Etc.getpwnam(user)
return false
- rescue ArgumentError
+ rescue ArgumentError
return true
- end
end
def current?(param, user)
diff --git a/test/ral/type/filesources.rb b/test/ral/type/filesources.rb
index d3eb537..2b43424 100755
--- a/test/ral/type/filesources.rb
+++ b/test/ral/type/filesources.rb
@@ -30,11 +30,9 @@ class TestFileSources < Test::Unit::TestCase
end
def use_storage
- begin
initstorage
- rescue
+ rescue
system("rm -rf #{Puppet[:statefile]}")
- end
end
def initstorage
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list