Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4f7736b2d | ||
|
|
60f72fffdf | ||
|
|
77af9c1cba | ||
|
|
1b2414337f |
@@ -6,7 +6,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/kuba2k2/platformio-libretuya"
|
||||
},
|
||||
"version": "0.12.1",
|
||||
"version": "0.12.3",
|
||||
"frameworks": {
|
||||
"arduino": {
|
||||
"title": "Generic Arduino framework",
|
||||
|
||||
31
platform.py
31
platform.py
@@ -20,27 +20,32 @@ LTCHIPTOOL_VERSION = "^2.0.2"
|
||||
|
||||
# Install & import tools
|
||||
def check_ltchiptool(install: bool):
|
||||
if install:
|
||||
# update ltchiptool to a supported version
|
||||
print("Installing/updating ltchiptool")
|
||||
system(
|
||||
f'{sys.executable} -m pip install -U "ltchiptool >= {LTCHIPTOOL_VERSION}, < 3.0"'
|
||||
)
|
||||
|
||||
# unload all modules from the old version
|
||||
for name, module in list(sorted(sys.modules.items())):
|
||||
if not name.startswith("ltchiptool"):
|
||||
continue
|
||||
del sys.modules[name]
|
||||
del module
|
||||
|
||||
# try to import it
|
||||
ltchiptool = importlib.import_module("ltchiptool")
|
||||
|
||||
# check if the version is known
|
||||
if Version(ltchiptool.get_version()) in SimpleSpec(LTCHIPTOOL_VERSION):
|
||||
return
|
||||
if not install:
|
||||
raise ImportError("Version too old")
|
||||
|
||||
# update ltchiptool to a supported version
|
||||
print("Installing/updating ltchiptool")
|
||||
system(f"{sys.executable} -m pip install -U ltchiptool=={LTCHIPTOOL_VERSION}")
|
||||
|
||||
# unload all modules from the old version
|
||||
for name, module in list(sorted(sys.modules.items())):
|
||||
if not name.startswith("ltchiptool"):
|
||||
continue
|
||||
del sys.modules[name]
|
||||
del module
|
||||
|
||||
|
||||
def try_check_ltchiptool():
|
||||
install_modes = [True, False]
|
||||
install_modes = [False, True]
|
||||
exception = None
|
||||
for install in install_modes:
|
||||
try:
|
||||
@@ -51,7 +56,7 @@ def try_check_ltchiptool():
|
||||
print(
|
||||
"!!! Installing ltchiptool failed, or version outdated. "
|
||||
"Please install ltchiptool manually using pip. "
|
||||
f"Cannot continue: {exception}"
|
||||
f"Cannot continue. {type(exception).name}: {exception}"
|
||||
)
|
||||
raise exception
|
||||
|
||||
|
||||
Reference in New Issue
Block a user