-
-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve voltage warning lines in TinyPilot logs #1544
Improve voltage warning lines in TinyPilot logs #1544
Conversation
Automated comment from CodeApprove ➜⏳ @jdeanwallace please review this Pull Request |
@cghague - Just a heads up that I'm reassigning these reviews to @jdeanwallace since I'm backed up this week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated comment from CodeApprove ➜
⏳ Approval Pending (3 unresolved comments)
Approval will be granted automatically when all comments are resolved
LGTM!
In: Discussion
Short arguments were used for consistency with the majority of the rest of the collect-debug-logs script.
I think this is generally the right choice, but in this case there is already a few other instances of using the prefered long arguments (1, 2, 3) that I think we should just go with using long arguments in this PR.
In: debian-pkg/opt/tinypilot-privileged/scripts/collect-debug-logs:
> Line 142
if LAST_VOLTAGE_LINE=$(journalctl -q -r -n 1 -g "voltage") ; then
Can we quote the command substitution?
From Google Shell style guide:
# "quote command substitutions" # Note that quotes nested inside "$()" don't need escaping. flag="$(some_command and its args "$@" 'quoted separately')"
In: debian-pkg/opt/tinypilot-privileged/scripts/collect-debug-logs:
> Line 145
printf "No"
This is something new I just confirmed with Michael, but can we use a lowercase "yes"/"no"?
👀 @cghague it's your turn please take a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated comment from CodeApprove ➜
In: Discussion
+1
If we have a defined convention, we usually want to use that one. If a file is internally consistent in violating our convention, and it would look weird to use our official convention (e.g., spaces in a file that consistently uses tabs), then we should be locally consistent.
But for cases where the file itself is inconsistent in adhering to a convention, we should go with our style guide.
I've filed #1547 to make collect-debug-logs
consistent.
👀 @cghague, @jdeanwallace it's your turn please take a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated comment from CodeApprove ➜
In: Discussion
Resolved
In: debian-pkg/opt/tinypilot-privileged/scripts/collect-debug-logs:
Resolved
In: debian-pkg/opt/tinypilot-privileged/scripts/collect-debug-logs:
Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated comment from CodeApprove ➜
Approved: I have approved this change on CodeApprove and all of my comments have been resolved.
Resolves #1495
Parses the output of
journalctl
into a simple “yes” or “no” result. If the result is “yes”, the latest voltage warning is also included in the output.Parsing the output of
journalctl
I initially considered piping the output of
journalctl
intogrep
for readability, but getting the correct exit code as well as just the latest voltage warning was quite awkward with this approach. I therefore settled on using just the filtering and output options that are built intojournalctl
:-q
argument is used to suppress the unwantedjournalctl
header text.-r
argument causesjournalctl
to output from newest to oldest.-n 1
argument causesjournalctl
to stop after outputting a single line.-g "voltage"
argument limits output to only lines that contain the word “voltage”.The end result of this combination of arguments is that
journalctl
will efficiently output only the most recent voltage warning. In addition, the exit status of the command reflects whether or not any matching lines were found, which allows for a simpleif <command>
test to be used.Short arguments were used for consistency with the majority of the rest of the
![Review on CodeApprove](https://camo.githubusercontent.com/575eb075ea0212ea9b05fa395f16d231ecb42d04a1ad83bd98925e9b2783e9a7/68747470733a2f2f636f6465617070726f76652e636f6d2f65787465726e616c2f6769746875622d7461672d616c6c62672e706e67)
collect-debug-logs
script.