Thursday, February 4, 2010

Death Agony!!!

Sometime I use many PC for automation integration testing.
But it is difficult to manage which one down by error.
So when some PC down,the PC death agony! by skype.
This code will death agony and vomit log.

# death_agony.rb
#! ruby -Ku
require 'rubygems'
require 'win32ole'
require 'kconv'

$KCODE = 'UTF8'
@MACHINE = ARGV[0]
@GOD = ARGV[1]

@oCom=WIN32OLE.new('AutoItX3.Control')
@oSkype=WIN32OLE.new('Skype4COM.skype')
raise "Please start skype" @oSkype.Client.IsRunning != true

death_agnoy = IO.read('errIO.txt')
@oSkype.SendMessage(@GOD, "Death Agony from #{@MACHINE} at #{Time.now}\n" + death_agony)
sleep(3)

@oUser = @oSkype.User(@GOD)
@oCall = @oSkype.PlaceCall(@oUser.Handle)
@oCall.Status

And catch exception in rake task(who don't use rake for testing?)

# rake.rb
# setup >(rake your_task pc=a_one_of_sacrifice p=where_to_agony) 1> errIO.txt
task :hell_grinder do
begin
ruby "death_test.rb "
rescue
p "ring ring ring..."
ruby "death_agony.rb " + ENV['pc'] + " " + ENV['p']
end
end

Then you can hear death agony from each sacrifice.
*Don't forget regsvr skype dll:here down load link
How to regist it.
> regsvr32 -that skype dll-
Ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh........

No comments:

Post a Comment