wendlers / mpfshell

A simple shell based file explorer for ESP8266 Micropython based devices ⛺
MIT License
396 stars 84 forks source link

Bug: Use uos.uname instead of os.uname #62

Closed stlehmann closed 5 years ago

stlehmann commented 5 years ago

mfpshell uses the uname function to get information about the board that it connects to. In the Micropython documentation this function lives in the "uos" module. However mpfshell uses os.uname() which is not a problem as long as one does not install the "os" module from micropython-lib which offers advanced functionality. This os module does not support uname as it is meant to lean on to CPythons os module.

A proper solution is to use uos.uname in the mpshell code. I fixed this in https://github.com/wendlers/mpfshell/pull/51.

skorokithakis commented 5 years ago

Your fix in #51 doesn't seem like it'll work, since the module gets imported as os and it's called as os everywhere else. Have you tested it?

stlehmann commented 5 years ago

Yes, I tested it on an ESP32 and it works just fine because uos gets loaded automatically on startup. You are right, the import for the uos module is missing. We should add this to the existing imports even the uos module gets imported automatically on startup. Using os everywhere else is also OK because the called functions exist in uos and os. However with uname that is not the case so uos.uname needs to be used here.

skorokithakis commented 5 years ago

We should be consistent and use the same module name everywhere, so we should migrate everything from os to uos. You're right that it gets loaded on startup, but I still prefer the explicit import. I would merge a PR that changes all os. to uos. calls, and also imports uos at the start. I'll implement it if I have time, or if you want to take a stab at it sooner, even better!

skorokithakis commented 5 years ago

This should be fixed in 3af4a1f, can you test?