Class: Voodoo::Sqr

Inherits:
Object
  • Object
show all
Defined in:
lib/voodoo/peopletools/sqr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSqr

Returns a new instance of Sqr.



8
9
10
11
12
# File 'lib/voodoo/peopletools/sqr.rb', line 8

def initialize
  @sqr_bin = File.join(Voodoo.configuration[:ps_home], %w{bin sqr ORA BINW}).gsub!(File::SEPARATOR, File::ALT_SEPARATOR)
  @executable = File.join(@sqr_bin, %w{sqrw.exe})
  @command_line_options = []
end

Instance Attribute Details

#command_line_optionsObject

Returns the value of attribute command_line_options.



6
7
8
# File 'lib/voodoo/peopletools/sqr.rb', line 6

def command_line_options
  @command_line_options
end

#executableObject

Returns the value of attribute executable.



6
7
8
# File 'lib/voodoo/peopletools/sqr.rb', line 6

def executable
  @executable
end

Instance Method Details

#append(args) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/voodoo/peopletools/sqr.rb', line 31

def append(args)
  args.each_pair do |k, v|
    @command_line_options.push case
      when k == :db_login
        v
      when k == :sqr
        v + '.sqr'
      when k == :input
        '-I' + v + '\\'
      when k == :output
        '-F' + v + '\\'
      when k == :log_file
        '-O' + v
      when k == :zif
        '-ZIF' + v
      when k == :print
        '-PRINTER:PD'
      when k == :xmb
        '-XMB'
      when k == :xcb
        '-XCB'
      when k == :debug
        '-DEBUGX'
    end
  end
end

#call_executableObject



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/voodoo/peopletools/sqr.rb', line 58

def call_executable
  LOG.debug("Executable is set to #{@executable}")
  LOG.debug("Command line options are set to #{@command_line_options.join(" ")}")

  #f = IO.popen(@executable + " " + @command_line_options.join(" "))
  #f.readlines.each { |line| puts ("#{line.chomp}")}
  #f.close
  pid = spawn(@executable + " " + @command_line_options.join(" "))
  LOG.debug("Created background process #{pid} for #{@executable}")
  Process.detach(pid)

  @command_line_options.clear
end

#run(migration, target, sqr_name) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/voodoo/peopletools/sqr.rb', line 14

def run(migration, target, sqr_name)
  @sqr_name = sqr_name.gsub(/\.sqr/, '')
  append(:sqr => File.join(target.ps_home, 'sqr', @sqr_name).gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
  append(:db_login => target.db_username + '/' + target.db_password + '@' + target.name)
  append(:input => File.join(target.ps_home, 'sqr').gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
  append(:output => migration.log_folder)
  append(:log_file => File.join(migration.log_folder, @sqr_name + '_' + Time.now.strftime("%Y_%m_%d_%H_%M_%S") + '.log').gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
  append(:zif => File.join(target.ps_home, 'sqr', 'pssqr.ini').gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
  append(:print => true)
  append(:xmb=> true)
  append(:xcb=> true)
  append(:debug=> true)
  LOG.info("Running #{@sqr_name}...")
  #puts "Running #{@sqr_name}..."
  call_executable
end