Skip to content

Conversation

@ThibaultDECO
Copy link
Contributor

A few tweaks to sys_info example

@gemini-code-assist
Copy link

Summary of Changes

Hello @ThibaultDECO, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces several enhancements to the sys_info.py example script, focusing on improving the clarity and presentation of system metrics. The changes aim to make the displayed information more comprehensive and visually appealing, ensuring a better user experience when monitoring system performance.

Highlights

  • System Information Display: The cpu_usage, mem_usage, and disk_usage functions in sys_info.py have been updated to provide more detailed and user-friendly output formats. CPU usage now shows a percentage and uptime in days, hours, and minutes, while memory and disk usage display both used and total values along with percentages.
  • Display Layout and Aesthetics: The stats function has been refined to improve the visual presentation on the display. This includes changing the font to 'DejaVuSansMono.ttf' for better readability, adding a white outline around the display area, and adjusting text positioning to ensure consistent vertical spacing based on line height.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several nice improvements to the sys_info example. The information displayed for CPU, memory, and disk usage is now more informative and clearly formatted. The stats function has been significantly refactored to dynamically calculate line heights based on the font, making the layout more robust and adaptable. My review includes a suggestion to further refine the drawing logic in the stats function for better clarity and robustness.

Comment on lines +102 to 113
draw.text((2, line_height * 0), cpu_usage(), font=font2, fill="white")
if device.height >= (line_height * 2):
draw.text((2, line_height * 1), mem_usage(), font=font2, fill="white")

if device.height >= 64:
draw.text((0, 26), disk_usage('/'), font=font2, fill="white")
if device.height >= (line_height * 3):
draw.text((2, line_height * 2), disk_usage('/'), font=font2, fill="white")
try:
draw.text((0, 38), network('wlan0'), font=font2, fill="white")
if device.height >= (line_height * 4):
draw.text((2, line_height * 3), network('wlan0'), font=font2, fill="white")
except KeyError:
# no wifi enabled/available
pass

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for drawing the text lines can be simplified and made more robust.

  1. The first line is drawn unconditionally, which might cause clipping on small displays. It should have a height check like the other lines.
  2. The if condition for network info is nested inside the one for disk info. This can be flattened to make the logic for each line independent and clearer.

Here is a suggested refactoring that addresses these points:

Suggested change
draw.text((2, line_height * 0), cpu_usage(), font=font2, fill="white")
if device.height >= (line_height * 2):
draw.text((2, line_height * 1), mem_usage(), font=font2, fill="white")
if device.height >= 64:
draw.text((0, 26), disk_usage('/'), font=font2, fill="white")
if device.height >= (line_height * 3):
draw.text((2, line_height * 2), disk_usage('/'), font=font2, fill="white")
try:
draw.text((0, 38), network('wlan0'), font=font2, fill="white")
if device.height >= (line_height * 4):
draw.text((2, line_height * 3), network('wlan0'), font=font2, fill="white")
except KeyError:
# no wifi enabled/available
pass
if device.height >= line_height:
draw.text((2, line_height * 0), cpu_usage(), font=font2, fill="white")
if device.height >= (line_height * 2):
draw.text((2, line_height * 1), mem_usage(), font=font2, fill="white")
if device.height >= (line_height * 3):
draw.text((2, line_height * 2), disk_usage('/'), font=font2, fill="white")
if device.height >= (line_height * 4):
try:
draw.text((2, line_height * 3), network('wlan0'), font=font2, fill="white")
except KeyError:
# no wifi enabled/available
pass

@rm-hull rm-hull merged commit 601ac32 into rm-hull:main Nov 15, 2025
3 checks passed
@ThibaultDECO ThibaultDECO deleted the patch-2 branch November 16, 2025 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants