def runCmd
      puts " Deployed and running #{@request.data['command']} #{@request.data['arguments']}".light_green
      print ' STDOUT'.light_cyan + ' and' + ' STDERR'.light_magenta + ":\n"

      # offset (place saving) variables
      @stdoutOffset = 0
      @stderrOffset = 0
      begin
        # get most recent task state
        # need to wait for "task_running" before we can ask for STDOUT/STDERR
        @taskState = JSON.parse(RestClient.get "#{@uri}/api/history/task/#{@thisTask['taskId']['id']}")
        @taskState["taskUpdates"].each do |update|
          @taskState = update['taskState']
        end
        if @taskState == "TASK_FAILED"
          return 1 # failure
        end
        if @taskState == "TASK_RUNNING"
          sleep 1
          # print stdout
          @stdout = JSON.parse(RestClient.get "#{@uri}/api/sandbox/#{@thisTask['taskId']['id']}/read", {params: {path: "stdout", length: 30000, offset: @stdoutOffset}})['data']
          outLength = @stdout.bytes.to_a.size
          if @stdout.length > 0
            print @stdout.light_cyan
            @stdoutOffset += outLength
          end
          # print stderr
          @stderr = JSON.parse(RestClient.get "#{@uri}/api/sandbox/#{@thisTask['taskId']['id']}/read", {params: {path: "stderr", length: 30000, offset: @stderrOffset}})['data']
          errLength = @stderr.bytes.to_a.size
          if @stderr.length > 0
            print @stderr.light_magenta
            @stderrOffset += errLength
          end
        end
      end until @taskState == "TASK_FINISHED"

      return 0 # success
    end
def runCmd
      puts " Deployed and running #{@request.data['command']} #{@request.data['arguments']}".light_green
      print ' STDOUT'.light_cyan + ' and' + ' STDERR'.light_magenta + ":\n"

      # offset (place saving) variables
      @stdoutOffset = 0
      @stderrOffset = 0
      begin
        # get most recent task state
        # need to wait for "task_running" before we can ask for STDOUT/STDERR
        @taskState = JSON.parse(RestClient.get "#{@uri}/api/history/task/#{@thisTask['taskId']['id']}")
        @taskState["taskUpdates"].each do |update|
          @taskState = update['taskState']
        end
        if @taskState == "TASK_FAILED"
          return 1 # failure
        end
        if @taskState == "TASK_RUNNING"
          sleep 1
          # print stdout
          @stdout = JSON.parse(RestClient.get "#{@uri}/api/sandbox/#{@thisTask['taskId']['id']}/read", {params: {path: "stdout", length: 30000, offset: @stdoutOffset}})['data']
          outLength = @stdout.bytes.to_a.size
          if @stdout.length > 0
            print @stdout.light_cyan
            @stdoutOffset += outLength
          end
          # print stderr
          @stderr = JSON.parse(RestClient.get "#{@uri}/api/sandbox/#{@thisTask['taskId']['id']}/read", {params: {path: "stderr", length: 30000, offset: @stderrOffset}})['data']
          errLength = @stderr.bytes.to_a.size
          if @stderr.length > 0
            print @stderr.light_magenta
            @stderrOffset += errLength
          end
        end
      end until @taskState == "TASK_FINISHED"

      return 0 # success
    end
Returns an exit code (0 for success, 1 for failure)