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