diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-10-02 00:14:38 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-10-02 00:14:38 -0400 |
commit | d724953ee21bae030124513785977d1babc68e73 (patch) | |
tree | 00a50fb50ad3c7bc69f3db85518b4f96ca555f6e /cbc | |
parent | b0d463430e95bb01cc92e3584156cf8a152d2918 (diff) | |
parent | aca92f0cdc432e755fd6d7617e6e51489d14c733 (diff) | |
download | cbc-d724953ee21bae030124513785977d1babc68e73.tar.gz |
Merge branch 'master' of bitbucket.org:jhunkeler/cbc
Diffstat (limited to 'cbc')
-rw-r--r-- | cbc/environment.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/cbc/environment.py b/cbc/environment.py index d1b7d12..2603af2 100644 --- a/cbc/environment.py +++ b/cbc/environment.py @@ -20,7 +20,7 @@ class Environment(object): self.pwd = os.path.abspath(os.curdir) self.pkgdir = None self.rcpath = os.path.expanduser('~/.cbcrc') - self.configrc = None + self.configrc = CBCConfigParser(interpolation=ExtendedInterpolation()) if 'CBC_HOME' in kwargs: self.cbchome = kwargs['CBC_HOME'] @@ -30,17 +30,7 @@ class Environment(object): if 'CBC_HOME' in self.environ: self.cbchome = self.environ['CBC_HOME'] - if os.path.exists(self.rcpath): - if os.path.isfile(self.rcpath): - self.configrc = CBCConfigParser(interpolation=ExtendedInterpolation()) - self.configrc.read(self.rcpath) - - if 'settings' in self.configrc.sections(): - if 'path' in self.configrc['settings']: - self.cbchome = self.configrc['settings']['path'] - if not self.cbchome: - raise IncompleteEnv('.cbcrc empty path detected. Check: settings -> path') - + # A few hard-coded defaults pertaining to the seldom-used internal web server self.configrc['cbc_cgi'] = {} self.configrc['cbc_cgi']['local_server'] = 'true' self.configrc['cbc_cgi']['local_port'] = '8888' @@ -48,6 +38,16 @@ class Environment(object): self.configrc['cbc_cgi']['protocol'] = 'http' self.configrc['cbc_cgi']['url'] = '{0}://localhost:{1}'.format(self.configrc['cbc_cgi']['protocol'], self.configrc['cbc_cgi']['local_port']) + if os.path.exists(self.rcpath): + if os.path.isfile(self.rcpath): + self.configrc.read(self.rcpath) + + if 'settings' in self.configrc.sections(): + if 'path' in self.configrc['settings']: + self.cbchome = self.configrc['settings']['path'] + if not self.cbchome: + raise IncompleteEnv('.cbcrc empty path detected. Check: settings -> path') + if self.cbchome is None: raise IncompleteEnv('CBC_HOME is undefined.') |