当前位置: 首页>>代码示例>>Python>>正文


Python Glusto.show_config方法代码示例

本文整理汇总了Python中glusto.core.Glusto.show_config方法的典型用法代码示例。如果您正苦于以下问题:Python Glusto.show_config方法的具体用法?Python Glusto.show_config怎么用?Python Glusto.show_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在glusto.core.Glusto的用法示例。


在下文中一共展示了Glusto.show_config方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUpClass

# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import show_config [as 别名]
    def setUpClass(cls):
        """unittest standard setUpClass method
        Runs before all test_ methods in the class
        """
        print "Setting Up Class: %s" % cls.__name__
        # Setting class attributes for use across all test methods
        cls.yaml_file = '/tmp/testconfig.yml'
        cls.ini_file = '/tmp/testconfig.ini'
        cls.ini_ordered_file = '/tmp/testconfig_ordered.ini'

        cls.config = {}
        cls.config['defaults'] = {}
        cls.config['defaults']['this'] = 'yada1'
        cls.config['defaults']['that'] = 'yada2'
        cls.config['globals'] = {}
        cls.config['globals']['the_other'] = 'yada3'
        # to test ini substitution
        cls.config['defaults']['this_and_that'] = '%(this)s and %(that)s'

        g.show_config(cls.config)

        cls.order = ['defaults', 'globals']

        # cleanup files if they exist
        '''
开发者ID:ramkrsna,项目名称:glusto,代码行数:27,代码来源:test_glusto_configs.py

示例2: test_ini_noext

# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import show_config [as 别名]
    def test_ini_noext(self):
        """Testing ini config file(s) without extension"""
        print "Running: %s - %s" % (self.id(), self.shortDescription())

        g.store_config(self.config, self.ini_file)
        self.assertTrue(os.path.exists(self.ini_file))
        g.store_config(self.config, self.ini_noext, config_type='ini')
        self.assertTrue(os.path.exists(self.ini_noext))

        print "--------------"
        g.show_file(self.ini_file)
        print "--------------"
        g.show_file(self.ini_noext)
        print "--------------"

        # read the config file
        config = g.load_config(self.ini_file)
        g.show_config(config)
        self.assertEqual(config['defaults']['this'], 'yada1')
        self.assertEqual(config['defaults']['that'], 'yada2')
        self.assertEqual(config['defaults']['this_and_that'],
                         'yada1 and yada2')
        self.assertEqual(config['globals']['the_other'], 'yada3')

        config_noext = g.load_config(self.ini_file, config_type='ini')
        g.show_config(config_noext)
        self.assertEqual(config_noext['defaults']['this'], 'yada1')
        self.assertEqual(config_noext['defaults']['that'], 'yada2')
        self.assertEqual(config_noext['defaults']['this_and_that'],
                         'yada1 and yada2')
        self.assertEqual(config_noext['globals']['the_other'], 'yada3')

        self.assertEqual(config, config_noext, 'config files are not the same')
开发者ID:mbukatov,项目名称:glusto,代码行数:35,代码来源:test_glusto_configs.py

示例3: setUp

# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import show_config [as 别名]
    def setUp(self):
        """unittest standard setUp method
        Runs before each test_ method
        """
        print "Setting Up: %s" % self.id()
        # render the template
        g.render_template(self.template_file,
                          self.template_vars,
                          self.output_file,
                          self.search_path)

        # read the resulting config file built from template
        self.output_config = g.load_config(self.output_file)
        g.show_config(self.output_config)
开发者ID:mbukatov,项目名称:glusto,代码行数:16,代码来源:test_glusto_templates.py

示例4: test_ini

# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import show_config [as 别名]
    def test_ini(self):
        """Testing ini config file(s)"""
        print "Running: %s - %s" % (self.id(), self.shortDescription())

        g.store_config(self.config, self.ini_file)
        self.assertTrue(os.path.exists(self.ini_file))

        # read the config file
        config = g.load_config(self.ini_file)
        g.show_config(config)
        self.assertEqual(config['defaults']['this'], 'yada1')
        self.assertEqual(config['defaults']['that'], 'yada2')
        self.assertEqual(config['defaults']['this_and_that'],
                         'yada1 and yada2')
        self.assertEqual(config['globals']['the_other'], 'yada3')
开发者ID:ramkrsna,项目名称:glusto,代码行数:17,代码来源:test_glusto_configs.py

示例5: test_yaml

# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import show_config [as 别名]
    def test_yaml(self):
        """Testing yaml config file"""
        print "Running: %s - %s" % (self.id(), self.shortDescription())

        # write the config file
        g.store_config(self.config, self.yaml_file)
        # TODO: does unittest have a file exists assert?
        self.assertTrue(os.path.exists(self.yaml_file))

        # read the config file
        config = g.load_config(self.yaml_file)
        g.show_config(config)
        self.assertEqual(config['defaults']['this'], 'yada1')
        self.assertEqual(config['defaults']['that'], 'yada2')
        self.assertEqual(config['globals']['the_other'], 'yada3')
开发者ID:ramkrsna,项目名称:glusto,代码行数:17,代码来源:test_glusto_configs.py

示例6: setUpClass

# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import show_config [as 别名]
    def setUpClass(cls):
        """unittest standard setUpClass method
        Runs before all test_ methods in the class
        """
        print "Setting Up Class: %s" % cls.__name__

        # Setting class attributes for use across all test methods
        cls.config_file = ('supporting_files/templates/'
                           'glusto_templates-vars.yml')
        config = g.load_config(cls.config_file)
        g.show_config(config)
        if config:
            g.update_config(config)

        cls.template_vars = g.config['templates']
        cls.template_file = ('templates/'
                             'glusto_templates-template.jinja')
        cls.search_path = 'supporting_files'
        cls.output_file = '/tmp/glusto_templates-output.yml'
开发者ID:mbukatov,项目名称:glusto,代码行数:21,代码来源:test_glusto_templates.py

示例7: main

# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import show_config [as 别名]
def main():
    """Entry point console script for setuptools.

    Provides a command-line interface to Glusto.

    Currently does nothing useful, but plan to wrap Glusto functionality in a
    CLI interface that can be injected into shell scripts, etc.

    Example:
        # glusto run hostname.example.com "uname -a"
    """
    epilog = ('NOTE: If encountering an "unknown option" issue '
              'with the -t and -n options, use param=\'args\' syntax.'
              '(e.g., -t="-v -x tests")')
    parser = argparse.ArgumentParser(description="Glusto CLI wrapper",
                                     epilog=epilog)
    parser.add_argument("-c", "--config",
                        help="Config file(s) to read.",
                        action="store", dest="config_list",
                        default=None)
    parser.add_argument("--ssh-keyfile",
                        help="SSH keyfile for connections.",
                        action="store", dest="ssh_keyfile")
    parser.add_argument("-l", "--log",
                        help="Default logfile location.",
                        action="store", dest="log_filename",
                        default=None)
    parser.add_argument("--log-level",
                        help="Default log level.",
                        action="store", dest="log_level",
                        default=None)
    parser.add_argument("--pytest",
                        help="Run tests using the pytest framework.",
                        action="store", dest="run_pytest")
    parser.add_argument("--nosetests",
                        help="Run tests using the nose framework.",
                        action="store", dest="run_nosetests")
    parser.add_argument("--unittest",
                        help="Run tests using the unittest framework.",
                        action="store", dest="run_unittest")
    parser.add_argument("-u",
                        help="Run unittests per provided config file.",
                        action="store_true", dest="run_unittest_config")
    parser.add_argument("-d", "--discover",
                        help="Discover unittests from directory.",
                        action="store", dest="discover_dir")
    args = parser.parse_args()

    # read config files and update g.config attributes
    handle_configs(args.config_list)

    # TODO: break everything into separate methods

    # handle actionable config items
    # logging
    # set defaults
    log_name = "glustomain"
    log_filename = "/tmp/glustomain.log"
    log_level = "INFO"
    # override with config
    log_filename = g.config.get('log_filename', log_filename)
    log_level = g.config.get('log_level', log_level)
    # override with CLI options
    if args.log_filename:
        log_filename = args.log_filename
    if args.log_level:
        log_level = args.log_level

    g.log = g.create_log(name=log_name, filename=log_filename,
                         level=log_level)
    print("Log %s created as %s with log level %s" % (log_name, log_filename,
                                                      log_level))

    g.log.info("Starting glusto via main()")
    print "Starting glusto via main()"

    # override ssh_keyfile @ CLI
    if args.ssh_keyfile:
        g.ssh_set_keyfile(args.ssh_keyfile)

    g.show_config(g.config)

    # unittest
    # TODO: functionalize this so it can be used for standalone test scripts
    if args.run_unittest_config or args.discover_dir:
        tsuite = unittest.TestSuite()
        if args.discover_dir:
            unittest_config = {'cli_discover': 'true'}
        else:
            unittest_config = g.config.get('unittest', False)

        if not unittest_config:
            print ("ERROR: Unittest option requires a unittest configuration.")
            return False

        output_junit = unittest_config.get('output_junit', False)
        if output_junit:
            trunner = xmlrunner.XMLTestRunner(output='/tmp/glustoreports')
        else:
            trunner = unittest.TextTestRunner(verbosity=2)
#.........这里部分代码省略.........
开发者ID:loadtheaccumulator,项目名称:glusto,代码行数:103,代码来源:main.py


注:本文中的glusto.core.Glusto.show_config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。