Skip to content

Fault if env vars are not found #249

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

Open
fcassirer opened this issue Mar 27, 2025 · 0 comments
Open

Fault if env vars are not found #249

fcassirer opened this issue Mar 27, 2025 · 0 comments

Comments

@fcassirer
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant