Repository navigation
os.uname(): sysname is CircuitPython; nodename is the hostname - #11905
Merged
Merged
Conversation
sysname and nodename were both the microcontroller name. - sysname is "CircuitPython", or "Zephyr" on zephyr-cp (CIRCUITPY_OS_UNAME_SYSNAME). - On boards with Wi-Fi or Ethernet, nodename is the network hostname, read on each call. Before the interface is set up, it is the hostname the interface will use: CIRCUITPY_WIFI_HOSTNAME if set, otherwise the port's default. - On boards without networking, nodename is still the microcontroller name, and os.uname() still returns a constant tuple. Move the "cpy-<board>-<mac>" default-hostname formatting, which was copied in three places, into supervisor/shared/network.c. Add per-port wifi_hostname_is_set(), wifi_get_default_hostname() and mii_get_default_hostname(), which work before the interface is set up. Fixes adafruit#10153. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It reports whether common_hal_wifi_init() has run, which is more general than whether the hostname is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The de_DE build overflowed by 4 bytes after adding the "CircuitPython" os.uname().sysname string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Why is sysname Zephyr on the Zephyr port? That should be an implementation detail. I think it should be CircuitPython still. |
Collaborator
Author
I thought it would be nice to know, and it's an RTOS. But I waffled on this. I'll take it out. |
The RTOS is an implementation detail. Drop the zephyr-cp override and the CIRCUITPY_OS_UNAME_SYSNAME setting, which now has only one value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code by Claude, reviewed and revised by @dhalbert.
Problem
os.uname().sysnameandos.uname().nodenameboth returned the microcontroller name. In CPython,sysnameis the OS name andnodenameis the machine's hostname.Fix
sysnameis now"CircuitPython".nodenameis the network hostname, read on each call. It will track changes towifi.radio.hostnameorEthernet.hostname.nodenameis the hostname the interface will use:CIRCUITPY_WIFI_HOSTNAMEfromsettings.tomlif set, otherwise the port's default (cpy-<board>-<mac>,PicoWon raspberrypi,cpy-<mac>on espressif Ethernet).nodenameis still the microcontroller name.os.uname()will still return a constant tuple instead of constructing one. This means that builds with no network support grow only enough to include the"CircuitPython"string.cpy-<board>-<mac>default-hostname code, which was copied in three places, is now refactored intonetwork_format_default_hostname()insupervisor/shared/network.c.This is a breaking change, so it is for 11.0.0.
Testing
nodenamebefore and afterimport wifi, after settingwifi.radio.hostname, and with and withoutCIRCUITPY_WIFI_HOSTNAME.nodenamewithboard.ETHERNET, before and after setting its hostname.tests/test_os.py.