Class: TDRunner::TDRunnerCommandTool
- Inherits:
-
Object
- Object
- TDRunner::TDRunnerCommandTool
- Defined in:
- lib/tdrunner_command_tool.rb
Overview
TDRunner monitor module for controlling the SIERRA execution
Instance Method Summary collapse
-
#initialize(args) ⇒ TDRunnerCommandTool
constructor
A new instance of TDRunnerCommandTool.
Constructor Details
#initialize(args) ⇒ TDRunnerCommandTool
Returns a new instance of TDRunnerCommandTool.
25 26 27 28 29 30 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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/tdrunner_command_tool.rb', line 25 def initialize(args) @sut_arg = "" @httpd_port = 0 while not args.empty? case arg=args.shift when 'httpd' then @httpd_port = args.shift.to_i when 'sut' then @sut_arg = args.shift when 'usb' then raise "Argument error: sut must be given before 'usb' command" if @sut_arg.empty? case arg2=args.shift when 'powerup' uperror = "" begin sut = TDriver.sut(:Id => @sut_arg) sut.power_up rescue uperror = " ERROR (#{$!.to_s.gsub(/\s+/, ' ')})" end puts "USB: Power up"+uperror when 'powerdown' downerror = "" begin sut = TDriver.sut(:Id => @sut_arg) sut.power_down rescue downerror = " ERROR (#{$!.to_s.gsub(/\s+/, ' ')})" end puts "USB: Power down"+downerror when arg+' '+'reset' sut = TDriver.sut(:Id => @sut_arg) sut.reset else raise "Argument error: Unrecognized 'usb' subcommand '#{arg2}'" end # end of main command 'usb' when 'status' if not @sut_arg.empty? sut = TDriver.sut(:Id => @sut_arg) puts "Selected SUT: #{@sut_arg}" STDOUT.sync sutstatus='' begin sut.refresh sutstatus="OK" rescue sutstatus = "ERROR (#{$!.to_s.gsub(/\s+/, ' ')})" end puts "SUT connection: #{sutstatus}" else puts "Selected SUT: N/A" puts "SUT connection: N/A" end # note: in tdrunner_gui, '?' also has the special meaning of not updating existing value in status display # if line below is changed, tdrunner_gui code needs to be changed accordingly puts "USB: ?" STDOUT.sync sutlist='' #paramfilename = '/etc/tdriver/tdriver_params.xml' begin #paramfile = File.new(paramfilename) #sutlist = paramfile.readlines.join.scan(/<sut +id *= *"([^"]+)"/).map{|i| i[0]}.join(' ') sutlist = TDriver.suts.reject { |item| item.to_s == 'sut_generic' }.join(' ') rescue #sutlist = "Failed to read '#{paramfilename}': #{$!.to_s.gsub(/\s+/, ' ')}" sutlist = "ERROR (#{$!.to_s.gsub(/\s+/, ' ')})" end puts "Available SUTs: #{sutlist}" # end of main command 'status' if @httpd_port > 0 httpd_str = "N/A" if require('net/http') uri = URI.parse("http://localhost:#{@httpd_port}/") begin response = Net::HTTP.get_response(uri) httpd_str = "ALIVE (#{uri})" rescue httpd_str = "FAILED (#{uri})" end else httpd_str = "ERROR (required ruby gem status: net/http:#{req1} uri:#{req2})" end puts "HTTPD: #{httpd_str}" end #httpd status else raise "Argument error: Unrecognized command '#{arg}'" end end end |