From bd611bbee81a85bdbd0bb6e60534b3a346019b7b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 14 Dec 2017 16:52:13 +0200 Subject: [PATCH] Allow to change default projects location // Resolve #1161 --- docs | 2 +- platformio/app.py | 55 ++++++++++++++++++++++--------------- platformio/managers/core.py | 2 +- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/docs b/docs index 5e303c13..0f72050d 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 5e303c13b78db4f1a4008f3901a2d503f7db5354 +Subproject commit 0f72050d3a2d9d67bfa74e426bd9418ad82fbd7f diff --git a/platformio/app.py b/platformio/app.py index 676d2d3b..ffacb7c2 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -18,7 +18,7 @@ import os import uuid from copy import deepcopy from os import environ, getenv, listdir, remove -from os.path import dirname, getmtime, isdir, isfile, join +from os.path import abspath, dirname, expanduser, getmtime, isdir, isfile, join from time import time import requests @@ -27,7 +27,25 @@ from lockfile import LockFailed, LockFile from platformio import __version__, exception, util from platformio.exception import InvalidSettingName, InvalidSettingValue + +def projects_dir_validate(projects_dir): + assert isdir(projects_dir) + return abspath(projects_dir) + + DEFAULT_SETTINGS = { + "auto_update_libraries": { + "description": "Automatically update libraries (Yes/No)", + "value": False + }, + "auto_update_platforms": { + "description": "Automatically update platforms (Yes/No)", + "value": False + }, + "check_libraries_interval": { + "description": "Check for the library updates interval (days)", + "value": 7 + }, "check_platformio_interval": { "description": "Check for the new PlatformIO interval (days)", "value": 3 @@ -36,37 +54,30 @@ DEFAULT_SETTINGS = { "description": "Check for the platform updates interval (days)", "value": 7 }, - "check_libraries_interval": { - "description": "Check for the library updates interval (days)", - "value": 7 - }, - "auto_update_platforms": { - "description": "Automatically update platforms (Yes/No)", - "value": False - }, - "auto_update_libraries": { - "description": "Automatically update libraries (Yes/No)", - "value": False - }, - "force_verbose": { - "description": "Force verbose output when processing environments", - "value": False + "enable_cache": { + "description": "Enable caching for API requests and Library Manager", + "value": True }, "enable_ssl": { "description": "Enable SSL for PlatformIO Services", "value": False }, - "enable_cache": { - "description": "Enable caching for API requests and Library Manager", - "value": True - }, "enable_telemetry": { "description": ("Telemetry service (Yes/No)"), "value": True - } + }, + "force_verbose": { + "description": "Force verbose output when processing environments", + "value": False + }, + "projects_dir": { + "description": "Default location for PlatformIO projects (PIO Home)", + "value": join(expanduser("~"), "Documents", "PlatformIO", "Projects"), + "validator": projects_dir_validate + }, } SESSION_VARS = {"command_ctx": None, "force_option": False, "caller_id": None} @@ -269,7 +280,7 @@ def sanitize_setting(name, value): defdata = DEFAULT_SETTINGS[name] try: if "validator" in defdata: - value = defdata['validator']() + value = defdata['validator'](value) elif isinstance(defdata['value'], bool): if not isinstance(value, bool): value = str(value).lower() in ("true", "yes", "y", "1") diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 3a383ec8..f6ff4bff 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -23,7 +23,7 @@ from platformio.managers.package import PackageManager CORE_PACKAGES = { "contrib-piohome": ">=0.4.0,<2", "pysite-pioplus": ">=0.4.2,<2", - "tool-pioplus": ">=0.11.0,<2", + "tool-pioplus": ">=0.12.0,<2", "tool-unity": "~1.20302.1", "tool-scons": "~3.20501.2" }