PageRenderTime 236ms CodeModel.GetById 90ms app.highlight 8ms RepoModel.GetById 134ms app.codeStats 0ms

/silversupport/env.py

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