Fault if env vars are not found · Issue #249 · Jean28518/linux-assistant · GitHub
Skip to content

Fault if env vars are not found #249

Open

Description

@fcassirer

https://github.com/Jean28518/linux-assistant/blame/b32db3948d51ff34ccc5258e3a53d159a61e85c0/additional/python/get_applications.py#L79

I get:

                                                                                                                                                                  
flutter: Traceback (most recent call last):                                                                                                                        
  File "/usr/lib/linux-assistant/additional/python//get_applications.py", line 79, in <module>                                                                     
    dataDirs = os.getenv("XDG_DATA_DIRS").split(":")                                                                                                               
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                    
AttributeError: 'NoneType' object has no attribute 'split'               

There are a number of places where os.getenv() is used without defaults and result in exceptions when the code runs.

Two such places are get_applications.py#79 and #81. There is a helper in jessentials.py, "get_environment_variable()" but it isn't used.
In addition, on line #81, just assuming "HOME" is an env variable isn't all that useful, instead, perhaps it would be better to defer to HOME if it exists but default to something like:

        from pathlib import Path

       str=str(Path('~').expanduser())
81: if jfolders.does_folder_exist(os.getenv("HOME",str) + "/.local/share/applications"):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions