GithubHelp home page GithubHelp logo

dwavesystems / homebase Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 11.0 53 KB

platform independent access to user data folders.

Home Page: http://homebase.readthedocs.io/

License: Other

Python 99.80% Dockerfile 0.20%

homebase's People

Contributors

arcondello avatar bastianzim avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

homebase's Issues

`site_config_dir` and `site_config_dir_list` failing to create the directory

The error:

>>> import homebase
>>> homebase.site_config_dir("myapp", "author")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/tmp.fumBiPyUdA/lib/python3.5/site-packages/homebase/homebase.py", line 307, in site_config_dir
    return _get_folder(False, _FolderTypes.config, app_name, app_author, version, False, use_virtualenv, create)[0]
  File "/tmp/tmp.fumBiPyUdA/lib/python3.5/site-packages/homebase/homebase.py", line 430, in _get_folder
    os.makedirs(final_path)
  File "/tmp/tmp.fumBiPyUdA/lib/python3.5/os.py", line 231, in makedirs
    makedirs(head, mode, exist_ok)
  File "/tmp/tmp.fumBiPyUdA/lib/python3.5/os.py", line 241, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/etc/xdg/xdg-ubuntu'

The site_config_dir() and site_config_dir_list() should probably have create=False as the default.

Update to use CircleCI

Most of the other Ocean packages have been updated to use CircleCI, we should update homebase as well.

enum package

Hi Oren, when I tried to install, I had to manually install the "enum" package (after that, "enum34" was installed automatically when I called setup.py).

XDG usage

Config dirs (on Linux) returned according to XDG (X Windows Desktop) specs:

/etc/xdg/xdg-ubuntu
/usr/share/upstart/xdg
/etc/xdg

Data dirs:

/usr/share/ubuntu
/usr/share/gnome
/usr/local/share
/usr/share
/var/lib/snapd/desktop
/var/lib/snapd/desktop

For the default system-wide config dir, homebase returns:

>>> homebase.site_config_dir("myapp", "author", create=False)
'/etc/xdg/xdg-ubuntu/myapp'

I was expecting to see something like /usr/local/share/myapp and /etc/local/myapp.

Handle possible race condition during directory create

For all directory lookup operations when create=True, this gets executed in _get_folder():

if create and not os.path.exists(final_path):
os.makedirs(final_path)

Since directory existence check and create are not one atomic operation, it's possible directory gets created (by another thread or process running the same code) between the check and the create. When that happens, the other thread/process fails with FileExistsError.

The solution here is to set exist_ok=True when calling os.makedirs. I.e. the create op should be idempotent here.

add appdirs license

We want to point out the pieces of appdirs code and include their license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.