Exemplo n.º 1
0
    def test_load5(self):
        """Test load method"""
        PluginGlobals.add_env("testing.config_loading")

        class TMP2(Plugin):

            def __init__(self):
                declare_option("a")
                declare_option("b", cls=FileOption)
                declare_option("c")
                declare_option("xx", section_re='globals.*')

        config = Configuration()
        tmp2 = TMP2()
        config.load(currdir + "config4.ini")
        #config.pprint()
        if False and sys.platform == "win32":
            #
            # A hack, to ensure cross-platform portability of this test
            #
            e = ExtensionPoint(IFileOption)
            for ep in e.extensions():
                ep.set_value("/dev/null", raw=True)
        #PluginGlobals.pprint()
        config.save(currdir + "config4.out")
        #print config
        self.assertFileEqualsBaseline(
            currdir + "config4.out", currdir + "config4.txt", filter=filter)
        pyutilib.misc.setup_redirect(currdir + "log2.out")
        config.pprint()
        pyutilib.misc.reset_redirect()
        self.assertFileEqualsBaseline(
            currdir + "log2.out", currdir + "log2.txt", filter=filter)
        PluginGlobals.remove_env(
            "testing.config_loading", cleanup=True, singleton=False)
Exemplo n.º 2
0
def register_executable(name, validate=None):
    ep = ExtensionPoint(IExternalExecutable)
    if len(ep(name, all=True)) == 0:
        PluginGlobals.add_env("pca")
        PluginGlobals._executables.append(
            ExternalExecutable(name=name, validate=validate))
        PluginGlobals.pop_env()
    else:
        #
        # If the executable is being 'registered', then we search for it
        # again, since the user environment may have changed.
        #
        list(ep(name, all=True))[0].find_executable()
Exemplo n.º 3
0
def register_executable(name, validate=None):
    ep = ExtensionPoint(IExternalExecutable)
    if len(ep(name, all=True)) == 0:
        PluginGlobals.add_env("pca")
        PluginGlobals._executables.append(
            ExternalExecutable(
                name=name, validate=validate))
        PluginGlobals.pop_env()
    else:
        #
        # If the executable is being 'registered', then we search for it
        # again, since the user environment may have changed.
        #
        list(ep(name, all=True))[0].find_executable()
Exemplo n.º 4
0
    def test_load5(self):
        """Test load method"""
        PluginGlobals.add_env("testing.config_loading")

        class TMP2(Plugin):
            def __init__(self):
                declare_option("a")
                declare_option("b", cls=FileOption)
                declare_option("c")
                declare_option("xx", section_re='globals.*')

        config = Configuration()
        tmp2 = TMP2()
        config.load(currdir + "config4.ini")
        #config.pprint()
        if False and sys.platform == "win32":
            #
            # A hack, to ensure cross-platform portability of this test
            #
            e = ExtensionPoint(IFileOption)
            for ep in e.extensions():
                ep.set_value("/dev/null", raw=True)
        #PluginGlobals.pprint()
        config.save(currdir + "config4.out")
        #print config
        self.assertFileEqualsBaseline(currdir + "config4.out",
                                      currdir + "config4.txt",
                                      filter=filter)
        pyutilib.misc.setup_redirect(currdir + "log2.out")
        config.pprint()
        pyutilib.misc.reset_redirect()
        self.assertFileEqualsBaseline(currdir + "log2.out",
                                      currdir + "log2.txt",
                                      filter=filter)
        PluginGlobals.remove_env("testing.config_loading",
                                 cleanup=True,
                                 singleton=False)
Exemplo n.º 5
0
#  _________________________________________________________________________
#
#  PyUtilib: A Python utility library.
#  Copyright (c) 2008 Sandia Corporation.
#  This software is distributed under the BSD License.
#  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
#  the U.S. Government retains certain rights in this software.
#  _________________________________________________________________________

from pyutilib.component.core import PluginGlobals
PluginGlobals.add_env("pca")

from pyutilib.component.executables.executable import *

PluginGlobals.pop_env()
Exemplo n.º 6
0
 def setUp(self):
     PluginGlobals.add_env("testing.options")
     PluginGlobals.clear_global_data(keys=['globals', 'a.b'])
Exemplo n.º 7
0
import os
import re
import sys
from os.path import abspath, dirname
currdir = dirname(abspath(__file__)) + os.sep

import unittest
from pyutilib.component.core import Interface, PluginGlobals, ExtensionPoint, implements, Plugin
from pyutilib.component.config.options import Option, OptionError, IOption, declare_option, FileOption, IntOption, FloatOption, DictOption, BoolOption

PluginGlobals.add_env("testing.options")


class IDummyOption(Interface):
    """An interface that supports the initialization of the directory for
    options that specify files.  This is needed to correctly initialize
    relative paths for files."""


class DummyOption1(Option):
    """A test class that converts option data into float values."""

    implements(IDummyOption)

    def convert(self, value, default):
        """Conversion routine."""
        val = value[-1]
        if not val:
            return 0
        try:
            return float(val)
Exemplo n.º 8
0
#  _________________________________________________________________________
#
#  PyUtilib: A Python utility library.
#  Copyright (c) 2008 Sandia Corporation.
#  This software is distributed under the BSD License.
#  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
#  the U.S. Government retains certain rights in this software.
#  _________________________________________________________________________
#

from pyutilib.component.core import PluginGlobals
PluginGlobals.add_env("pyutilib")

from pyutilib.subprocess.processmngr import subprocess, SubprocessMngr, run_command, timer, signal_handler, run, PIPE, STDOUT

PluginGlobals.pop_env()
Exemplo n.º 9
0
 def setUp(self):
     PluginGlobals.add_env("testing.options")
     PluginGlobals.clear_global_data(keys=['globals', 'a.b'])
Exemplo n.º 10
0
import os
import re
import sys
from os.path import abspath, dirname
currdir = dirname(abspath(__file__)) + os.sep

import unittest
from pyutilib.component.core import Interface, PluginGlobals, ExtensionPoint, implements, Plugin
from pyutilib.component.config.options import Option, OptionError, IOption, declare_option, FileOption, IntOption, FloatOption, DictOption, BoolOption

PluginGlobals.add_env("testing.options")


class IDummyOption(Interface):
    """An interface that supports the initialization of the directory for
    options that specify files.  This is needed to correctly initialize
    relative paths for files."""


class DummyOption1(Option):
    """A test class that converts option data into float values."""

    implements(IDummyOption)

    def convert(self, value, default):
        """Conversion routine."""
        val = value[-1]
        if not val:
            return 0
        try:
            return float(val)
Exemplo n.º 11
0
 def setUp(self):
     PluginGlobals.add_env("testing.config")
     pyutilib.component.config.plugin_ConfigParser.Configuration_ConfigParser(
         name="Configuration_ConfigParser")
     self.tmp = Test.TMP()
Exemplo n.º 12
0
 def setUp(self):
     PluginGlobals.add_env("testing.config")
     pyutilib.component.config.plugin_ConfigParser.Configuration_ConfigParser(
         name="Configuration_ConfigParser")
     self.tmp = Test.TMP()
Exemplo n.º 13
0
#  _________________________________________________________________________
#
#  PyUtilib: A Python utility library.
#  Copyright (c) 2008 Sandia Corporation.
#  This software is distributed under the BSD License.
#  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
#  the U.S. Government retains certain rights in this software.
#  _________________________________________________________________________
"""
The pyutilib.component.config package includes utilities to configure
the PyUtilib Component Architecture.  This includes facilities for using
configuration files, controlling logging, and specifying component options.
"""

from pyutilib.component.core import PluginGlobals
PluginGlobals.add_env("pca")

from pyutilib.component.config.env_config import EnvironmentConfig
from pyutilib.component.config.options import ExecutableOption, declare_option, Option
from pyutilib.component.config.managed_plugin import ManagedPlugin, ManagedSingletonPlugin
from pyutilib.component.config.configuration import Configuration, ConfigurationError
from pyutilib.component.config.logging_config import LoggingConfig
from pyutilib.component.config.tempfiles import ITempfileManager, TempfileManagerPlugin, TempfileManager
import pyutilib.component.config.plugin_ConfigParser

PluginGlobals.pop_env()