diff options
| -rw-r--r-- | cbc/environment.py | 38 | 
1 files changed, 26 insertions, 12 deletions
| diff --git a/cbc/environment.py b/cbc/environment.py index 0f0a9f9..d1b7d12 100644 --- a/cbc/environment.py +++ b/cbc/environment.py @@ -3,7 +3,14 @@ import time  from .exceptions import IncompleteEnv  from .parsers import CBCConfigParser, ExtendedInterpolation - +''' +[cbc_cgi] +local_server: true +local_port: 8888 +local_sources: /srv/conda/sources +protocol: http +url: ${cbc_cgi:protocol}://localhost:${cbc_cgi:local_port} +'''  class Environment(object):      def __init__(self, *args, **kwargs): @@ -14,10 +21,10 @@ class Environment(object):          self.pkgdir = None          self.rcpath = os.path.expanduser('~/.cbcrc')          self.configrc = None -         +          if 'CBC_HOME' in kwargs:              self.cbchome = kwargs['CBC_HOME'] -         +          # I want the local user environment to override what is          # passed to the class.          if 'CBC_HOME' in self.environ: @@ -27,40 +34,47 @@ class Environment(object):              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') +        self.configrc['cbc_cgi'] = {} +        self.configrc['cbc_cgi']['local_server'] = 'true' +        self.configrc['cbc_cgi']['local_port'] = '8888' +        self.configrc['cbc_cgi']['local_sources'] = os.path.expanduser('~') +        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 self.cbchome is None:              raise IncompleteEnv('CBC_HOME is undefined.') -         +          self.cbchome = os.path.abspath(self.cbchome)          if not os.path.exists(self.cbchome):              os.makedirs(self.cbchome) -         +      def _script_meta(self):          self.config['script'] = {}          self.config['script']['meta'] = self.join('meta.yaml')          self.config['script']['build_linux'] = self.join('build.sh')          self.config['script']['build_windows'] = self.join('bld.bat') -         +      def join(self, filename):          return os.path.abspath(os.path.join(self.pkgdir, filename)) -     +      def mkpkgdir(self, pkgname):          pkgdir = os.path.join(self.cbchome, pkgname) -         +          if not pkgname:              raise IncompleteEnv('Empty package name passed to {0}'.format(__name__))          if not os.path.exists(pkgdir):              os.mkdir(pkgdir) -             +          self.pkgdir = pkgdir          self._script_meta() -         -         + + | 
