diff options
Diffstat (limited to 'lib/puppet/util')
38 files changed, 172 insertions, 172 deletions
diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index f0be0ece2..cdfc194da 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -24,7 +24,7 @@ class Puppet::Util::Autoload # List all loaded files. def self.list_loaded @loaded.sort { |a,b| a[0] <=> b[0] }.collect do |path, hash| - "%s: %s" % [path, hash[:file]] + "#{path}: #{hash[:file]}" end end @@ -62,7 +62,7 @@ class Puppet::Util::Autoload begin self.send(opt.to_s + "=", value) rescue NoMethodError - raise ArgumentError, "%s is not a valid option" % opt + raise ArgumentError, "#{opt} is not a valid option" end end diff --git a/lib/puppet/util/backups.rb b/lib/puppet/util/backups.rb index 4270f528c..e08bf57de 100644 --- a/lib/puppet/util/backups.rb +++ b/lib/puppet/util/backups.rb @@ -49,7 +49,7 @@ module Puppet::Util::Backups rescue => detail # since they said they want a backup, let's error out # if we couldn't make one - self.fail "Could not back %s up: %s" % [file, detail.message] + self.fail "Could not back #{file} up: #{detail.message}" end end @@ -67,22 +67,22 @@ module Puppet::Util::Backups end if stat.ftype == "directory" - raise Puppet::Error, "Will not remove directory backup %s; use a filebucket" % newfile + raise Puppet::Error, "Will not remove directory backup #{newfile}; use a filebucket" end - info "Removing old backup of type %s" % stat.ftype + info "Removing old backup of type #{stat.ftype}" begin File.unlink(newfile) rescue => detail puts detail.backtrace if Puppet[:trace] - self.fail "Could not remove old backup: %s" % detail + self.fail "Could not remove old backup: #{detail}" end end def backup_file_with_filebucket(f) sum = self.bucket.backup(f) - self.info "Filebucketed %s to %s with sum %s" % [f, self.bucket.name, sum] + self.info "Filebucketed #{f} to #{self.bucket.name} with sum #{sum}" return sum end end diff --git a/lib/puppet/util/cacher.rb b/lib/puppet/util/cacher.rb index 28786ab53..3a75dc88d 100644 --- a/lib/puppet/util/cacher.rb +++ b/lib/puppet/util/cacher.rb @@ -39,7 +39,7 @@ module Puppet::Util::Cacher # Provide a means of defining an attribute whose value will be cached. # Must provide a block capable of defining the value if it's flushed.. def cached_attr(name, options = {}, &block) - init_method = "init_" + name.to_s + init_method = "init_#{name}" define_method(init_method, &block) define_method(name) do @@ -103,7 +103,7 @@ module Puppet::Util::Cacher value_cache.delete(name) end unless value_cache.include?(name) - value_cache[name] = send("init_%s" % name) + value_cache[name] = send("init_#{name}") end value_cache[name] end diff --git a/lib/puppet/util/classgen.rb b/lib/puppet/util/classgen.rb index 83c302c01..d9022bbdc 100644 --- a/lib/puppet/util/classgen.rb +++ b/lib/puppet/util/classgen.rb @@ -134,11 +134,11 @@ module Puppet::Util::ClassGen if const_defined?(const) if options[:overwrite] - Puppet.info "Redefining %s in %s" % [name, self] + Puppet.info "Redefining #{name} in #{self}" remove_const(const) else raise Puppet::ConstantAlreadyDefined, - "Class %s is already defined in %s" % [const, self] + "Class #{const} is already defined in #{self}" end end const_set(const, klass) @@ -185,7 +185,7 @@ module Puppet::Util::ClassGen if hash = options[:hash] if hash.include? klassname and ! options[:overwrite] raise Puppet::SubclassAlreadyDefined, - "Already a generated class named %s" % klassname + "Already a generated class named #{klassname}" end hash[klassname] = klass @@ -197,7 +197,7 @@ module Puppet::Util::ClassGen array.find { |c| c.name == klassname } and ! options[:overwrite]) raise Puppet::SubclassAlreadyDefined, - "Already a generated class named %s" % klassname + "Already a generated class named #{klassname}" end array << klass diff --git a/lib/puppet/util/constant_inflector.rb b/lib/puppet/util/constant_inflector.rb index 29d334348..20ad384d9 100644 --- a/lib/puppet/util/constant_inflector.rb +++ b/lib/puppet/util/constant_inflector.rb @@ -10,6 +10,6 @@ module Puppet::Util::ConstantInflector end def constant2file(constant) - constant.to_s.gsub(/([a-z])([A-Z])/) { |term| $1 + "_" + $2 }.gsub("::", "/").downcase + constant.to_s.gsub(/([a-z])([A-Z])/) { |term| $1 + "_#{$2}" }.gsub("::", "/").downcase end end diff --git a/lib/puppet/util/docs.rb b/lib/puppet/util/docs.rb index 02374d8b7..d73550d9f 100644 --- a/lib/puppet/util/docs.rb +++ b/lib/puppet/util/docs.rb @@ -9,7 +9,7 @@ module Puppet::Util::Docs # rather than just sticking them in a hash, because otherwise they're # too difficult to do inheritance with. def dochook(name, &block) - method = "dochook_" + name.to_s + method = "dochook_#{name}" meta_def method, &block end diff --git a/lib/puppet/util/errors.rb b/lib/puppet/util/errors.rb index a44c1ca18..d78064227 100644 --- a/lib/puppet/util/errors.rb +++ b/lib/puppet/util/errors.rb @@ -38,7 +38,7 @@ module Puppet::Util::Errors rescue Puppet::Error => detail raise adderrorcontext(detail) rescue => detail - message = options[:message] || "%s failed with error %s: %s" % [self.class, detail.class, detail.to_s] + message = options[:message] || "#{self.class} failed with error #{detail.class}: #{detail}" error = options[:type].new(message) # We can't use self.fail here because it always expects strings, diff --git a/lib/puppet/util/feature.rb b/lib/puppet/util/feature.rb index d5866927a..40ecfe447 100644 --- a/lib/puppet/util/feature.rb +++ b/lib/puppet/util/feature.rb @@ -14,14 +14,14 @@ class Puppet::Util::Feature def add(name, options = {}) method = name.to_s + "?" if self.class.respond_to?(method) - raise ArgumentError, "Feature %s is already defined" % name + raise ArgumentError, "Feature #{name} is already defined" end if block_given? begin result = yield rescue Exception => detail - warn "Failed to load feature test for %s: %s" % [name, detail] + warn "Failed to load feature test for #{name}: #{detail}" result = false end @results[name] = result @@ -78,7 +78,7 @@ class Puppet::Util::Feature def load_library(lib, name) unless lib.is_a?(String) - raise ArgumentError, "Libraries must be passed as strings not %s" % lib.class + raise ArgumentError, "Libraries must be passed as strings not #{lib.class}" end begin @@ -86,7 +86,7 @@ class Puppet::Util::Feature rescue SystemExit,NoMemoryError raise rescue Exception - Puppet.debug "Failed to load library '%s' for feature '%s'" % [lib, name] + Puppet.debug "Failed to load library '#{lib}' for feature '#{name}'" return false end return true diff --git a/lib/puppet/util/file_locking.rb b/lib/puppet/util/file_locking.rb index f1f02be1c..ab43e2353 100644 --- a/lib/puppet/util/file_locking.rb +++ b/lib/puppet/util/file_locking.rb @@ -5,7 +5,7 @@ module Puppet::Util::FileLocking # Create a shared lock for reading def readlock(file) - raise ArgumentError, "%s is not a file" % file unless !File.exists?(file) or File.file?(file) + raise ArgumentError, "#{file} is not a file" unless !File.exists?(file) or File.file?(file) Puppet::Util.sync(file).synchronize(Sync::SH) do File.open(file) { |f| f.lock_shared { |lf| yield lf } @@ -17,9 +17,9 @@ module Puppet::Util::FileLocking # tmp file. def writelock(file, mode = nil) unless FileTest.directory?(File.dirname(file)) - raise Puppet::DevError, "Cannot create %s; directory %s does not exist" % [file, File.dirname(file)] + raise Puppet::DevError, "Cannot create #{file}; directory #{File.dirname(file)} does not exist" end - raise ArgumentError, "%s is not a file" % file unless !File.exists?(file) or File.file?(file) + raise ArgumentError, "#{file} is not a file" unless !File.exists?(file) or File.file?(file) tmpfile = file + ".tmp" unless mode diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb index 7965532fd..974d908b8 100644 --- a/lib/puppet/util/fileparsing.rb +++ b/lib/puppet/util/fileparsing.rb @@ -44,7 +44,7 @@ module Puppet::Util::FileParsing @fields = fields.collect do |field| r = symbolize(field) if INVALID_FIELDS.include?(r) - raise ArgumentError.new("Cannot have fields named %s" % r) + raise ArgumentError.new("Cannot have fields named #{r}") end r end @@ -53,7 +53,7 @@ module Puppet::Util::FileParsing def initialize(type, options = {}, &block) @type = symbolize(type) unless [:record, :text].include?(@type) - raise ArgumentError, "Invalid record type %s" % @type + raise ArgumentError, "Invalid record type #{@type}" end set_options(options) @@ -92,7 +92,7 @@ module Puppet::Util::FileParsing if self.optional.include?(field) self.absent else - raise ArgumentError, "Field '%s' is required" % field + raise ArgumentError, "Field '#{field}' is required" end else details[field].to_s @@ -157,7 +157,7 @@ module Puppet::Util::FileParsing if ret = record.send(:process, line.dup) unless ret.is_a?(Hash) raise Puppet::DevError, - "Process record type %s returned non-hash" % record.name + "Process record type #{record.name} returned non-hash" end else return nil @@ -235,7 +235,7 @@ module Puppet::Util::FileParsing if val = parse_line(line) val else - error = Puppet::Error.new("Could not parse line %s" % line.inspect) + error = Puppet::Error.new("Could not parse line #{line.inspect}") error.line = count raise error end @@ -250,7 +250,7 @@ module Puppet::Util::FileParsing @record_order.each do |record| # These are basically either text or record lines. - method = "handle_%s_line" % record.type + method = "handle_#{record.type}_line" if respond_to?(method) if result = send(method, line, record) if record.respond_to?(:post_parse) @@ -260,7 +260,7 @@ module Puppet::Util::FileParsing end else raise Puppet::DevError, - "Somehow got invalid line type %s" % record.type + "Somehow got invalid line type #{record.type}" end end @@ -323,7 +323,7 @@ module Puppet::Util::FileParsing # Convert our parsed record into a text record. def to_line(details) unless record = record_type(details[:record_type]) - raise ArgumentError, "Invalid record type %s" % details[:record_type].inspect + raise ArgumentError, "Invalid record type #{details[:record_type].inspect}" end if record.respond_to?(:pre_gen) @@ -382,7 +382,7 @@ module Puppet::Util::FileParsing @record_order ||= [] if @record_types.include?(record.name) - raise ArgumentError, "Line type %s is already defined" % record.name + raise ArgumentError, "Line type #{record.name} is already defined" end @record_types[record.name] = record diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb index c2291a3ab..3df4fdee0 100755 --- a/lib/puppet/util/filetype.rb +++ b/lib/puppet/util/filetype.rb @@ -47,7 +47,7 @@ class Puppet::Util::FileType if Puppet[:trace] puts detail.backtrace end - raise Puppet::Error, "%s could not read %s: %s" % [self.class, @path, detail] + raise Puppet::Error, "#{self.class} could not read #{@path}: #{detail}" end end @@ -64,7 +64,7 @@ class Puppet::Util::FileType if Puppet[:debug] puts detail.backtrace end - raise Puppet::Error, "%s could not write %s: %s" % [self.class, @path, detail] + raise Puppet::Error, "#{self.class} could not write #{@path}: #{detail}" end end end @@ -137,19 +137,19 @@ class Puppet::Util::FileType # Read the file. def read - Puppet.info "Reading %s from RAM" % @path + Puppet.info "Reading #{@path} from RAM" @@tabs[@path] end # Remove the file. def remove - Puppet.info "Removing %s from RAM" % @path + Puppet.info "Removing #{@path} from RAM" @@tabs[@path] = "" end # Overwrite the file. def write(text) - Puppet.info "Writing %s to RAM" % @path + Puppet.info "Writing #{@path} to RAM" @@tabs[@path] = text end end @@ -164,7 +164,7 @@ class Puppet::Util::FileType begin @uid = Puppet::Util.uid(user) rescue Puppet::Error => detail - raise Puppet::Error, "Could not retrieve user %s" % user + raise Puppet::Error, "Could not retrieve user #{user}" end # XXX We have to have the user name, not the uid, because some @@ -216,10 +216,10 @@ class Puppet::Util::FileType begin output = Puppet::Util.execute(%w{crontab -l}, :uid => @path) return "" if output.include?("can't open your crontab") - raise Puppet::Error, "User %s not authorized to use cron" % @path if output.include?("you are not authorized to use cron") + raise Puppet::Error, "User #{@path} not authorized to use cron" if output.include?("you are not authorized to use cron") return output rescue => detail - raise Puppet::Error, "Could not read crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not read crontab for #{@path}: #{detail}" end end @@ -228,7 +228,7 @@ class Puppet::Util::FileType begin Puppet::Util.execute(%w{crontab -r}, :uid => @path) rescue => detail - raise Puppet::Error, "Could not remove crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not remove crontab for #{@path}: #{detail}" end end @@ -248,7 +248,7 @@ class Puppet::Util::FileType begin Puppet::Util.execute(["crontab", output_file.path], :uid => @path) rescue => detail - raise Puppet::Error, "Could not write crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not write crontab for #{@path}: #{detail}" end output_file.delete end @@ -261,11 +261,11 @@ class Puppet::Util::FileType begin output = Puppet::Util.execute(%w{crontab -l}, :uid => @path) if output.include?("You are not authorized to use the cron command") - raise Puppet::Error, "User %s not authorized to use cron" % @path + raise Puppet::Error, "User #{@path} not authorized to use cron" end return output rescue => detail - raise Puppet::Error, "Could not read crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not read crontab for #{@path}: #{detail}" end end @@ -274,7 +274,7 @@ class Puppet::Util::FileType begin Puppet::Util.execute(%w{crontab -r}, :uid => @path) rescue => detail - raise Puppet::Error, "Could not remove crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not remove crontab for #{@path}: #{detail}" end end @@ -293,7 +293,7 @@ class Puppet::Util::FileType begin Puppet::Util.execute(["crontab", output_file.path], :uid => @path) rescue => detail - raise Puppet::Error, "Could not write crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not write crontab for #{@path}: #{detail}" ensure output_file.delete end diff --git a/lib/puppet/util/inifile.rb b/lib/puppet/util/inifile.rb index 0a957d447..38bc1c574 100644 --- a/lib/puppet/util/inifile.rb +++ b/lib/puppet/util/inifile.rb @@ -122,7 +122,7 @@ module Puppet::Util::IniConfig end elsif " \t\r\n\f".include?(l[0,1]) && section && optname # continuation line - section[optname] += "\n" + l.chomp + section[optname] += "\n#{l.chomp}" elsif l =~ /^\[([^\]]+)\]/ # section heading section.mark_clean unless section.nil? diff --git a/lib/puppet/util/instance_loader.rb b/lib/puppet/util/instance_loader.rb index bf4f9b77f..56d75b698 100755 --- a/lib/puppet/util/instance_loader.rb +++ b/lib/puppet/util/instance_loader.rb @@ -42,7 +42,7 @@ module Puppet::Util::InstanceLoader # Use this method so they all get loaded loaded_instances(type).sort { |a,b| a.to_s <=> b.to_s }.each do |name| mod = self.loaded_instance(name) - docs += "%s\n%s\n" % [name, "-" * name.to_s.length] + docs += "#{name}\n#{"-" * name.to_s.length}\n" docs += Puppet::Util::Docs.scrub(mod.doc) + "\n\n" end @@ -68,7 +68,7 @@ module Puppet::Util::InstanceLoader if instance_loader(type).load(name) unless instances.include? name Puppet.warning( - "Loaded %s file for %s but %s was not defined" % [type, name, type] + "Loaded #{type} file for #{name} but #{type} was not defined" ) return nil end diff --git a/lib/puppet/util/ldap/connection.rb b/lib/puppet/util/ldap/connection.rb index 18d9bf5ab..4f71069ef 100644 --- a/lib/puppet/util/ldap/connection.rb +++ b/lib/puppet/util/ldap/connection.rb @@ -43,7 +43,7 @@ class Puppet::Util::Ldap::Connection begin send(param.to_s + "=", value) rescue - raise ArgumentError, "LDAP connections do not support %s parameters" % param + raise ArgumentError, "LDAP connections do not support #{param} parameters" end end end @@ -73,7 +73,7 @@ class Puppet::Util::Ldap::Connection @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: %s" % detail + raise Puppet::Error, "Could not connect to LDAP: #{detail}" end end end diff --git a/lib/puppet/util/ldap/manager.rb b/lib/puppet/util/ldap/manager.rb index 8d444195e..cfa7cb3f7 100644 --- a/lib/puppet/util/ldap/manager.rb +++ b/lib/puppet/util/ldap/manager.rb @@ -80,7 +80,7 @@ class Puppet::Util::Ldap::Manager # Calculate the dn for a given resource. def dn(name) - ["%s=%s" % [rdn, name], base].join(",") + ["#{rdn}=#{name}", base].join(",") end # Convert an ldap-style entry hash to a provider-style hash. @@ -103,7 +103,7 @@ class Puppet::Util::Ldap::Manager # Create our normal search filter. def filter - return "objectclass=%s" % objectclasses[0] if objectclasses.length == 1 + return "objectclass=#{objectclasses[0]}" if objectclasses.length == 1 return "(&(objectclass=" + objectclasses.join(")(objectclass=") + "))" end @@ -139,7 +139,7 @@ class Puppet::Util::Ldap::Manager if generator.source unless value = values[generator.source] - raise ArgumentError, "%s must be defined to generate %s" % [generator.source, generator.name] + raise ArgumentError, "#{generator.source} must be defined to generate #{generator.name}" end result = generator.generate(value) else @@ -216,14 +216,14 @@ class Puppet::Util::Ldap::Manager # Update the ldap entry with the desired state. def update(name, is, should) if should[:ensure] == :absent - Puppet.info "Removing %s from ldap" % dn(name) + Puppet.info "Removing #{dn(name)} from ldap" delete(name) return end # We're creating a new entry if is.empty? or is[:ensure] == :absent - Puppet.info "Creating %s in ldap" % dn(name) + Puppet.info "Creating #{dn(name)} in ldap" # Remove any :absent params and :ensure, then convert the names to ldap names. attrs = ldap_convert(should) create(name, attrs) diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index 57be5f5ba..ac1992526 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -79,7 +79,7 @@ class Puppet::Util::Log raise Puppet::DevError, "Logs require a level" end unless @levels.index(hash[:level]) - raise Puppet::DevError, "Invalid log level %s" % hash[:level] + raise Puppet::DevError, "Invalid log level #{hash[:level]}" end if @levels.index(hash[:level]) >= @loglevel return Puppet::Util::Log.new(hash) @@ -109,7 +109,7 @@ class Puppet::Util::Log end unless @levels.include?(level) - raise Puppet::DevError, "Invalid loglevel %s" % level + raise Puppet::DevError, "Invalid loglevel #{level}" end @loglevel = @levels.index(level) @@ -131,7 +131,7 @@ class Puppet::Util::Log end unless type - raise Puppet::DevError, "Unknown destination type %s" % dest + raise Puppet::DevError, "Unknown destination type #{dest}" end begin @@ -246,7 +246,7 @@ class Puppet::Util::Log def level=(level) raise ArgumentError, "Puppet::Util::Log requires a log level" unless level @level = level.to_sym - raise ArgumentError, "Invalid log level %s" % @level unless self.class.validlevel?(@level) + raise ArgumentError, "Invalid log level #{@level}" unless self.class.validlevel?(@level) # Tag myself with my log level tag(level) diff --git a/lib/puppet/util/log/destinations.rb b/lib/puppet/util/log/destinations.rb index 9fe61d484..37e6d1ae9 100644 --- a/lib/puppet/util/log/destinations.rb +++ b/lib/puppet/util/log/destinations.rb @@ -17,7 +17,7 @@ Puppet::Util::Log.newdesttype :syslog do begin facility = Syslog.const_get("LOG_#{str.upcase}") rescue NameError - raise Puppet::Error, "Invalid syslog facility %s" % str + raise Puppet::Error, "Invalid syslog facility #{str}" end @syslog = Syslog.open(name, options, facility) @@ -61,7 +61,7 @@ Puppet::Util::Log.newdesttype :file do # specified a "special" destination. unless FileTest.exist?(File.dirname(path)) Puppet.recmkdir(File.dirname(path)) - Puppet.info "Creating log directory %s" % File.dirname(path) + Puppet.info "Creating log directory #{File.dirname(path)}" end # create the log file, if it doesn't already exist @@ -73,7 +73,7 @@ Puppet::Util::Log.newdesttype :file do end def handle(msg) - @file.puts("%s %s (%s): %s" % [msg.time, msg.source, msg.level, msg.to_s]) + @file.puts("#{msg.time} #{msg.source} (#{msg.level}): #{msg}") @file.flush if @autoflush end @@ -133,16 +133,16 @@ Puppet::Util::Log.newdesttype :console do def handle(msg) if msg.source == "Puppet" - puts colorize(msg.level, "%s: %s" % [msg.level, msg.to_s]) + puts colorize(msg.level, "#{msg.level}: #{msg}") else - puts colorize(msg.level, "%s: %s: %s" % [msg.level, msg.source, msg.to_s]) + puts colorize(msg.level, "#{msg.level}: #{msg.source}: #{msg}") end end end Puppet::Util::Log.newdesttype :host do def initialize(host) - Puppet.info "Treating %s as a hostname" % host + Puppet.info "Treating #{host} as a hostname" args = {} if host =~ /:(\d+)/ args[:Port] = $1 @@ -164,24 +164,24 @@ Puppet::Util::Log.newdesttype :host do unless defined?(@domain) @domain = Facter["domain"].value if @domain - @hostname += "." + @domain + @hostname += ".#{@domain}" end end if msg.source =~ /^\// - msg.source = @hostname + ":" + msg.source + msg.source = @hostname + ":#{msg.source}" elsif msg.source == "Puppet" - msg.source = @hostname + " " + msg.source + msg.source = @hostname + " #{msg.source}" else - msg.source = @hostname + " " + msg.source + msg.source = @hostname + " #{msg.source}" end begin - #puts "would have sent %s" % msg + #puts "would have sent #{msg}" #puts "would have sent %s" % # CGI.escape(YAML.dump(msg)) begin tmp = CGI.escape(YAML.dump(msg)) rescue => detail - puts "Could not dump: %s" % detail.to_s + puts "Could not dump: #{detail}" return end # Add the hostname to the source diff --git a/lib/puppet/util/methodhelper.rb b/lib/puppet/util/methodhelper.rb index ecc9d537f..771d0e648 100644 --- a/lib/puppet/util/methodhelper.rb +++ b/lib/puppet/util/methodhelper.rb @@ -3,7 +3,7 @@ module Puppet::Util::MethodHelper def requiredopts(*names) names.each do |name| if self.send(name).nil? - devfail("%s is a required option for %s" % [name, self.class]) + devfail("#{name} is a required option for #{self.class}") end end end diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb index cf8ed9ee1..e8de54cf2 100644 --- a/lib/puppet/util/metric.rb +++ b/lib/puppet/util/metric.rb @@ -37,14 +37,14 @@ class Puppet::Util::Metric values.each { |value| # the 7200 is the heartbeat -- this means that any data that isn't # more frequently than every two hours gets thrown away - args.push "DS:%s:GAUGE:7200:U:U" % [value[0]] + args.push "DS:#{value[0]}:GAUGE:7200:U:U" } args.push "RRA:AVERAGE:0.5:1:300" begin @rrd.create( Puppet[:rrdinterval].to_i, start, args) rescue => detail - raise "Could not create RRD file %s: %s" % [path,detail] + raise "Could not create RRD file #{path}: #{detail}" end end @@ -62,7 +62,7 @@ class Puppet::Util::Metric colorstack = %w{#00ff00 #ff0000 #0000ff #ffff00 #ff99ff #ff9966 #66ffff #990000 #099000 #000990 #f00990 #0f0f0f #555555 #333333 #ffffff} {:daily => unit, :weekly => unit * 7, :monthly => unit * 30, :yearly => unit * 365}.each do |name, time| - file = self.path.sub(/\.rrd$/, "-%s.png" % name) + file = self.path.sub(/\.rrd$/, "-#{name}.png") args = [file] args.push("--title",self.label) @@ -75,8 +75,8 @@ class Puppet::Util::Metric values.zip(colorstack).each { |value,color| next if value.nil? # this actually uses the data label - defs.push("DEF:%s=%s:%s:AVERAGE" % [value[0],self.path,value[0]]) - lines.push("LINE2:%s%s:%s" % [value[0],color,value[1]]) + defs.push("DEF:#{value[0]}=#{self.path}:#{value[0]}:AVERAGE") + lines.push("LINE2:#{value[0]}#{color}:#{value[1]}") } args << defs args << lines @@ -91,7 +91,7 @@ class Puppet::Util::Metric #Puppet.warning "args = #{args}" RRDtool.graph( args ) rescue => detail - Puppet.err "Failed to graph %s: %s" % [self.name,detail] + Puppet.err "Failed to graph #{self.name}: #{detail}" end end end @@ -136,9 +136,9 @@ class Puppet::Util::Metric template = temps.join(":") begin @rrd.update( template, [ arg ] ) - #system("rrdtool updatev %s '%s'" % [self.path, arg]) + #system("rrdtool updatev #{self.path} '#{arg}'") rescue => detail - raise Puppet::Error, "Failed to update %s: %s" % [self.name,detail] + raise Puppet::Error, "Failed to update #{self.name}: #{detail}" end end diff --git a/lib/puppet/util/nagios_maker.rb b/lib/puppet/util/nagios_maker.rb index 339d2d1a2..e824b1de2 100644 --- a/lib/puppet/util/nagios_maker.rb +++ b/lib/puppet/util/nagios_maker.rb @@ -7,16 +7,16 @@ module Puppet::Util::NagiosMaker # from the parser. def self.create_nagios_type(name) name = name.to_sym - full_name = ("nagios_" + name.to_s).to_sym + full_name = ("nagios_#{name}").to_sym - raise(Puppet::DevError, "No nagios type for %s" % name) unless nagtype = Nagios::Base.type(name) + raise(Puppet::DevError, "No nagios type for #{name}") unless nagtype = Nagios::Base.type(name) type = Puppet::Type.newtype(full_name) {} type.ensurable type.newparam(nagtype.namevar, :namevar => true) do - desc "The name parameter for Nagios type %s" % nagtype.name + desc "The name parameter for Nagios type #{nagtype.name}" end # We deduplicate the parameters because it makes sense to allow Naginator to have dupes. diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb index 837c37a07..c71a846d9 100755 --- a/lib/puppet/util/posix.rb +++ b/lib/puppet/util/posix.rb @@ -11,7 +11,7 @@ module Puppet::Util::POSIX if id.is_a?(Integer) if id > Puppet[:maximum_uid].to_i - Puppet.err "Tried to get %s field for silly id %s" % [field, id] + Puppet.err "Tried to get #{field} field for silly id #{id}" return nil end method = methodbyid(space) @@ -36,7 +36,7 @@ module Puppet::Util::POSIX if id.is_a?(Integer) integer = true if id > Puppet[:maximum_uid].to_i - Puppet.err "Tried to get %s field for silly id %s" % [field, id] + Puppet.err "Tried to get #{field} field for silly id #{id}" return nil end end diff --git a/lib/puppet/util/provider_features.rb b/lib/puppet/util/provider_features.rb index 86f30cc8b..d106d473c 100644 --- a/lib/puppet/util/provider_features.rb +++ b/lib/puppet/util/provider_features.rb @@ -55,13 +55,13 @@ module Puppet::Util::ProviderFeatures # required to determine if the feature is present. def feature(name, docs, hash = {}) @features ||= {} - raise(Puppet::DevError, "Feature %s is already defined" % name) if @features.include?(name) + raise(Puppet::DevError, "Feature #{name} is already defined") if @features.include?(name) begin obj = ProviderFeature.new(name, docs, hash) @features[obj.name] = obj rescue ArgumentError => detail error = ArgumentError.new( - "Could not create feature %s: %s" % [name, detail] + "Could not create feature #{name}: #{detail}" ) error.set_backtrace(detail.backtrace) raise error @@ -76,7 +76,7 @@ module Puppet::Util::ProviderFeatures names = @features.keys.sort { |a,b| a.to_s <=> b.to_s } names.each do |name| doc = @features[name].docs.gsub(/\n\s+/, " ") - str += "- **%s**: %s\n" % [name, doc] + str += "- **#{name}**: #{doc}\n" end if providers.length > 0 diff --git a/lib/puppet/util/queue.rb b/lib/puppet/util/queue.rb index 329b07b22..31425fbae 100644 --- a/lib/puppet/util/queue.rb +++ b/lib/puppet/util/queue.rb @@ -52,7 +52,7 @@ module Puppet::Util::Queue # each registration. def self.register_queue_type(klass, type = nil) type ||= queue_type_from_class(klass) - raise Puppet::Error, "Queue type %s is already registered" % type.to_s if instance_hash(:queue_clients).include?(type) + raise Puppet::Error, "Queue type #{type} is already registered" if instance_hash(:queue_clients).include?(type) instance_hash(:queue_clients)[type] = klass end @@ -60,7 +60,7 @@ module Puppet::Util::Queue # (meaning it hasn't been registered with this module), an exception is thrown. def self.queue_type_to_class(type) c = loaded_instance :queue_clients, type - raise Puppet::Error, "Queue type %s is unknown." % type unless c + raise Puppet::Error, "Queue type #{type} is unknown." unless c c end diff --git a/lib/puppet/util/queue/stomp.rb b/lib/puppet/util/queue/stomp.rb index a87268b72..ffe745ff7 100644 --- a/lib/puppet/util/queue/stomp.rb +++ b/lib/puppet/util/queue/stomp.rb @@ -15,16 +15,16 @@ class Puppet::Util::Queue::Stomp begin uri = URI.parse(Puppet[:queue_source]) rescue => detail - raise ArgumentError, "Could not create Stomp client instance - queue source %s is invalid: %s" % [Puppet[:queue_source], detail] + raise ArgumentError, "Could not create Stomp client instance - queue source #{Puppet[:queue_source]} is invalid: #{detail}" end unless uri.scheme == "stomp" - raise ArgumentError, "Could not create Stomp client instance - queue source %s is not a Stomp URL: %s" % [Puppet[:queue_source], detail] + raise ArgumentError, "Could not create Stomp client instance - queue source #{Puppet[:queue_source]} is not a Stomp URL: #{detail}" end begin self.stomp_client = Stomp::Client.new(uri.user, uri.password, uri.host, uri.port, true) rescue => detail - raise ArgumentError, "Could not create Stomp client instance with queue source %s: got internal Stomp client error %s" % [Puppet[:queue_source], detail] + raise ArgumentError, "Could not create Stomp client instance with queue source #{Puppet[:queue_source]}: got internal Stomp client error #{detail}" end end diff --git a/lib/puppet/util/rdoc.rb b/lib/puppet/util/rdoc.rb index 1bc48abd0..82076534d 100644 --- a/lib/puppet/util/rdoc.rb +++ b/lib/puppet/util/rdoc.rb @@ -35,7 +35,7 @@ module Puppet::Util::RDoc # launch the documentation process r.document(options) rescue RDoc::RDocError => e - raise Puppet::ParseError.new("RDoc error %s" % e) + raise Puppet::ParseError.new("RDoc error #{e}") end end diff --git a/lib/puppet/util/rdoc/code_objects.rb b/lib/puppet/util/rdoc/code_objects.rb index 995869987..9ee26f47d 100644 --- a/lib/puppet/util/rdoc/code_objects.rb +++ b/lib/puppet/util/rdoc/code_objects.rb @@ -169,7 +169,7 @@ module RDoc end def to_s - res = self.class.name + ": " + @name + " (" + @type + ")\n" + res = self.class.name + ": #{@name} (#{@type})\n" res << @comment.to_s res end @@ -200,7 +200,7 @@ module RDoc end def to_s - res = self.class.name + ": " + @name + "\n" + res = self.class.name + ": #{@name}\n" res << @comment.to_s res end @@ -225,7 +225,7 @@ module RDoc end def full_name - @type + "[" + @title + "]" + @type + "[#{@title}]" end def name @@ -233,7 +233,7 @@ module RDoc end def to_s - res = @type + "[" + @title + "]\n" + res = @type + "[#{@title}]\n" res << @comment.to_s res end diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb index c32a401bd..f73b18dce 100644 --- a/lib/puppet/util/rdoc/generators/puppet_generator.rb +++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb @@ -241,7 +241,7 @@ module Generators res2 = [] collection['methods'].sort.each do |f| if f.document_self - res2 << { "href" => "../"+f.path, "name" => f.index_name.sub(/\(.*\)$/,'') } + res2 << { "href" => "../#{f.path}", "name" => f.index_name.sub(/\(.*\)$/,'') } end end @@ -593,7 +593,7 @@ module Generators @values["parent"] = CGI.escapeHTML(parent_class) if parent_name - lookup = parent_name + "::" + parent_class + lookup = parent_name + "::#{parent_class}" else lookup = parent_class end @@ -839,7 +839,7 @@ module Generators def as_href(from_path) if @options.all_one_file - "#" + path + "##{path}" else HTMLGenerator.gen_url(from_path, path) end @@ -877,7 +877,7 @@ module Generators if @options.all_one_file aref else - @html_class.path + "#" + aref + @html_class.path + "##{aref}" end end diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb index 9c86ec360..9d14ae6eb 100644 --- a/lib/puppet/util/rdoc/parser.rb +++ b/lib/puppet/util/rdoc/parser.rb @@ -31,7 +31,7 @@ class Parser # main entry point def scan - Puppet.info "rdoc: scanning %s" % @input_file_name + Puppet.info "rdoc: scanning #{@input_file_name}" if @input_file_name =~ /\.pp$/ @parser = Puppet::Parser::Parser.new(Puppet[:environment]) @parser.file = @input_file_name @@ -81,14 +81,14 @@ class Parser def split_module(path) # find a module fullpath = File.expand_path(path) - Puppet.debug "rdoc: testing %s" % fullpath + Puppet.debug "rdoc: testing #{fullpath}" if fullpath =~ /(.*)\/([^\/]+)\/(?:manifests|plugins|lib)\/.+\.(pp|rb)$/ modpath = $1 name = $2 - Puppet.debug "rdoc: module %s into %s ?" % [name, modpath] + Puppet.debug "rdoc: module #{name} into #{modpath} ?" Puppet::Module.modulepath().each do |mp| if File.identical?(modpath,mp) - Puppet.debug "rdoc: found module %s" % name + Puppet.debug "rdoc: found module #{name}" return name end end @@ -127,7 +127,7 @@ class Parser return end - Puppet.debug "rdoc: scanning for %s" % name + Puppet.debug "rdoc: scanning for #{name}" container.module_name = name container.global=true if name == "<site>" @@ -185,7 +185,7 @@ class Parser scan_for_vardef(container,stmt.children) if stmt.is_a?(Puppet::Parser::AST::ASTArray) if stmt.is_a?(Puppet::Parser::AST::VarDef) - Puppet.debug "rdoc: found constant: %s = %s" % [stmt.name.to_s, stmt.value.to_s] + Puppet.debug "rdoc: found constant: #{stmt.name} = #{stmt.value}" container.add_constant(Constant.new(stmt.name.to_s, stmt.value.to_s, stmt.doc)) end end @@ -202,7 +202,7 @@ class Parser begin type = stmt.type.split("::").collect { |s| s.capitalize }.join("::") title = stmt.title.is_a?(Puppet::Parser::AST::ASTArray) ? stmt.title.to_s.gsub(/\[(.*)\]/,'\1') : stmt.title.to_s - Puppet.debug "rdoc: found resource: %s[%s]" % [type,title] + Puppet.debug "rdoc: found resource: #{type}[#{title}]" param = [] stmt.params.children.each do |p| @@ -233,7 +233,7 @@ class Parser # create documentation for a class named +name+ def document_class(name, klass, container) - Puppet.debug "rdoc: found new class %s" % name + Puppet.debug "rdoc: found new class #{name}" container, name = get_class_or_module(container, name) superclass = klass.parent @@ -265,7 +265,7 @@ class Parser # create documentation for a node def document_node(name, node, container) - Puppet.debug "rdoc: found new node %s" % name + Puppet.debug "rdoc: found new node #{name}" superclass = node.parent superclass = "" if superclass.nil? or superclass.empty? @@ -290,7 +290,7 @@ class Parser # create documentation for a define def document_define(name, define, container) - Puppet.debug "rdoc: found new definition %s" % name + Puppet.debug "rdoc: found new definition #{name}" # find superclas if any @stats.num_methods += 1 @@ -308,7 +308,7 @@ class Parser when Puppet::Parser::AST::Leaf declaration << "'#{value.value}'" when Puppet::Parser::AST::ASTArray - declaration << "[%s]" % value.children.collect { |v| "'#{v}'" }.join(", ") + declaration << "[#{value.children.collect { |v| "'#{v}'" }.join(", ")}]" else declaration << "#{value.to_s}" end @@ -322,7 +322,7 @@ class Parser meth.comment = define.doc container.add_method(meth) look_for_directives_in(container, meth.comment) unless meth.comment.empty? - meth.params = "( " + declaration + " )" + meth.params = "( #{declaration} )" meth.visibility = :public meth.document_self = true meth.singleton = false @@ -386,7 +386,7 @@ class Parser container.add_fact(current_fact) current_fact.record_location(@top_level) comments = "" - Puppet.debug "rdoc: found custom fact %s" % current_fact.name + Puppet.debug "rdoc: found custom fact #{current_fact.name}" elsif line =~ /^[ \t]*confine[ \t]*:(.*?)[ \t]*=>[ \t]*(.*)$/ current_fact.confine = { :type => $1, :value => $2 } unless current_fact.nil? else # unknown line type @@ -414,7 +414,7 @@ class Parser current_plugin.comment = comments current_plugin.record_location(@top_level) comments = "" - Puppet.debug "rdoc: found new function plugins %s" % current_plugin.name + Puppet.debug "rdoc: found new function plugins #{current_plugin.name}" elsif line =~ /^[ \t]*Puppet::Type.newtype[ \t]*\([ \t]*:(.*?)\)/ current_plugin = Plugin.new($1, "type") container.add_plugin(current_plugin) @@ -422,7 +422,7 @@ class Parser current_plugin.comment = comments current_plugin.record_location(@top_level) comments = "" - Puppet.debug "rdoc: found new type plugins %s" % current_plugin.name + Puppet.debug "rdoc: found new type plugins #{current_plugin.name}" elsif line =~ /module Puppet::Parser::Functions/ # skip else # unknown line type diff --git a/lib/puppet/util/reference.rb b/lib/puppet/util/reference.rb index 74d75bb3f..c5bfe4722 100644 --- a/lib/puppet/util/reference.rb +++ b/lib/puppet/util/reference.rb @@ -11,7 +11,7 @@ class Puppet::Util::Reference instance_load(:reference, 'puppet/reference') def self.footer - "\n\n----------------\n\n*This page autogenerated on %s*\n" % Time.now + "\n\n----------------\n\n*This page autogenerated on #{Time.now}*\n" end def self.modes @@ -29,7 +29,7 @@ class Puppet::Util::Reference depth = 4 # Use the minimum depth sections.each do |name| - section = reference(name) or raise "Could not find section %s" % name + section = reference(name) or raise "Could not find section #{name}" depth = section.depth if section.depth < depth end text = ".. contents:: :depth: 2\n\n" @@ -69,9 +69,9 @@ class Puppet::Util::Reference def self.markdown(name, text) puts "Creating markdown for #{name} reference." - dir = "/tmp/" + Puppet::PUPPETVERSION + dir = "/tmp/#{Puppet::PUPPETVERSION}" FileUtils.mkdir(dir) unless File.directory?(dir) - Puppet::Util.secure_open(dir + "/" + "#{name}.rst", "w") do |f| + Puppet::Util.secure_open(dir + "/#{name}.rst", "w") do |f| f.puts text end pandoc = %x{which pandoc} @@ -90,7 +90,7 @@ class Puppet::Util::Reference exit(1) end - File.unlink(dir + "/" + "#{name}.rst") + File.unlink(dir + "/#{name}.rst") end def self.references @@ -105,7 +105,7 @@ class Puppet::Util::Reference def doc if defined?(@doc) - return "%s - %s" % [@name, @doc] + return "#{@name} - #{@doc}" else return @title end @@ -116,7 +116,7 @@ class Puppet::Util::Reference end def h(name, level) - return "%s\n%s\n\n" % [name, HEADER_LEVELS[level] * name.to_s.length] + return "#{name}\n#{HEADER_LEVELS[level] * name.to_s.length}\n\n" end def initialize(name, options = {}, &block) @@ -128,7 +128,7 @@ class Puppet::Util::Reference meta_def(:generate, &block) # Now handle the defaults - @title ||= "%s Reference" % @name.to_s.capitalize + @title ||= "#{@name.to_s.capitalize} Reference" @page ||= @title.gsub(/\s+/, '') @depth ||= 2 @header ||= "" @@ -140,12 +140,12 @@ class Puppet::Util::Reference end def option(name, value) - ":%s: %s\n" % [name.to_s.capitalize, value] + ":#{name.to_s.capitalize}: #{value}\n" end def paramwrap(name, text, options = {}) options[:level] ||= 5 - #str = "%s : " % name + #str = "#{name} : " str = h(name, options[:level]) if options[:namevar] str += "- **namevar**\n\n" @@ -171,7 +171,7 @@ class Puppet::Util::Reference text = h(@title, 1) text += "\n\n**This page is autogenerated; any changes will get overwritten** *(last generated on #{Time.now.to_s})*\n\n" if withcontents - text += ".. contents:: :depth: %s\n\n" % @depth + text += ".. contents:: :depth: #{@depth}\n\n" end text += @header @@ -198,7 +198,7 @@ class Puppet::Util::Reference f.puts self.to_trac end - puts "Writing %s reference to trac as %s" % [@name, @page] + puts "Writing #{@name} reference to trac as #{@page}" cmd = %{sudo trac-admin /opt/rl/trac/puppet wiki import %s /tmp/puppetdoc.txt} % self.page output = %x{#{cmd}} unless $CHILD_STATUS == 0 diff --git a/lib/puppet/util/resource_template.rb b/lib/puppet/util/resource_template.rb index 4e333571f..164d75ae3 100644 --- a/lib/puppet/util/resource_template.rb +++ b/lib/puppet/util/resource_template.rb @@ -44,7 +44,7 @@ class Puppet::Util::ResourceTemplate end def initialize(file, resource) - raise ArgumentError, "Template %s does not exist" % file unless FileTest.exist?(file) + raise ArgumentError, "Template #{file} does not exist" unless FileTest.exist?(file) @file = file @resource = resource end diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb index 28752cfac..fad15d74e 100644 --- a/lib/puppet/util/selinux.rb +++ b/lib/puppet/util/selinux.rb @@ -125,7 +125,7 @@ module Puppet::Util::SELinux if retval == 0 return true else - Puppet.warning "Failed to set SELinux context %s on %s" % [context, file] + Puppet.warning "Failed to set SELinux context #{context} on #{file}" return false end end diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index 3a823d30b..afec53a8a 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -100,7 +100,7 @@ class Puppet::Util::Settings elsif pval = self.value(varname) pval else - raise Puppet::DevError, "Could not find value for %s" % value + raise Puppet::DevError, "Could not find value for #{value}" end end @@ -220,7 +220,7 @@ class Puppet::Util::Settings hash[name] = val end hash.sort { |a,b| a[0].to_s <=> b[0].to_s }.each do |name, val| - puts "%s = %s" % [name, val] + puts "#{name} = #{val}" end else val.split(/\s*,\s*/).sort.each do |v| @@ -230,9 +230,9 @@ class Puppet::Util::Settings puts value(val,env) break end - puts "%s = %s" % [v, value(v,env)] + puts "#{v} = #{value(v,env)}" else - puts "invalid parameter: %s" % v + puts "invalid parameter: #{v}" return false end end @@ -382,7 +382,7 @@ class Puppet::Util::Settings end if type = hash[:type] unless klass = {:setting => Setting, :file => FileSetting, :boolean => BooleanSetting}[type] - raise ArgumentError, "Invalid setting type '%s'" % type + raise ArgumentError, "Invalid setting type '#{type}'" end hash.delete(:type) else @@ -394,7 +394,7 @@ class Puppet::Util::Settings when String, Integer, Float # nothing klass = Setting else - raise ArgumentError, "Invalid value '%s' for %s" % [hash[:default].inspect, hash[:name]] + raise ArgumentError, "Invalid value '#{hash[:default].inspect}' for #{hash[:name]}" end end hash[:settings] = self @@ -427,7 +427,7 @@ class Puppet::Util::Settings # Reparse our config file, if necessary. def reparse if file and file.changed? - Puppet.notice "Reparsing %s" % file.file + Puppet.notice "Reparsing #{file.file}" parse reuse() end @@ -501,7 +501,7 @@ class Puppet::Util::Settings return else raise ArgumentError, - "Attempt to assign a value to unknown configuration parameter %s" % param.inspect + "Attempt to assign a value to unknown configuration parameter #{param.inspect}" end end if setting.respond_to?(:munge) @@ -550,12 +550,12 @@ class Puppet::Util::Settings hash[:name] = name hash[:section] = section if @config.include?(name) - raise ArgumentError, "Parameter %s is already defined" % name + raise ArgumentError, "Parameter #{name} is already defined" end tryconfig = newsetting(hash) if short = tryconfig.short if other = @shortnames[short] - raise ArgumentError, "Parameter %s is already using short name '%s'" % [other.name, short] + raise ArgumentError, "Parameter #{other.name} is already using short name '#{short}'" end @shortnames[short] = tryconfig end @@ -612,7 +612,7 @@ Generated on #{Time.now}. # Add a section heading that matches our name. if @config.include?(:run_mode) - str += "[%s]\n" % self[:run_mode] + str += "[#{self[:run_mode]}]\n" end eachsection do |section| persection(section) do |obj| @@ -644,7 +644,7 @@ if @config.include?(:run_mode) catalog = to_catalog(*sections).to_ral rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not create resources for managing Puppet's files and directories in sections %s: %s" % [sections.inspect, detail] + Puppet.err "Could not create resources for managing Puppet's files and directories in sections #{sections.inspect}: #{detail}" # We need some way to get rid of any resources created during the catalog creation # but not cleaned up. @@ -657,7 +657,7 @@ if @config.include?(:run_mode) if transaction.any_failed? report = transaction.report failures = report.logs.find_all { |log| log.level == :err } - raise "Got %s failure(s) while initializing: %s" % [failures.length, failures.collect { |l| l.to_s }.join("; ")] + raise "Got #{failures.length} failure(s) while initializing: #{failures.collect { |l| l.to_s }.join("; ")}" end end end @@ -769,14 +769,14 @@ if @config.include?(:run_mode) tmpfile = file + ".tmp" sync = Sync.new unless FileTest.directory?(File.dirname(tmpfile)) - raise Puppet::DevError, "Cannot create %s; directory %s does not exist" % [file, File.dirname(file)] + raise Puppet::DevError, "Cannot create #{file}; directory #{File.dirname(file)} does not exist" end sync.synchronize(Sync::EX) do File.open(file, ::File::CREAT|::File::RDWR, 0600) do |rf| rf.lock_exclusive do if File.exist?(tmpfile) - raise Puppet::Error, ".tmp file already exists for %s; Aborting locked write. Check the .tmp file and delete if appropriate" % [file] + raise Puppet::Error, ".tmp file already exists for #{file}; Aborting locked write. Check the .tmp file and delete if appropriate" end # If there's a failure, remove our tmpfile @@ -790,7 +790,7 @@ if @config.include?(:run_mode) begin File.rename(tmpfile, file) rescue => detail - Puppet.err "Could not rename %s to %s: %s" % [file, tmpfile, detail] + Puppet.err "Could not rename #{file} to #{tmpfile}: #{detail}" File.unlink(tmpfile) if FileTest.exist?(tmpfile) end end @@ -803,11 +803,11 @@ if @config.include?(:run_mode) def get_config_file_default(default) obj = nil unless obj = @config[default] - raise ArgumentError, "Unknown default %s" % default + raise ArgumentError, "Unknown default #{default}" end unless obj.is_a? FileSetting - raise ArgumentError, "Default %s is not a file" % default + raise ArgumentError, "Default #{default} is not a file" end return obj @@ -860,14 +860,14 @@ if @config.include?(:run_mode) param, value = $1.intern, $2 result[param] = value unless [:owner, :mode, :group].include?(param) - raise ArgumentError, "Invalid file option '%s'" % param + raise ArgumentError, "Invalid file option '#{param}'" end if param == :mode and value !~ /^\d+$/ raise ArgumentError, "File modes must be numbers" end else - raise ArgumentError, "Could not parse '%s'" % string + raise ArgumentError, "Could not parse '#{string}'" end end '' @@ -937,7 +937,7 @@ if @config.include?(:run_mode) raise end else - error = Puppet::Error.new("Could not match line %s" % line) + error = Puppet::Error.new("Could not match line #{line}") error.file = file error.line = line raise error @@ -952,9 +952,9 @@ if @config.include?(:run_mode) begin return File.read(file) rescue Errno::ENOENT - raise ArgumentError, "No such file %s" % file + raise ArgumentError, "No such file #{file}" rescue Errno::EACCES - raise ArgumentError, "Permission denied to file %s" % file + raise ArgumentError, "Permission denied to file #{file}" end end diff --git a/lib/puppet/util/settings/boolean_setting.rb b/lib/puppet/util/settings/boolean_setting.rb index aa365fd8e..67fce9ae3 100644 --- a/lib/puppet/util/settings/boolean_setting.rb +++ b/lib/puppet/util/settings/boolean_setting.rb @@ -24,7 +24,7 @@ class Puppet::Util::Settings::BooleanSetting < Puppet::Util::Settings::Setting when true, "true"; return true when false, "false"; return false else - raise ArgumentError, "Invalid value '%s' for %s" % [value.inspect, @name] + raise ArgumentError, "Invalid value '#{value.inspect}' for #{@name}" end end end diff --git a/lib/puppet/util/settings/file_setting.rb b/lib/puppet/util/settings/file_setting.rb index 815bdcf52..bbb388bd6 100644 --- a/lib/puppet/util/settings/file_setting.rb +++ b/lib/puppet/util/settings/file_setting.rb @@ -17,7 +17,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting def group=(value) unless AllowedGroups.include?(value) identifying_fields = [desc,name,default].compact.join(': ') - raise SettingError, "Internal error: The :group setting for %s must be 'service', not '%s'" % [identifying_fields,value] + raise SettingError, "Internal error: The :group setting for #{identifying_fields} must be 'service', not '#{value}'" end @group = value end @@ -30,7 +30,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting def owner=(value) unless AllowedOwners.include?(value) identifying_fields = [desc,name,default].compact.join(': ') - raise SettingError, "Internal error: The :owner setting for %s must be either 'root' or 'service', not '%s'" % [identifying_fields,value] + raise SettingError, "Internal error: The :owner setting for #{identifying_fields} must be either 'root' or 'service', not '#{value}'" end @owner = value end @@ -115,7 +115,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting name = $1 unless @settings.include?(name) raise ArgumentError, - "Settings parameter '%s' is undefined" % name + "Settings parameter '#{name}' is undefined" end } end diff --git a/lib/puppet/util/settings/setting.rb b/lib/puppet/util/settings/setting.rb index 489dfd01d..6f8e39209 100644 --- a/lib/puppet/util/settings/setting.rb +++ b/lib/puppet/util/settings/setting.rb @@ -38,14 +38,14 @@ class Puppet::Util::Settings::Setting args.each do |param, value| method = param.to_s + "=" unless self.respond_to? method - raise ArgumentError, "%s does not accept %s" % [self.class, param] + raise ArgumentError, "#{self.class} does not accept #{param}" end self.send(method, value) end unless self.desc - raise ArgumentError, "You must provide a description for the %s config option" % self.name + raise ArgumentError, "You must provide a description for the #{self.name} config option" end end @@ -83,7 +83,7 @@ class Puppet::Util::Settings::Setting # Add in a statement about the default. if defined?(@default) and @default - str += "# The default value is '%s'.\n" % @default + str += "# The default value is '#{@default}'.\n" end # If the value has not been overridden, then print it out commented @@ -92,9 +92,9 @@ class Puppet::Util::Settings::Setting value = @settings.value(self.name) if value != @default - line = "%s = %s" % [@name, value] + line = "#{@name} = #{value}" else - line = "# %s = %s" % [@name, @default] + line = "# #{@name} = #{@default}" end str += line + "\n" diff --git a/lib/puppet/util/storage.rb b/lib/puppet/util/storage.rb index 076952c1d..974d56f56 100644 --- a/lib/puppet/util/storage.rb +++ b/lib/puppet/util/storage.rb @@ -53,7 +53,7 @@ class Puppet::Util::Storage return end unless File.file?(Puppet[:statefile]) - Puppet.warning("Checksumfile %s is not a file, ignoring" % Puppet[:statefile]) + Puppet.warning("Checksumfile #{Puppet[:statefile]} is not a file, ignoring") return end Puppet::Util.benchmark(:debug, "Loaded state") do @@ -61,12 +61,12 @@ class Puppet::Util::Storage begin @@state = YAML.load(file) rescue => detail - Puppet.err "Checksumfile %s is corrupt (%s); replacing" % [Puppet[:statefile], detail] + Puppet.err "Checksumfile #{Puppet[:statefile]} is corrupt (#{detail}); replacing" begin File.rename(Puppet[:statefile], Puppet[:statefile] + ".bad") rescue raise Puppet::Error, - "Could not rename corrupt %s; remove manually" % Puppet[:statefile] + "Could not rename corrupt #{Puppet[:statefile]}; remove manually" end end end @@ -77,7 +77,7 @@ class Puppet::Util::Storage self.init end - #Puppet.debug "Loaded state is %s" % @@state.inspect + #Puppet.debug "Loaded state is #{@@state.inspect}" end def self.stateinspect @@ -88,7 +88,7 @@ class Puppet::Util::Storage Puppet.debug "Storing state" unless FileTest.exist?(Puppet[:statefile]) - Puppet.info "Creating state file %s" % Puppet[:statefile] + Puppet.info "Creating state file #{Puppet[:statefile]}" end Puppet::Util.benchmark(:debug, "Stored state") do diff --git a/lib/puppet/util/suidmanager.rb b/lib/puppet/util/suidmanager.rb index 404f78890..c6b5e3c89 100644 --- a/lib/puppet/util/suidmanager.rb +++ b/lib/puppet/util/suidmanager.rb @@ -71,10 +71,10 @@ module Puppet::Util::SUIDManager # Make sure the passed argument is a number. def convert_xid(type, id) map = {:gid => :group, :uid => :user} - raise ArgumentError, "Invalid id type %s" % type unless map.include?(type) + raise ArgumentError, "Invalid id type #{type}" unless map.include?(type) ret = Puppet::Util.send(type, id) if ret == nil - raise Puppet::Error, "Invalid %s: %s" % [map[type], id] + raise Puppet::Error, "Invalid #{map[type]}: #{id}" end return ret end diff --git a/lib/puppet/util/tagging.rb b/lib/puppet/util/tagging.rb index 9ee90799f..51cff9520 100644 --- a/lib/puppet/util/tagging.rb +++ b/lib/puppet/util/tagging.rb @@ -11,7 +11,7 @@ module Puppet::Util::Tagging qualified = [] ary.collect { |tag| tag.to_s.downcase }.each do |tag| - fail(Puppet::ParseError, "Invalid tag %s" % tag.inspect) unless valid_tag?(tag) + fail(Puppet::ParseError, "Invalid tag #{tag.inspect}") unless valid_tag?(tag) qualified << tag if tag.include?("::") @tags << tag unless @tags.include?(tag) end |