PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/silversupport/env.py

https://bitbucket.org/ianb/silverlining/
Python | 25 lines | 11 code | 6 blank | 8 comment | 1 complexity | 3416b726ebaa9d4ec90931294cb0ee76 MD5 | raw file
Possible License(s): GPL-2.0
  1. """Functions specifically related to the environment this is running in."""
  2. import os
  3. __all__ = ['is_production', 'local_location']
  4. def is_production():
  5. """Returns true if this is a production environment. False if it
  6. is development or unknown"""
  7. ## FIXME: this is lame. It's causing prolbems with the CI server too.
  8. return os.path.exists('/usr/local/share/silverlining/lib')
  9. def local_location(path):
  10. """Returns a filename for storing information locally
  11. Typically this is ``~/.silverlining/<path>``
  12. """
  13. assert not is_production()
  14. path = os.path.join(os.environ['HOME'], '.silverlining', path)
  15. path_dir = os.path.dirname(path)
  16. if not os.path.exists(path_dir):
  17. os.makedirs(path_dir)
  18. return path