-
Notifications
You must be signed in to change notification settings - Fork 0
/
idf-docker.py
38 lines (31 loc) · 923 Bytes
/
idf-docker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
import os
import subprocess
import sys
# Define the Docker image name
IMAGE_NAME = "espressif/idf:v5.3.1"
# Get environment variables (or set defaults if not present)
UD_GEN = os.getenv("UD_GEN")
if not UD_GEN:
print("Error: UD_GEN environment variable is not set.", file=sys.stderr)
sys.exit(1)
UD_DEBUG = os.getenv("UD_DEBUG", "0")
# Get the current working directory
current_directory = os.getcwd()
# Build the Docker command
docker_command = [
"docker", "run", "--rm", "-it",
"-v", f"{current_directory}:/workspace",
"-w", "/workspace",
"-e", f"UD_GEN={UD_GEN}",
"-e", f"UD_DEBUG={UD_DEBUG}",
IMAGE_NAME
]
# Add any additional arguments passed to the Python script
docker_command += sys.argv[1:]
# Run the Docker command
try:
subprocess.run(docker_command, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
sys.exit(1)