Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_user_dir возвращает значения с нераскрытыми переменными среды окружения #30

Open
sibskull opened this issue Feb 20, 2020 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
Milestone

Comments

@sibskull
Copy link

Например, DESKTOP ­— "$HOME/Рабочий стол"
Требуется раскрывать переменные среды окружения типа $HOME. Лучше не самим парсить, а воспользоваться готовыми программами:

import subprocess
subprocess.check_output(['xdg-user-dir', 'DESKTOP']).decode()
'/home/TEST.ALT/ho/Рабочий стол\n'

@sibskull
Copy link
Author

def get_user_dir(dir_name, default=None):
    '''
    Get path to XDG's user directory
    '''
    try:
        output = subprocess.check_output(['xdg-user-dir', 'DESKTOP']).decode()
        return output.rstrip()
    except Exception as exc:
        return default

@ghost ghost self-assigned this Feb 27, 2020
@ghost ghost added bug Something isn't working help wanted Extra attention is needed labels Feb 27, 2020
@ghost
Copy link

ghost commented Feb 27, 2020

Unfortunately, gpoa when ran via oddjobd has no user's environment variables so we can't grant you that variables will be expanded. Anyway, it'll need additional testing to prove it'll be working.

@sibskull
Copy link
Author

Use xdg-user-dir instead of parsing file by yourself.

@ghost ghost added this to the Milestone 2 milestone Feb 27, 2020
@ghost ghost added this to To do in Planning Feb 27, 2020
@ghost ghost added enhancement New feature or request and removed bug Something isn't working labels Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
Planning
  
To do
Development

No branches or pull requests

1 participant