376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
# File 'lib/spiderfw/setup/spider_setup_wizard.rb', line 376
def run
require 'rubygems'
require 'rubygems/command.rb'
require 'rubygems/dependency_installer.rb'
unless Spider.gem_available?('ruby-oci8')
if ask? _("Oracle gem is not available. Install?")
ok = false
while !ok
inst = Gem::DependencyInstaller.new
begin
inst.install 'ruby-oci8'
rescue
error _("Installation of oracle gem failed.")
puts _(
"The oracle gem failed to compile, so the pure-ruby version was installed.
You should install the compiled version manually for better performance.")
end
end
else
error _("Can't configure oracle without the ruby-oci8 gem.")
return
end
end
require 'oci8'
ok = false
while !ok
if (ask _("Do you want to connect via tns or direct connection?"),
:choices => ['tns', 'direct']) == 'tns'
ask! _("Tns:"), :tns, :default => 'ORCL'
ask _("Username"), :user
ask _("Password"), :pass
begin
m = ::OCI8.new(@user, @pass, @tns)
m.ping
m.logoff
connect_ok = true
ok = true
notify_partial("Ok.", true)
rescue => myerr
if myerr.exception.code == 1017
notify_partial("Connection failed.", true)
error _("Username or Password invalid.")
elsif myerr.exception.code == 12154
notify_partial("Connection failed.", true)
error _("Tns seems not responding.")
else
notify_partial("", true)
error _("Connection failed.")
end
ok = ask_error
end
else
ask _("Host:"), :host, :default => 'localhost'
ask _("Port:"), :port, :default => 1521
ask _("Tns:"), :tns, :default => 'ORCL'
ask _("Username"), :user
ask _("Password"), :pass
@db_name = "//#{@host}:#{@port}/#{@tns}"
begin
m = ::OCI8.new(@user, @pass, @db_name)
ok = true
m.logoff
rescue => myerr
if myerr.exception.code == 1017
notify_partial("Connection failed.", true)
error _("Username or Password invalid.")
elsif myerr.exception.code == 12154
notify_partial("Connection failed.", true)
error _("Server seems not responding.")
else
notify_partial("", true)
error _("Connection failed.")
end
ok = ask_error
end
end
end
end
|