fix(ci): provision.py subprocess-first NVS gen + swarm IDF venv
provision.py had same 'str' has no attribute 'size' bug as the NVS matrix generator — switch to subprocess-first approach. Swarm test also needs IDF export for the swarm smoke test step. Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
parent
815ff60ff7
commit
e0b808d3ac
|
|
@ -83,25 +83,20 @@ def generate_nvs_binary(csv_content, size):
|
||||||
bin_path = csv_path.replace(".csv", ".bin")
|
bin_path = csv_path.replace(".csv", ".bin")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Try the pip-installed version first (esp_idf_nvs_partition_gen package)
|
# Method 1: subprocess invocation (most reliable across package versions)
|
||||||
try:
|
for module_name in ["esp_idf_nvs_partition_gen", "nvs_partition_gen"]:
|
||||||
from esp_idf_nvs_partition_gen import nvs_partition_gen
|
try:
|
||||||
nvs_partition_gen.generate(csv_path, bin_path, size)
|
subprocess.check_call(
|
||||||
with open(bin_path, "rb") as f:
|
[sys.executable, "-m", module_name, "generate",
|
||||||
return f.read()
|
csv_path, bin_path, hex(size)],
|
||||||
except ImportError:
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||||
pass
|
)
|
||||||
|
with open(bin_path, "rb") as f:
|
||||||
|
return f.read()
|
||||||
|
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||||
|
continue
|
||||||
|
|
||||||
# Try legacy import name (older versions)
|
# Method 2: ESP-IDF bundled script
|
||||||
try:
|
|
||||||
import nvs_partition_gen
|
|
||||||
nvs_partition_gen.generate(csv_path, bin_path, size)
|
|
||||||
with open(bin_path, "rb") as f:
|
|
||||||
return f.read()
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Fall back to calling the ESP-IDF script directly
|
|
||||||
idf_path = os.environ.get("IDF_PATH", "")
|
idf_path = os.environ.get("IDF_PATH", "")
|
||||||
gen_script = os.path.join(idf_path, "components", "nvs_flash",
|
gen_script = os.path.join(idf_path, "components", "nvs_flash",
|
||||||
"nvs_partition_generator", "nvs_partition_gen.py")
|
"nvs_partition_generator", "nvs_partition_gen.py")
|
||||||
|
|
@ -113,13 +108,10 @@ def generate_nvs_binary(csv_content, size):
|
||||||
with open(bin_path, "rb") as f:
|
with open(bin_path, "rb") as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
# Last resort: try as a module
|
raise RuntimeError(
|
||||||
subprocess.check_call([
|
"NVS partition generator not available. "
|
||||||
sys.executable, "-m", "nvs_partition_gen", "generate",
|
"Install: pip install esp-idf-nvs-partition-gen"
|
||||||
csv_path, bin_path, hex(size)
|
)
|
||||||
])
|
|
||||||
with open(bin_path, "rb") as f:
|
|
||||||
return f.read()
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
for p in (csv_path, bin_path):
|
for p in (csv_path, bin_path):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue