def __init__(self, buildout, name, options): self.buildout = buildout self.name = name self.options = options self.logger = logging.getLogger(self.name) # Preprocess some variables self.interpreter = options.setdefault('interpreter', 'gdb-python') self.newest = bool_option(buildout['buildout'], 'newest') self.offline = bool_option(buildout['buildout'], 'offline') self.options['bin-directory'] = buildout['buildout']['bin-directory'] # Gets a personalized eggs list or the one from buildout self.eggs = tools.parse_list(options.get('eggs', '')) if not self.eggs: self.eggs = tools.parse_list(buildout['buildout'].get('eggs', '')) if not self.eggs: # Cannot proceed without eggs... raise MissingOption("Referenced option does not exist for section nor it could be found on the global 'buildout' section:", name, 'eggs') # Gets a personalized prefixes list or the one from buildout prefixes = tools.parse_list(options.get('prefixes', '')) if not prefixes: prefixes = tools.parse_list(buildout['buildout'].get('prefixes', '')) prefixes = [os.path.abspath(k) for k in prefixes if os.path.exists(k)] # Builds an environment wrapper, in case dependent packages need to be # compiled self.envwrapper = EnvironmentWrapper(self.logger, bool_option(options, 'debug', 'false'), prefixes) # Computes the final user paths that need consideration, set that back on # the buildout section self.user_paths = [] if prefixes: for k in prefixes: for suffix in SUFFIXES: candidate = os.path.realpath(os.path.join(k, suffix)) if os.path.exists(candidate) and candidate not in self.user_paths: self.user_paths.append(candidate) # Shall we panic or ignore if we cannot find all eggs? self.panic = options.get('error-on-failure', 'true').lower() == 'true' # initializes the script infrastructure super(Recipe, self).__init__(buildout, name, options)
def working_set(self, extra=()): """Separate method to just get the working set This is intended for reuse by similar recipes. """ options = self.options buildout_section = self.buildout['buildout'] # Backward compat. :( options['executable'] = sys.executable orig_distributions = [ r.strip() for r in options.get('eggs', self.name).split('\n') if r.strip() ] ws = self._working_set( distributions=orig_distributions + list(extra), develop_eggs_dir=options['develop-eggs-directory'], eggs_dir=options['eggs-directory'], offline=(buildout_section.get('offline') == 'true'), newest=(buildout_section.get('newest') == 'true'), links=self.links, index=self.index, allow_hosts=self.allow_hosts, allow_unknown_extras=bool_option(buildout_section, 'allow-unknown-extras')) return orig_distributions, ws
def make_scripts(self, extra_paths, ws): scripts = [] _script_template = zc.buildout.easy_install.script_template for protocol in ('wsgi', 'fcgi'): zc.buildout.easy_install.script_template = \ zc.buildout.easy_install.script_header + \ script_template[protocol] if self.options.get(protocol, '').lower() == 'true': project = self.options.get('projectegg', self.options['project']) scripts.extend( zc.buildout.easy_install.scripts( [('%s.%s' % (self.options.get('control-script', self.name), protocol), 'djangorecipe.%s' % protocol, 'main')], ws, sys.executable, self.options['bin-directory'], extra_paths=extra_paths, relative_paths = ( bool_option(self.buildout['buildout'] , 'relative-paths', False) and self.buildout['buildout']['directory'] or ''), arguments="'%s.%s', logfile='%s'" % ( project, self.options['settings'], self.options.get('logfile')), initialization=self.options['initialization'])) zc.buildout.easy_install.script_template = _script_template return scripts
def unsatisfied_requirements(buildout, package, working_set): """Reads and extracts the unsatisfied requirements from the package """ # read all lines from "requirements.txt" specs = [k.strip() for k in package_readlines(package, 'requirements.txt')] # discard empty lines and comments specs = [k for k in specs if k and k[0] not in ('#', '-')] # do not consider packages which are already installed, with a reasonable # version matching the user specification, either on the current working # set, the installed eggs or the system paths newest = bool_option(buildout, 'newest', 'true') left_over = [] for k in specs: if requirement_is_satisfied(k, working_set, newest): dist = working_set.require(k)[0] logger.info("taking requirement `%s' (%s) from `%s'", dist.key, dist.version, dist.location) else: left_over.append(k) specs = left_over return left_over
def working_set(self, extra=()): """Separate method to just get the working set This is intended for reuse by similar recipes. """ options = self.options buildout_section = self.buildout['buildout'] # Backward compat. :( options['executable'] = sys.executable orig_distributions = [ r.strip() for r in options.get('eggs', self.name).split('\n') if r.strip() ] ws = self._working_set( distributions=orig_distributions + list(extra), develop_eggs_dir=options['develop-eggs-directory'], eggs_dir=options['eggs-directory'], offline=(buildout_section.get('offline') == 'true'), newest=(buildout_section.get('newest') == 'true'), links=self.links, index=self.index, allow_hosts=self.allow_hosts, allow_unknown_extras=bool_option(buildout_section, 'allow-unknown-extras') ) return orig_distributions, ws
def make_scripts(self, extra_paths, ws): scripts = [] _script_template = zc.buildout.easy_install.script_template for protocol in ('wsgi', 'fcgi'): zc.buildout.easy_install.script_template = \ zc.buildout.easy_install.script_header + \ script_template[protocol] if self.options.get(protocol, '').lower() == 'true': project = self.options.get('projectegg', self.options['project']) scripts.extend( zc.buildout.easy_install.scripts( [('%s.%s' % (self.options.get('control-script', self.name), protocol), 'djangorecipe.%s' % protocol, 'main')], ws, sys.executable, self.options['bin-directory'], extra_paths=extra_paths, relative_paths=(bool_option( self.buildout['buildout'], 'relative-paths', False) and self.buildout['buildout']['directory'] or ''), arguments="'%s.%s', logfile='%s'" % (project, self.options['settings'], self.options.get('logfile')), initialization=self.options['initialization'])) zc.buildout.easy_install.script_template = _script_template return scripts
def __init__(self, buildout, name, options): self.name, self.options = name, options self.logger = logging.getLogger(self.name) self.buildout = buildout # finds the setup script or use the default self.setup = os.path.join(buildout['buildout']['directory'], options.get('setup', '.')) # some fine-tunning if os.path.isdir(self.setup): self.directory = self.setup self.setup = os.path.join(self.directory, 'setup.py') else: self.directory = os.path.dirname(self.setup) # where to place the egg self.dest = self.buildout['buildout']['develop-eggs-directory'] # the eggs we need to **build** this package eggs = tools.parse_list(options.get('eggs', '')) required_eggs = [ 'xbob.extension', # basic extension building using pkg-config + Bob ] eggs += required_eggs eggs = tools.uniq(eggs) # generates the script that will work as the "builder" builder_options = self.options.copy() builder_options['eggs'] = '\n'.join(eggs) name = self.options.get('interpreter', 'xpython.builder') builder_options['interpreter'] = name self.builder = PythonInterpreter(buildout, name, builder_options) self.debug = bool_option(options, 'debug', bool_option(self.buildout['buildout'], 'debug', 'false')) self.verbose = bool_option(options, 'verbose', bool_option(self.buildout['buildout'], 'verbose', 'false')) # gets a personalized prefixes list or the one from buildout prefixes = tools.parse_list(options.get('prefixes', '')) if not prefixes: prefixes = tools.parse_list(buildout['buildout'].get('prefixes', '')) self.envwrapper = EnvironmentWrapper(self.logger, self.debug, prefixes)
def create_manage_script(self, extra_paths, ws): project = self.options.get('projectegg', self.options['project']) return zc.buildout.easy_install.scripts( [(self.options.get('control-script', self.name), 'djangorecipe.manage', 'main')], ws, sys.executable, self.options['bin-directory'], relative_paths = ( bool_option(self.buildout['buildout'] , 'relative-paths', False) and self.buildout['buildout']['directory'] or ''), extra_paths=extra_paths, arguments="'%s.%s'" % (project, self.options['settings']), initialization=self.options['initialization'])
def __init__(self, buildout, name, options): self.buildout, self.name, self.options = buildout, name, options b_options = buildout['buildout'] self.name = options.get('name', name) self.options['name'] = self.name self.logger = logging.getLogger(self.name) # deployment layout def add_section(section_name, options): if section_name in buildout._raw: raise KeyError("already in buildout", section_name) buildout._raw[section_name] = options buildout[section_name] # cause it to be added to the working parts self.deployment_name = self.name + "-celery-deployment" self.deployment = zc.recipe.deployment.Install(buildout, self.deployment_name, { 'name': "celery", 'prefix': self.options.get('prefix'), 'user': self.options.get('user'), 'etc-user': self.options.get('etc-user')}) add_section(self.deployment_name, self.deployment.options) self.options['user'] = self.deployment.options['user'] self.options['etc-user'] = self.deployment.options['etc-user'] self.options['etc-prefix'] = self.options['etc_prefix'] = self.deployment.options['etc-prefix'] self.options['var-prefix'] = self.options['var_prefix'] = self.deployment.options['var-prefix'] self.options['etc-directory'] = self.options['etc_directory'] = self.deployment.options['etc-directory'] self.options['log-directory'] = self.options['log_directory'] = self.deployment.options['log-directory'] self.options['run-directory'] = self.options['run_directory'] = self.deployment.options['run-directory'] self.options['cache-directory'] = self.options['cache_directory'] = self.deployment.options['cache-directory'] self.options['bin-directory'] = self.options['bin_directory'] = b_options['bin-directory'] self.prefix = self.options['prefix'] # conda environment path self.options['env'] = self.options.get('env', '') self.options['pkgs'] = self.options.get('pkgs', 'celery redis-py pymongo') self.options['channels'] = self.options.get('channels', 'defaults birdhouse') self.conda = birdhousebuilder.recipe.conda.Recipe(self.buildout, self.name, { #'prefix': self.options.get('conda-prefix', ''), 'env': self.options['env'], 'pkgs': self.options['pkgs'], 'channels': self.options['channels']}) self.options['conda-prefix'] = self.options['conda_prefix'] = self.conda.options['prefix'] # celery options self.options['app'] = options.get('app', 'myapp') self.use_celeryconfig = bool_option(self.options, 'use-celeryconfig', True) self.options['broker-url'] = self.options.get('broker-url', 'redis://localhost:6379/0') self.options['celery-result-backend'] = self.options.get('celery-result-backend', 'redis://localhost:6379/0') self.options['loglevel'] = self.options.get('loglevel', 'WARNING')
def create_manage_script(self, extra_paths, ws): project = self.options.get('projectegg', self.options['project']) return zc.buildout.easy_install.scripts( [(self.options.get('control-script', self.name), 'djangorecipe.manage', 'main')], ws, sys.executable, self.options['bin-directory'], relative_paths=( bool_option(self.buildout['buildout'], 'relative-paths', False) and self.buildout['buildout']['directory'] or ''), extra_paths=extra_paths, arguments="'%s.%s'" % (project, self.options['settings']), initialization=self.options['initialization'])
def __init__(self, buildout, name, options): self.options = options options['entry'] = '%s\t%s' % (options['times'], options['command']) self.comment = options.get('comment') if not bool_option(self.options, 'enabled', default=True): self.options['entry'] = '# ' + self.options['entry'] # readcrontab and writecrontab are solely for testing. readcrontab = self.options.get('readcrontab', None) writecrontab = self.options.get('writecrontab', None) self.options['identifier'] = '%s [%s]' % ( buildout['buildout']['directory'], name) self.crontab = UserCrontabManager( readcrontab, writecrontab, identifier=self.options['identifier'])
def install_package(buildout, specification, working_set): """Installs a package on either the eggs directory or development-eggs directory. Updates the working set""" new_ws = zc.buildout.easy_install.install( specs = [specification], dest = buildout['eggs-directory'], links = buildout.get('find-links', '').split(), index = buildout.get('index', None), path = [buildout['develop-eggs-directory']], working_set = working_set, newest = bool_option(buildout, 'newest', 'true'), ) merge_working_sets(working_set, new_ws) return working_set
def install_package(buildout, specification, working_set): """Installs a package on either the eggs directory or development-eggs directory. Updates the working set""" new_ws = zc.buildout.easy_install.install( specs=[specification], dest=buildout['eggs-directory'], links=buildout.get('find-links', '').split(), index=buildout.get('index', None), path=[buildout['develop-eggs-directory']], working_set=working_set, newest=bool_option(buildout, 'newest', 'true'), ) merge_working_sets(working_set, new_ws) return working_set
def create_test_runner(self, extra_paths, working_set): apps = self.options.get('test', '').split() # Only create the testrunner if the user requests it if apps: return zc.buildout.easy_install.scripts( [(self.options.get('testrunner', 'test'), 'djangorecipe.test', 'main')], working_set, sys.executable, self.options['bin-directory'], extra_paths=extra_paths, relative_paths = ( bool_option(self.buildout['buildout'] , 'relative-paths', False) and self.buildout['buildout']['directory'] or ''), arguments="'%s.%s', %s" % ( self.options['project'], self.options['settings'], ', '.join(["'%s'" % app for app in apps])), initialization=self.options['initialization']) else: return []
def create_test_runner(self, extra_paths, working_set): apps = self.options.get('test', '').split() # Only create the testrunner if the user requests it if apps: return zc.buildout.easy_install.scripts( [(self.options.get('testrunner', 'test'), 'djangorecipe.test', 'main')], working_set, sys.executable, self.options['bin-directory'], extra_paths=extra_paths, relative_paths=(bool_option(self.buildout['buildout'], 'relative-paths', False) and self.buildout['buildout']['directory'] or ''), arguments="'%s.%s', %s" % (self.options['project'], self.options['settings'], ', '.join( ["'%s'" % app for app in apps])), initialization=self.options['initialization']) else: return []
def __init__(self, buildout, name, options): self.buildout, self.name, self.options = buildout, name, options b_options = buildout['buildout'] self.name = options.get('name', name) self.options['name'] = self.name self.logger = logging.getLogger(self.name) # buildout option anaconda-home overwrites default anaconda path # TODO: do i realy need this? # TODO: guess with "which conda"? b_options['anaconda-home'] = b_options.get( 'anaconda-home', join(os.environ.get('HOME', '/opt'), 'anaconda')) self.anaconda_home = b_options['anaconda-home'] # conda prefix # either prefix option or CONDA_PREFIX (set by conda env) or # anaconda_home # TODO: check if prefix is a valid argument (not '' or None) self.prefix = self.options.get( 'prefix', os.environ.get('CONDA_PREFIX', os.environ.get('CONDA_ENV_PATH', b_options['anaconda-home']))) # env option can be overwritten by buildout conda-env option self.env = self.options.get('env', b_options.get('conda-env', '')) self.options['env'] = self.env if self.env: self.prefix = conda_envs(self.anaconda_home).get(self.env, self.prefix) self.options['prefix'] = self.prefix # Offline mode, don't connect to the Internet. self.offline = bool_option(b_options, 'offline', False) if not self.offline: self.offline = bool_option(b_options, 'conda-offline', False) # Newest mode, don't update dependencies self.newest = bool_option(b_options, 'newest', True) # Do not search default or .condarc channels. Requires channels. self.override_channels = bool_option( b_options, 'override-channels', True) # Ignore pinned file. self.no_pin = bool_option(b_options, 'no-pin', False) # channels option or buildout conda-channels option self.channels = split_args(b_options.get('conda-channels', 'defaults')) self.logger.debug('buildout conda channels %s', self.channels) # buildout channels are overwritten by recipe channels recipe_channels = split_args(self.options.get('channels', '')) if recipe_channels: self.channels = recipe_channels # make channel list unique self.channels = [channel for n, channel in enumerate(self.channels) if channel not in self.channels[:n]] self.logger.debug('unique conda channels %s', self.channels) # channel priority self.channel_priority = bool_option( b_options, 'channel-priority', True) # packages self.default_pkgs = split_args( self.options.get('default-pkgs', 'python=2 pip')) self.pkgs = split_args(options.get('pkgs')) self.pip_pkgs = split_args(options.get('pip'))
def prefer_final(buildout): return bool_option(buildout, 'prefer-final', 'true')
def verbose(buildout): return bool_option(buildout, 'verbose', 'false')
def debug(buildout): return bool_option(buildout, 'debug', 'false')
def newest(buildout): return bool_option(buildout, 'newest', 'true')
def offline(buildout): return bool_option(buildout, 'offline', 'false')
def __init__(self, buildout, name, options): self.buildout, self.name, self.options = buildout, name, options b_options = buildout['buildout'] self.name = options.get('name', name) self.options['name'] = self.name self.logger = logging.getLogger(self.name) # deployment layout def add_section(section_name, options): if section_name in buildout._raw: raise KeyError("already in buildout", section_name) buildout._raw[section_name] = options buildout[section_name] # cause it to be added to the working parts self.prefix = self.options.get('prefix', '') if not self.prefix: self.prefix = b_options['parts-directory'] self.options['prefix'] = self.prefix user = self.options.get('user', '') if not user: user = os.environ['USER'] self.options['user'] = user etc_user = self.options.get('etc-user', '') if not etc_user: etc_user = user self.options['etc-user'] = etc_user self.deployment_name = self.name + "-pywps-deployment" self.deployment = zc.recipe.deployment.Install(buildout, self.deployment_name, { 'name': "pywps", 'prefix': self.options['prefix'], 'user': self.options['user'], 'etc-user': self.options['etc-user']}) add_section(self.deployment_name, self.deployment.options) self.options['etc-prefix'] = self.deployment.options['etc-prefix'] self.options['var-prefix'] = self.options['var_prefix'] = self.deployment.options['var-prefix'] self.options['etc-directory'] = self.deployment.options['etc-directory'] self.options['lib-directory'] = self.options['lib_directory'] = self.deployment.options['lib-directory'] self.options['log-directory'] = self.options['log_directory'] = self.deployment.options['log-directory'] self.options['run-directory'] = self.options['run_directory'] = self.deployment.options['run-directory'] self.options['cache-directory'] = self.options['cache_directory'] = self.deployment.options['cache-directory'] self.prefix = self.options['prefix'] # conda environment self.options['env'] = self.options.get('env', '') self.options['pkgs'] = self.options.get('pkgs', 'pywps gunicorn gevent') self.options['channels'] = self.options.get('channels', 'defaults birdhouse') self.conda = birdhousebuilder.recipe.conda.Recipe(self.buildout, self.name, { 'env': self.options['env'], 'pkgs': self.options['pkgs'], 'channels': self.options['channels']}) self.options['conda-prefix'] = self.options['conda_prefix'] = self.conda.options['prefix'] # nginx options self.options['hostname'] = self.options.get('hostname', 'localhost') if bool_option(self.options, 'enable-https', False): self.options['enable_https'] = 'true' enable_https = True else: self.options['enable_https'] = 'false' enable_https = False self.options['http-port'] = self.options['http_port'] = self.options.get('http-port', '8091') self.options['https-port'] = self.options['https_port'] = self.options.get('https-port', '28091') self.options['http-output-port'] = self.options['http_output_port'] = \ self.options.get('http-output-port', self.options.get('output-port', '8090')) self.options['https-output-port'] = self.options['https_output_port'] = \ self.options.get('https-output-port', '28090') self.options['ssl-verify-client'] = self.options['ssl_verify_client'] = \ self.options.get('ssl-verify-client', 'off') self.options['ssl-client-certificate'] = self.options['ssl_client_certificate'] = \ self.options.get('ssl-client-certificate', 'esgf-ca-bundle.crt') self.options['ssl-client-certificate-url'] = self.options['ssl_client_certificate_url'] = \ self.options.get( 'ssl-client-certificate-url', 'https://github.com/ESGF/esgf-dist/raw/master/installer/certs/esgf-ca-bundle.crt') # set url and outputurl if enable_https: url = "https://{}:{}/wps".format( self.options['hostname'], self.options['https_port']) outputurl = "https://{}:{}/wpsoutputs/{}/".format( self.options['hostname'], self.options['https_output_port'], self.options['name']) else: url = "http://{}:{}/wps".format( self.options['hostname'], self.options['http_port']) outputurl = "http://{}:{}/wpsoutputs/{}/".format( self.options['hostname'], self.options['http_output_port'], self.options['name']) # allow to overwrite url and outputurl self.options['url'] = self.options.get('url', url) self.options['outputurl'] = self.options.get('outputurl', outputurl) # gunicorn options output_path = os.path.join( self.options['lib-directory'], 'outputs', self.name) self.options['home'] = self.options.get('home', output_path) self.options['workers'] = options.get('workers', '1') self.options['worker-class'] = self.options['worker_class'] = options.get('worker-class', 'gevent') self.options['timeout'] = options.get('timeout', '30') self.options['loglevel'] = options.get('loglevel', 'info') # pywps options self.options['application'] = options.get('application', self.name + ':application') self.options['title'] = options.get('title', 'PyWPS Server') self.options['abstract'] = options.get( 'abstract', 'See http://pywps.org/') self.options['provider_name'] = self.options['provider-name'] = self.options.get('provider-name', '') self.options['city'] = self.options.get('city', '') self.options['country'] = self.options.get('country', '') self.options['provider_url'] = self.options['provider-url'] = self.options.get('provider-url', '') self.options['loglevel'] = self.options.get('loglevel', 'WARN') self.options['logformat'] = self.options.get( 'logformat', '%(asctime)s] [%(levelname)s] line=%(lineno)s module=%(module)s %(message)s') self.options['parallelprocesses'] = self.options.get('parallelprocesses', '2') self.options['maxprocesses'] = self.options.get('maxprocesses', '30') self.options['maxinputparamlength'] = self.options.get('maxinputparamlength', '1024') self.options['maxsingleinputsize'] = self.options.get('maxsingleinputsize', '30mb') self.options['maxrequestsize'] = self.options.get('maxrequestsize', '30mb') self.options['database'] = self.options.get('database', 'sqlite') root_cache_path = os.path.join(self.options['lib-directory'], 'cache') self.options['allowedinputpaths'] = self.options.get('allowedinputpaths', root_cache_path) self.options['sethomedir'] = self.options.get('sethomedir', 'true') self.options['setworkdir'] = self.options.get('setworkdir', 'true') # processing options self.options['mode'] = self.options.get('mode', 'default') self.options['path'] = self.options.get('path', '') # extra options self.extra_options = parse_extra_options(self.options.get('extra-options', '')) self.options['bin-directory'] = self.options['bin_directory'] = b_options.get('bin-directory') self.options['directory'] = b_options.get('directory') # make dirs make_dirs(output_path, self.options['user']) make_dirs(self.options['home'], self.options['user']) tmp_path = os.path.join( self.options['lib-directory'], 'tmp', self.name) make_dirs(tmp_path, self.options['user']) cache_path = os.path.join(root_cache_path, self.name) make_dirs(cache_path, self.options['user']) db_path = os.path.join( self.options['lib-directory'], 'db', self.name) make_dirs(db_path, self.options['user'])
def __init__(self, buildout, name, options): self.buildout, self.name, self.options = buildout, name, options b_options = buildout['buildout'] self.name = options.get('name', name) self.options['name'] = self.name self.logger = logging.getLogger(self.name) # deployment layout def add_section(section_name, options): if section_name in buildout._raw: raise KeyError("already in buildout", section_name) buildout._raw[section_name] = options buildout[section_name] # cause it to be added to the working parts self.deployment_name = self.name + "-supervisor-deployment" self.deployment = zc.recipe.deployment.Install(buildout, self.deployment_name, { 'name': "supervisor", 'prefix': self.options.get('prefix'), 'user': self.options.get('user'), 'etc-user': self.options.get('etc-user')}) add_section(self.deployment_name, self.deployment.options) self.options['user'] = self.deployment.options['user'] self.options['home'] = os.path.expanduser('~' + self.options['user']) self.options['etc-user'] = self.deployment.options['etc-user'] self.options['etc-prefix'] = self.options['etc_prefix'] = self.deployment.options['etc-prefix'] self.options['var-prefix'] = self.options['var_prefix'] = self.deployment.options['var-prefix'] self.options['etc-directory'] = self.options['etc_directory'] = self.deployment.options['etc-directory'] self.options['log-directory'] = self.options['log_directory'] = self.deployment.options['log-directory'] self.options['run-directory'] = self.options['run_directory'] = self.deployment.options['run-directory'] self.options['cache-directory'] = self.options['cache_directory'] = self.deployment.options['cache-directory'] self.options['bin-directory'] = b_options['bin-directory'] self.prefix = self.options['prefix'] # conda environment path self.options['env'] = self.options.get('env', '') self.options['pkgs'] = self.options.get('pkgs', 'supervisor') self.options['channels'] = self.options.get('channels', 'defaults') self.conda = birdhousebuilder.recipe.conda.Recipe(self.buildout, self.name, { #'prefix': self.options.get('conda-prefix', ''), 'env': self.options['env'], 'pkgs': self.options['pkgs'], 'channels': self.options['channels']}) self.options['conda-prefix'] = self.options['conda_prefix'] = self.conda.options['prefix'] bin_path = os.path.join(self.options['conda-prefix'], 'bin') lib_path = os.path.join(self.options['conda-prefix'], 'lib') # buildout options used for supervisord.conf self.options['host'] = b_options.get('supervisor-host', '127.0.0.1') self.options['port'] = b_options.get('supervisor-port', '9001') self.options['username'] = b_options.get('supervisor-username', '') self.options['password'] = b_options.get('supervisor-password', '') use_monitor = bool_option(b_options, 'supervisor-use-monitor', True) self.options['use-monitor'] = self.options['use_monitor'] = 'true' if use_monitor else 'false' self.options['loglevel'] = b_options.get('supervisor-loglevel', 'info') # options used for program config self.program = self.options.get('program', name) logfile = os.path.join(self.options['log-directory'], self.program + ".log") # set default options skip_user = bool_option(self.options, 'skip-user', False) self.options['skip-user'] = self.options['skip_user'] = '******' if skip_user else 'false' # TODO: fix usage of directory ... currently searches for wpsapp.py self.options['directory'] = self.options.get('directory', bin_path) self.options['priority'] = self.options.get('priority', '999') self.options['autostart'] = self.options.get('autostart', 'true') self.options['autorestart'] = self.options.get('autorestart', 'false') self.options['stdout-logfile'] = self.options['stdout_logfile'] = self.options.get('stdout-logfile', logfile) self.options['stderr-logfile'] = self.options['stderr_logfile'] = self.options.get('stderr-logfile', logfile) self.options['startsecs'] = self.options.get('startsecs', '1') self.options['numprocs'] = self.options.get('numprocs', '1') self.options['stopwaitsecs'] = self.options.get('stopwaitsecs', '10') self.options['stopasgroup'] = self.options.get('stopasgroup', 'false') self.options['killasgroup'] = self.options.get('killasgroup', 'true') self.options['stopsignal'] = self.options.get('stopsignal', 'TERM') env_templ = \ 'USER={0},LOGNAME={0},HOME={1},PATH="/bin:/usr/bin:{2}",PYTHON_EGG_CACHE="{3}"' self.options['environment'] = self.options.get( 'environment', env_templ.format(self.options['user'], self.options['home'], bin_path, self.options['cache-directory']))