Example #1
0
def new_config(args=None):
    if args is None:
        args = RuntimeStateConfig()

        return fetch_config(args)
    else:
        return args
Example #2
0
 def setUp(self):
     self.c = Configuration()
     self.c.runstate = RuntimeStateConfig()
     self.task = MapTask()
     self.task.job = sum
     self.Task = MapTask
     self.task.conf = self.c
Example #3
0
 def setUp(self):
     self.c = Configuration()
     self.c.runstate = RuntimeStateConfig()
     self.c.state['git'] = giza.config.git.GitConfig({}, self.c,
                                                     os.getcwd())
     self.setUpClasses()
     self.create_data()
Example #4
0
def main():
    """
    The main entry point, as specified in the ``setup.py`` file. Adds commands
    from other subsidiary entry points (specified in the ``commands`` variable
    above,) and then uses ``arch.dispatch()`` to start the process.

    The ``RuntimeStateConfig()`` object is created here and handed to the parser
    as the object that will recive all command line data, rather than using a
    standard argparse namespace object. This allows all runtime argument parsing
    to happen inside of these config objects rather than spread among all of the
    entry points.

    This function catches and recovers from :exc:`KeyboardInterupt` which means
    that doesn't dump a stack trace following a Control-C.
    """

    parser = get_base_parser()

    for namespace, entry_points in commands.items():
        if namespace == 'main':
            argh.add_commands(parser, entry_points)
        else:
            argh.add_commands(parser, entry_points, namespace=namespace)

    args = RuntimeStateConfig()
    try:
        argh.dispatch(parser, namespace=args)
    except KeyboardInterrupt:
        logger.error('operation interrupted by user.')
Example #5
0
    def test_configuration_object_validation_acceptance(self):
        for i in [self.c, Configuration(), RuntimeStateConfig()]:
            t = self.Task()

            self.assertIsNone(t.conf)
            t.conf = i
            self.assertIs(i, t.conf)
Example #6
0
    def setUp(self):
        self.c = Configuration()
        self.c.runstate = RuntimeStateConfig()
        self.c.paths = {'includes': os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                                 'data-inheritance')}
        self.DataCache = DataCache

        self.create_data()
Example #7
0
def new_skeleton_config(conf=None):
    if conf is None:
        conf = Configuration()
        args = RuntimeStateConfig()
        conf.runstate = args

        return conf
    else:
        return conf
Example #8
0
    def setUp(self):
        self.c = Configuration()
        self.c.runstate = RuntimeStateConfig()
        self.c.paths = {'includes': get_test_file_path()}

        self.DataContentBase = DataContentBase
        self.DataCache = DataCache

        self.create_data()
Example #9
0
    def setUp(self):
        self.c = Configuration()
        self.c.runstate = RuntimeStateConfig()
        self.c.paths = {
            'includes':
            os.path.join(os.path.abspath(os.path.dirname(__file__)),
                         'data-inheritance')
        }

        self.data = DummyCache([], self.c)
Example #10
0
def new_config(args=None):
    if args in (None, True, False):
        args = RuntimeStateConfig()

        return fetch_config(args)
    elif isinstance(args, RuntimeStateConfig):
        return fetch_config(args)
    elif isinstance(args, Configuration):
        return args
    else:
        raise ConfigurationError
Example #11
0
def main():
    try:
        from giza.config.helper import fetch_config
        from giza.config.runtime import RuntimeStateConfig
        conf = fetch_config(RuntimeStateConfig())
    except:
        conf = get_conf()

    m = generate_meta(conf)

    m.write(sys.argv[1])
    print('[meta-build]: built "' + sys.argv[1] + '" to seed build metadata.')
Example #12
0
def main():
    parser = get_base_parser()

    for namespace, entry_points in commands.items():
        if namespace == 'main':
            argh.add_commands(parser, entry_points)
        else:
            argh.add_commands(parser, entry_points, namespace=namespace)

    args = RuntimeStateConfig()
    try:
        argh.dispatch(parser, namespace=args)
    except KeyboardInterrupt:
        logger.error('operation interrupted by user.')
Example #13
0
    def setUp(self):
        self.c = Configuration()
        self.c.runstate = RuntimeStateConfig()
        self.c.paths = {'includes': 'data-inheritance',
                        'projectroot': os.path.abspath(os.path.dirname(__file__))}

        self.DataContentBase = DataContentBase
        self.DataCache = DataCache
        self.InheritableContentBase = InheritableContentBase

        self.dummy_doc = {'ref': 'dummy-doc',
                          'pre': 'pre text'}

        self.create_data()
Example #14
0
def new_skeleton_config(conf=None):
    if conf is None:
        conf = Configuration()
        args = RuntimeStateConfig()
        conf.runstate = args

        try:
            register_content_generators(conf)
        except KeyError:
            logger.warning("cannot register content generators")

        return conf
    else:
        return conf
Example #15
0
    def setUp(self):
        self.c = Configuration()
        self.c.runstate = RuntimeStateConfig()
        self.c.paths = {
            'includes':
            os.path.join(os.path.abspath(os.path.dirname(__file__)),
                         'data-inheritance')
        }

        self.content_fn = get_inheritance_data_files()[0]

        self.data = DummyCache([], self.c)
        self.data.ingest([self.content_fn])

        self.content = self.data.cache[self.content_fn]
Example #16
0
def new_skeleton_config(conf=None):
    if conf is None:
        conf = Configuration()
        args = RuntimeStateConfig()
        conf.runstate = args

        try:
            register_content_generators(conf)
        except KeyError:
            logger.warning("trouble registering content generators")

        return conf
    elif isinstance(conf, RuntimeStateConfig):
        return fetch_config(conf)
    else:
        return conf
Example #17
0
 def runstate(self, value):
     if isinstance(value, RuntimeStateConfig):
         if 'runstate' in self.state:
             self.state['runstate'].state.update(value.state)
         else:
             value.conf = self
             self.state['runstate'] = value
     elif isinstance(value, dict):
         if 'runstate' in self.state:
             self.state['runstate'].ingest(value)
         else:
             runtime = RuntimeStateConfig(value)
             runtime.conf = self
             self.state['runstate'] = runtime
     elif value is None:
         runtime = RuntimeStateConfig()
         runtime.conf = self
         self.state['runstate'] = runtime
     else:
         msg = "invalid runtime state"
         logger.critical(msg)
         raise TypeError(msg)
Example #18
0
#
# MongoDB documentation build configuration file, created by
# sphinx-quickstart on Mon Oct  3 09:58:40 2011.
#
# This file is execfile()d with the current directory set to its containing dir.

import sys
import os
import datetime

from sphinx.errors import SphinxError

from giza.config.runtime import RuntimeStateConfig
from giza.config.helper import fetch_config, get_versions, get_manual_path

conf = fetch_config(RuntimeStateConfig())
sconf = conf.system.files.data.sphinx_local

sys.path.append(
    os.path.join(conf.paths.projectroot, conf.paths.buildsystem, 'sphinxext'))

try:
    tags
except NameError:

    class Tags(object):
        def has(self, *args):
            return False

    tags = Tags()
Example #19
0
 def setUp(self):
     self.c = Configuration()
     self.c.runstate = RuntimeStateConfig()
     self.app = BuildApp(self.c)
Example #20
0
 def setUp(self):
     self.c = Configuration()
     self.c.runstate = RuntimeStateConfig()
     self.app = BuildApp(self.c)
     self.app.default_pool = random.choice(['serial', 'thread'])
     self.app.pool_size = 2
Example #21
0
    def setUp(self):
        self.c = Configuration()
        self.c.runstate = RuntimeStateConfig()
        self.InheritableContentBase = InheritableContentBase

        self.create_data()
Example #22
0
    def setUp(self):
        self.c = Configuration()
        self.c.runstate = RuntimeStateConfig()

        self.data = DummyRecord({}, self.c)
        self.data.replacement = {'state': 'foo'}