Fixed wrong path (#4158)

* Fixed wrong path

On linux, "Documents" doesn't have to be the right folder. It depends on the language selected when installing the operating system.

* Refactor code

* Update HISTORY.rst

Co-authored-by: Ivan Kravets <me@ikravets.com>
This commit is contained in:
CommanderRedYT
2022-01-20 11:19:30 +01:00
committed by GitHub
parent 4e1ec1215a
commit 8c66352994
2 changed files with 11 additions and 3 deletions

View File

@ -12,7 +12,8 @@ PlatformIO Core 5
~~~~~~~~~~~~~~~~~~
- Improved support for private packages in `PlatformIO Registry <https://registry.platformio.org/>`__
- Improved checking of available Internet connection for IPv6-only workstations (`pull #4151 <https://github.com/platformio/platformio-core/issues/4151>`_)
- Improved checking of available Internet connection for IPv6-only workstations (`pull #4151 <https://github.com/platformio/platformio-core/pull/4151>`_)
- Better detecting of default PlatformIO project directory on Linux OS (`pull #4158 <https://github.com/platformio/platformio-core/pull/4158>`_)
- Respect disabling debugging server from "platformio.ini" passing an empty value to the `debug_server <https://docs.platformio.org/en/latest/projectconf/section_env_debug.html#debug-server>`__ option
5.2.4 (2021-12-15)

View File

@ -14,12 +14,13 @@
import json
import os
import subprocess
from hashlib import sha1
from click.testing import CliRunner
from platformio import __version__, exception, fs
from platformio.compat import IS_WINDOWS, hashlib_encode_data
from platformio.compat import IS_MACOS, IS_WINDOWS, hashlib_encode_data
from platformio.project.config import ProjectConfig
@ -75,7 +76,13 @@ def get_default_projects_dir():
ctypes.windll.shell32.SHGetFolderPathW(None, 5, None, 0, buf)
docs_dir = buf.value
except: # pylint: disable=bare-except
pass
if not IS_MACOS:
try:
docs_dir = subprocess.check_output(
["xdg-user-dir", "DOCUMENTS"]
).decode("utf-8")
except FileNotFoundError: # command not found
pass
return os.path.join(docs_dir, "PlatformIO", "Projects")