mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Use native Windows API for getting My Documents folder path
This commit is contained in:
@ -30,6 +30,19 @@ from platformio.project.helpers import (get_project_cache_dir,
|
||||
get_project_core_dir)
|
||||
|
||||
|
||||
def get_default_projects_dir():
|
||||
docs_dir = join(expanduser("~"), "Documents")
|
||||
try:
|
||||
assert WINDOWS
|
||||
import ctypes.wintypes
|
||||
buf = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
|
||||
ctypes.windll.shell32.SHGetFolderPathW(None, 5, None, 0, buf)
|
||||
docs_dir = buf.value
|
||||
except: # pylint: disable=bare-except
|
||||
pass
|
||||
return join(docs_dir, "PlatformIO", "Projects")
|
||||
|
||||
|
||||
def projects_dir_validate(projects_dir):
|
||||
assert isdir(projects_dir)
|
||||
return abspath(projects_dir)
|
||||
@ -77,7 +90,7 @@ DEFAULT_SETTINGS = {
|
||||
},
|
||||
"projects_dir": {
|
||||
"description": "Default location for PlatformIO projects (PIO Home)",
|
||||
"value": join(expanduser("~"), "Documents", "PlatformIO", "Projects"),
|
||||
"value": get_default_projects_dir(),
|
||||
"validator": projects_dir_validate
|
||||
},
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
import click
|
||||
|
||||
from platformio import app
|
||||
from platformio.compat import string_types
|
||||
|
||||
|
||||
@click.group(short_help="Manage PlatformIO settings")
|
||||
@ -26,7 +27,7 @@ def cli():
|
||||
@click.argument("name", required=False)
|
||||
def settings_get(name):
|
||||
|
||||
list_tpl = "{name:<40} {value:<35} {description}"
|
||||
list_tpl = u"{name:<40} {value:<35} {description}"
|
||||
terminal_width, _ = click.get_terminal_size()
|
||||
|
||||
click.echo(
|
||||
@ -41,7 +42,8 @@ def settings_get(name):
|
||||
continue
|
||||
_value = app.get_setting(_name)
|
||||
|
||||
_value_str = str(_value)
|
||||
_value_str = (str(_value)
|
||||
if not isinstance(_value, string_types) else _value)
|
||||
if isinstance(_value, bool):
|
||||
_value_str = "Yes" if _value else "No"
|
||||
_value_str = click.style(_value_str, fg="green")
|
||||
|
Reference in New Issue
Block a user