mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 19:26:37 +00:00
make new VSC port pio script more failsafe (#23439)
* no crash when VSC database is not found * don't stop when unknown OS is detected
This commit is contained in:
parent
2b460aa112
commit
54a9a117fc
@ -21,20 +21,22 @@ if os.environ.get("PLATFORMIO_CALLER") == "vscode":
|
|||||||
try:
|
try:
|
||||||
db_path = os.path.expanduser(os.path.expandvars(os_paths[os_name]))
|
db_path = os.path.expanduser(os.path.expandvars(os_paths[os_name]))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise RuntimeError("Unknown OS: " + os_name)
|
print("Unknown OS: " + os_name)
|
||||||
|
|
||||||
conn = sqlite3.connect(db_path)
|
# Only when the database is found we can go on
|
||||||
cursor = conn.cursor()
|
if os.path.exists(db_path):
|
||||||
|
conn = sqlite3.connect(db_path)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
for key in ['pioarduino.pioarduino-ide', 'platformio.platformio-ide']:
|
for key in ['pioarduino.pioarduino-ide', 'platformio.platformio-ide']:
|
||||||
cursor.execute("SELECT value FROM ItemTable WHERE key = ?", (key,))
|
cursor.execute("SELECT value FROM ItemTable WHERE key = ?", (key,))
|
||||||
row = cursor.fetchone()
|
row = cursor.fetchone()
|
||||||
if row:
|
if row:
|
||||||
data = json.loads(row[0])
|
data = json.loads(row[0])
|
||||||
projects = data.get("projects", {})
|
projects = data.get("projects", {})
|
||||||
project = projects.get(project_path)
|
project = projects.get(project_path)
|
||||||
if project and "customPort" in project:
|
if project and "customPort" in project:
|
||||||
print("USB port set in VSC:", project["customPort"])
|
print("USB port set in VSC:", project["customPort"])
|
||||||
env["UPLOAD_PORT"] = project["customPort"]
|
env["UPLOAD_PORT"] = project["customPort"]
|
||||||
break
|
break
|
||||||
conn.close()
|
conn.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user