Advertisement
Guest User

Untitled

a guest
Jul 31st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. require File.dirname(__FILE__) '/../../config/boot'
  4. require "rubygems"
  5. require_gem "activerecord"
  6.  
  7.  
  8. #Ruby standard includes
  9. require 'xmlrpc/server'
  10.  
  11. #custom includes
  12. require "Log/Log.rb"
  13. require "Session/SessionManager.rb"
  14. require "XmlRpc/RpcClasses.rb"
  15. require "Settings.rb"
  16.  
  17.  
  18. # Read database config via YAML
  19. @dbs = YAML::load(ERB.new(IO.read("./database.yml")).result)
  20.  
  21. # If for some reason we wanted to change the connection string (maybe chan
  22. # in mid program we could have a different database under either the test
  23. # historical paramaters and then just set this to @dbs["test"] or @dbs["pr
  24. curr_db = @dbs["production"]
  25.  
  26. # these parameters are YAML file specific, which should make it easy to ch
  27. # changing the source code for the program.
  28. ActiveRecord::Base.establish_connection(
  29. :adapter => curr_db["adapter"],
  30. :database => curr_db["database"], # The current database in the YML file
  31. # If this is changed the database.yml file needs to be
  32. :host => curr_db["host"],
  33. :username => curr_db["username"],
  34. :password => curr_db["password"]
  35. )
  36.  
  37.  
  38. begin
  39. resultset = ValidDataTable.find(:all)
  40. $log << "result is: \n"
  41. $log << " is of type " << resultset.inspect << "\n"
  42. $log.flush
  43. $log << "Analysis: \n"
  44. resultset.each { |result|
  45. $log << "\t" << result.class << "\n"
  46. }
  47. rescue => stuff
  48. $log << "We got an exception..."
  49. $log << stuff
  50. end
  51.  
  52. begin
  53. resultset = ValidDataTable.find(:all)
  54. $log << "result is: "
  55. $log << resultset
  56. rescue => stuff
  57. $log << "We got an exception..."
  58. $log << stuff
  59. end
  60.  
  61.  
  62.  
  63. #DBConnect()
  64. appServer = XMLRPC::Server.new(Settings::ListenPort, Settings::ListenIP)
  65. include XmlRpc
  66. registerClasses(appServer)
  67. appServer.serve
  68.  
  69.  
  70. ------------------------------output--------------------------
  71.  
  72. result is:
  73. is of type We got an exception...
  74. can't convert String into Integer
  75. result is: #<ValidDataTable:0xb75ee20c>#<ValidDataTable:0xb75ee1d0>
  76.  
  77.  
  78. -----------------------------stacktrace-----------------------
  79. It won't give me one. The app server stuff does wierd stuff with output.
  80.  
  81. --------------------------default exception handling output-----------
  82. ./appServer.rb:40:in `<<': can't convert String into Integer (TypeError)
  83. from ./appServer.rb:40
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement