def build(argv): """ Configure and build files. """ defaults = dict(build=True, genconf=True, **miniascape.options.M_DEFAULTS) p = miniascape.options.option_parser(defaults) p.add_option("--no-build", action="store_false", dest="build", help="Do not build, generate ks.cfg, vm build scripts, etc.") p.add_option("--no-genconf", action="store_false", dest="genconf", help="Do not generate config from context files") (options, args) = p.parse_args(argv) miniascape.globals.set_loglevel(options.verbose) options = miniascape.options.tweak_options(options) # suppress logs from anyconfig unless the environment variable # 'ANYCONFIG_DEBUG' is set to 1. if os.environ.get("ANYCONFIG_DEBUG", None) != '1': anyconfig.set_loglevel(logging.WARN) # configure if options.genconf: confdir = miniascape.site.configure(options.ctxs, options.tmpldir, options.workdir, options.site) if not options.build: return # ... and build (generate all). cf = miniascape.config.ConfFiles(confdir) miniascape.host.gen_host_files(cf, options.tmpldir, options.workdir, True) miniascape.guest.gen_all(cf, options.tmpldir, options.workdir)
import os import anyconfig import copy import logging from playhouse.postgres_ext import PostgresqlExtDatabase from rq import Queue from elasticsearch import Elasticsearch from redis import StrictRedis from functools import lru_cache # Throttle logging. logging.getLogger("elasticsearch.trace").propagate = False anyconfig.set_loglevel("WARNING") class Config: @classmethod def from_env(cls): """ Get a config instance with the default file precedence. """ return cls([os.path.join(os.path.dirname(__file__), "osp.yml"), "/etc/osp/osp.yml"]) def __init__(self, paths): """ Initialize the configuration object.
import os import anyconfig import logging from rq import Queue from elasticsearch import Elasticsearch from redis import StrictRedis # Throttle logging. logging.getLogger('elasticsearch.trace').propagate = False anyconfig.set_loglevel('WARNING') class Config: @classmethod def from_env(cls): """ Get a config instance with the default file precedence. """ return cls([ os.path.join(os.path.dirname(__file__), 'london.yml'), '~/.london.yml', ])
import miniascape.site as TT import miniascape.tests.common as C import anyconfig import logging import os.path import unittest PKGDIR = os.path.join(C.selfdir(), "..", "..") CTXS = [os.path.join(PKGDIR, "conf/default", "*.yml")] TMPLDIR = os.path.join(PKGDIR, "templates") # Suppress verbose logging messages from anyconfig. anyconfig.set_loglevel(logging.WARN) class Test_00_effectful_functions(unittest.TestCase): def setUp(self): self.workdir = C.setup_workdir() def tearDown(self): C.cleanup_workdir(self.workdir) def test_10_gen_site_conf_files(self): conf = anyconfig.load(CTXS) tmpldirs = [TMPLDIR] confdir = TT.gen_site_conf_files(conf, tmpldirs, self.workdir)
# along with this program. If not, see <http://www.gnu.org/licenses/>. # import miniascape.site as TT import miniascape.tests.common as C import anyconfig import logging import os.path import unittest PKGDIR = os.path.join(C.selfdir(), "..", "..") CTXS = [os.path.join(PKGDIR, "conf/default", "*.yml")] TMPLDIR = os.path.join(PKGDIR, "templates") # Suppress verbose logging messages from anyconfig. anyconfig.set_loglevel(logging.WARN) class Test_00_effectful_functions(unittest.TestCase): def setUp(self): self.workdir = C.setup_workdir() def tearDown(self): C.cleanup_workdir(self.workdir) def test_10_gen_site_conf_files(self): conf = anyconfig.load(CTXS) tmpldirs = [TMPLDIR] confdir = TT.gen_site_conf_files(conf, tmpldirs, self.workdir)
''' metrique.utils ~~~~~~~~~~~~~~ This module contains utility functions shared between metrique sub-modules. ''' from __future__ import unicode_literals, absolute_import import logging logger = logging.getLogger('metrique') try: import anyconfig anyconfig.set_loglevel(logging.WARN) # too noisy... HAS_ANYCONFIG = True except ImportError: HAS_ANYCONFIG = False logger.warn('anyconfig module is not installed!') from calendar import timegm from collections import defaultdict, Mapping, OrderedDict from copy import copy import cPickle import cProfile as profiler import csv from datetime import datetime, date try: from dateutil.parser import parse as dt_parse
import os import anyconfig import copy import logging from playhouse.postgres_ext import PostgresqlExtDatabase from rq import Queue from elasticsearch import Elasticsearch from redis import StrictRedis # Throttle logging. logging.getLogger('elasticsearch.trace').propagate = False anyconfig.set_loglevel('WARNING') class Config: @classmethod def from_env(cls): """ Get a config instance with the default file precedence. """ return cls([ os.path.join(os.path.dirname(__file__), 'osp.yml'), '/etc/osp/osp.yml', ]) def __init__(self, paths): """ Initialize the configuration object.
~~~~~~~~~~~~~~ This module contains utility functions shared between metrique sub-modules. """ from __future__ import unicode_literals, absolute_import import logging logger = logging.getLogger("metrique") try: import anyconfig anyconfig.set_loglevel(logging.WARN) # too noisy... HAS_ANYCONFIG = True except ImportError: HAS_ANYCONFIG = False logger.warn("anyconfig module is not installed!") from calendar import timegm from collections import defaultdict, Mapping, OrderedDict from copy import copy import cPickle import cProfile as profiler import csv from datetime import datetime, date try: from dateutil.parser import parse as dt_parse