Comments (1)
working propotype
mpremote COM16 mount . get-port
"stubber: get-port"
import gc
import os
import sys
try:
from collections import OrderedDict
except ImportError:
from ucollections import OrderedDict # type: ignore
info = OrderedDict(
{
"family": sys.implementation.name,
"version": "",
"port": "stm32" if sys.platform.startswith("pyb") else sys.platform, # port: esp32 / win32 / linux / stm32
"board": "GENERIC",
"cpu": "",
"build": "",
"board_d": "",
}
)
try:
info["version"] = ".".join([str(n) for n in sys.implementation.version])
except AttributeError:
pass
try:
machine = sys.implementation._machine if "_machine" in dir(sys.implementation) else os.uname().machine
info["board"] = machine.strip()
info["cpu"] = machine.split("with")[1].strip()
except (AttributeError, IndexError):
pass
gc.collect()
try:
# look up the board name in the board_info.csv file
with open("board_info.csv", "r") as f:
b = info["board"]
for line in f:
descr_, board_ = line.split(",")[1].strip(), line.split(",")[0].strip()
if board_ == b:
info["board_d"] = board_
info["board"] = descr_
break
info["board"] = info["board"].replace(" ", "_")
except (AttributeError, IndexError, OSError):
pass
gc.collect()
try:
info["build"] = sys.version.split(";")[1].strip().split(" ")[1].split("-")[1]
except (AttributeError, IndexError):
pass
if info["version"] == "" and sys.platform not in ("unix", "win32"):
try:
u = os.uname()
info["version"] = u.release
except (IndexError, AttributeError, TypeError):
pass
try: # families
from pycopy import const as _t # type: ignore
info["family"] = "pycopy"
del _t
except (ImportError, KeyError):
pass
try: # families
from pycom import FAT as _t # type: ignore
info["family"] = "pycom"
del _t
except (ImportError, KeyError):
pass
if info["family"] == "micropython":
if (
info["version"]
and info["version"].endswith(".0")
and info["version"] >= "1.10.0" # versions from 1.10.0 to 1.20.0 do not have a micro .0
and info["version"] <= "1.20.0"
):
# drop the .0 for newer releases
info["version"] = info["version"][:-2]
# output the info dict as a string with the OrderedDict() removed
print(str(info).replace("OrderedDict(", "").rstrip(")"))
from micropython-stubber.
Related Issues (20)
- SoftI2C is asking for an id parameter and it should not HOT 12
- Generating lvgl stubs using documentation HOT 8
- Update micopython-lib matching for v1.12.0 or newer
- Update handling of u-modules in 1.20.1 and up HOT 2
- Check/Update latest stubs version numbering
- Fix bare const using __builtins__.py - pyright/pylance HOT 2
- Document how to generate stubs for a branch or fork of MicroPython? HOT 12
- Try rich-click for nicer UX
- improve typing for 'underdocumented' `__init__` methods
- from _typeshed import Incomplete
- fix class SoftSPI(SPI) error as SPI defined later ( reorder / different syntax) HOT 1
- Merge docstring for Literals from the documentation into the stub files
- Consider the "Any trick"
- stubber build: Incorrect package versions When specifying multiple versions to be build at the same time
- BTLE low-level constants defined as 'Incomplete' HOT 6
- Should constant values be included in stub files
- Find simple way to add more documentation by the community
- update src/stubber/tools/manifestfile.py from Micropython repo
- Add disk backed cache - and find/fix other startup delays.
- docstubs to use ...
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micropython-stubber.