Skip to content

Commit

Permalink
Merge pull request #1654 from OpenC3/sr_output
Browse files Browse the repository at this point in the history
Colorize SR output on CHECK success/failure
  • Loading branch information
ryanmelt authored Oct 24, 2024
2 parents f0cd262 + 4ac6392 commit a7b71b5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@
hide-default-footer
dense
data-test="output-messages"
/>
>
<template v-slot:item.message="{ item }">
<div :class="messageClass(item.message)">{{ item.message }}</div>
</template>
</v-data-table>
</v-card>
</div>
</template>
Expand Down Expand Up @@ -126,6 +130,15 @@ export default {
},
},
methods: {
messageClass(message) {
if (message.match(/CHECK:.*success with value.*after waiting/)) {
return 'openc3-green'
} else if (message.match(/CHECK:.*failed with value.*after waiting/)) {
return 'openc3-red'
} else {
return ''
}
},
downloadLog() {
const output = this.messages.map((message) => message.message).join('\n')
const blob = new Blob([output], {
Expand Down
6 changes: 5 additions & 1 deletion openc3-cosmos-script-runner-api/app/models/running_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,11 @@ def handle_output_io(filename = @current_filename, line_number = @current_line_n
begin
json = JSON.parse(out_line, :allow_nan => true, :create_additions => true)
time_formatted = Time.parse(json["@timestamp"]).sys.formatted if json["@timestamp"]
out_line = json["log"] if json["log"]
if json["log"]
out_line = json["log"]
elsif json["message"]
out_line = json["message"]
end
rescue
# Regular output
end
Expand Down
2 changes: 2 additions & 0 deletions openc3-cosmos-script-runner-api/scripts/running_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@ def handle_output_io(self, filename=None, line_number=None):
time_formatted = json_hash["@timestamp"]
if "log" in json_hash:
out_line = json_hash["log"]
if "message" in json_hash:
out_line = json_hash["message"]
except:
# Regular output
pass
Expand Down

0 comments on commit a7b71b5

Please sign in to comment.