diff options
| author | Ian Taylor <ian@lorf.org> | 2009-06-05 12:38:35 -0400 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-06-06 09:11:28 +1000 |
| commit | 41ce18cc8ea239d1633fc6cd9e9f599957a82e74 (patch) | |
| tree | 9d398b4e3e6d726a174b5b57094c7dd6749ccf0e /lib/puppet/util | |
| parent | f3b40923605420f774dac298fb1708de180c0a81 (diff) | |
| download | puppet-41ce18cc8ea239d1633fc6cd9e9f599957a82e74.tar.gz puppet-41ce18cc8ea239d1633fc6cd9e9f599957a82e74.tar.xz puppet-41ce18cc8ea239d1633fc6cd9e9f599957a82e74.zip | |
Changed tabs to spaces without interfering with indentation or alignment
Diffstat (limited to 'lib/puppet/util')
| -rw-r--r-- | lib/puppet/util/log.rb | 30 | ||||
| -rw-r--r-- | lib/puppet/util/pidlock.rb | 118 |
2 files changed, 74 insertions, 74 deletions
diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index db6177be2..8f8d46097 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -253,21 +253,21 @@ class Puppet::Util::Log newdesttype :console do - RED = {:console => "[0;31m", :html => "FFA0A0"} - GREEN = {:console => "[0;32m", :html => "00CD00"} - YELLOW = {:console => "[0;33m", :html => "FFFF60"} - BLUE = {:console => "[0;34m", :html => "80A0FF"} - PURPLE = {:console => "[0;35m", :html => "FFA500"} - CYAN = {:console => "[0;36m", :html => "40FFFF"} - WHITE = {:console => "[0;37m", :html => "FFFFFF"} - HRED = {:console => "[1;31m", :html => "FFA0A0"} - HGREEN = {:console => "[1;32m", :html => "00CD00"} - HYELLOW = {:console => "[1;33m", :html => "FFFF60"} - HBLUE = {:console => "[1;34m", :html => "80A0FF"} - HPURPLE = {:console => "[1;35m", :html => "FFA500"} - HCYAN = {:console => "[1;36m", :html => "40FFFF"} - HWHITE = {:console => "[1;37m", :html => "FFFFFF"} - RESET = {:console => "[0m", :html => ""} + RED = {:console => "[0;31m", :html => "FFA0A0"} + GREEN = {:console => "[0;32m", :html => "00CD00"} + YELLOW = {:console => "[0;33m", :html => "FFFF60"} + BLUE = {:console => "[0;34m", :html => "80A0FF"} + PURPLE = {:console => "[0;35m", :html => "FFA500"} + CYAN = {:console => "[0;36m", :html => "40FFFF"} + WHITE = {:console => "[0;37m", :html => "FFFFFF"} + HRED = {:console => "[1;31m", :html => "FFA0A0"} + HGREEN = {:console => "[1;32m", :html => "00CD00"} + HYELLOW = {:console => "[1;33m", :html => "FFFF60"} + HBLUE = {:console => "[1;34m", :html => "80A0FF"} + HPURPLE = {:console => "[1;35m", :html => "FFA500"} + HCYAN = {:console => "[1;36m", :html => "40FFFF"} + HWHITE = {:console => "[1;37m", :html => "FFFFFF"} + RESET = {:console => "[0m", :html => "" } @@colormap = { :debug => WHITE, diff --git a/lib/puppet/util/pidlock.rb b/lib/puppet/util/pidlock.rb index fae8134a5..d24b8378e 100644 --- a/lib/puppet/util/pidlock.rb +++ b/lib/puppet/util/pidlock.rb @@ -1,68 +1,68 @@ require 'fileutils' class Puppet::Util::Pidlock - attr_reader :lockfile - - def initialize(lockfile) - @lockfile = lockfile - end - - def locked? - clear_if_stale - File.exists? @lockfile - end - - def mine? - Process.pid == lock_pid - end + attr_reader :lockfile - def anonymous? - return false unless File.exists?(@lockfile) - File.read(@lockfile) == "" - end - - def lock(opts = {}) - opts = {:anonymous => false}.merge(opts) + def initialize(lockfile) + @lockfile = lockfile + end - if locked? - mine? - else - if opts[:anonymous] - File.open(@lockfile, 'w') { |fd| true } - else - File.open(@lockfile, "w") { |fd| fd.write(Process.pid) } - end - true - end - end - - def unlock(opts = {}) - opts = {:anonymous => false}.merge(opts) + def locked? + clear_if_stale + File.exists? @lockfile + end - if mine? or (opts[:anonymous] and anonymous?) - File.unlink(@lockfile) - true - else - false - end - end + def mine? + Process.pid == lock_pid + end - private - def lock_pid - if File.exists? @lockfile - File.read(@lockfile).to_i - else - nil - end - end + def anonymous? + return false unless File.exists?(@lockfile) + File.read(@lockfile) == "" + end - def clear_if_stale - return if lock_pid.nil? - - begin - Process.kill(0, lock_pid) - rescue Errno::ESRCH - File.unlink(@lockfile) - end - end + def lock(opts = {}) + opts = {:anonymous => false}.merge(opts) + + if locked? + mine? + else + if opts[:anonymous] + File.open(@lockfile, 'w') { |fd| true } + else + File.open(@lockfile, "w") { |fd| fd.write(Process.pid) } + end + true + end + end + + def unlock(opts = {}) + opts = {:anonymous => false}.merge(opts) + + if mine? or (opts[:anonymous] and anonymous?) + File.unlink(@lockfile) + true + else + false + end + end + + private + def lock_pid + if File.exists? @lockfile + File.read(@lockfile).to_i + else + nil + end + end + + def clear_if_stale + return if lock_pid.nil? + + begin + Process.kill(0, lock_pid) + rescue Errno::ESRCH + File.unlink(@lockfile) + end + end end |
