M7S / dockbarx

289 stars 40 forks source link

dbx_preference fails due to circular dependency #87

Closed spell02 closed 5 years ago

spell02 commented 5 years ago

dbx_preference fails to open with the following error:

Traceback (most recent call last):
  File "/usr/bin/dbx_preference", line 31, in <module>
    from dockbarx.common import *
  File "/usr/local/lib/python2.7/dist-packages/dockbarx/common.py", line 32, in <module>
    from log import logger
  File "/usr/local/lib/python2.7/dist-packages/dockbarx/log.py", line 27, in <module>
    from common import get_app_homedir
ImportError: cannot import name get_app_homedir

This is because dockbarx/common.py imports dockbarx/log.py, which imports dockbarx/common.py for get_app_home_dir().

On a different note, in get_app_home_dir(), the home directory is gotten with os.environ['HOME'] but I believe that expanduser("~") is more portable. Don't quote me on this, but just an aside.

denisfa commented 5 years ago

Hey! Sorry for that, such a bad mistake for my part. =(

About being more portable, do you mean between Linux' OSes? I know there are better ways to get the home dir when you want you app to run Windows/MacOS/Linux but, at least for now, this is a Linux-only app.

HOME=/tmp python2.7
>>> import os
>>> os.path.expanduser("~")
'/tmp'

I checked if we could avoid trolling with this, but seems to be the same.