Exemplo n.º 1
0
 def __init__(self, config=None, internal_time=time.time):
     super(RCConfig, self).__init__(config=config)
     self._time = internal_time
     # Working directory default config.
     self._wd_config = base_config.BaseConfig()
     if config is None:
         self.read()
Exemplo n.º 2
0
 def setUp(self):
     self.config = base_config.BaseConfig()
     self.config.set('gerrit', True)
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
     self.installer = gerrit_installer.GerritInstaller(
         self.pod, self.config)
Exemplo n.º 3
0
def install(pod_path, gerrit):
    """Checks whether the pod depends on npm, bower, and gulp and installs them
    if necessary. Then, runs install commands. Also optionally installs the
    Gerrit Code Review commit hook."""
    root = os.path.abspath(os.path.join(os.getcwd(), pod_path))
    pod = pods.Pod(root, storage=storage.FileStorage, load_extensions=False)
    with pod.profile.timer('grow_install'):
        config = base_config.BaseConfig()
        config.set('gerrit', gerrit)
        built_in_installers = []
        for installer_class in installers.BUILT_IN_INSTALLERS:
            built_in_installers.append(installer_class(pod, config))
        grow_installer = installer.Installer(built_in_installers, pod)
        grow_installer.run_installers()
    return pod
Exemplo n.º 4
0
    def read(self):
        """Reads the RC config from the system."""
        # Read the config from the home directory.
        filename = self.filename
        if not os.path.isfile(filename):
            self._config = {}
        else:
            with open(filename, 'r') as conf:
                self._config = yaml.load(conf.read()) or {}

        # Allow for an read only override from the working directory rc file.
        wd_filename = os.path.join(os.getcwd(), RC_FILE_NAME)
        if os.path.isfile(wd_filename):
            with open(wd_filename, 'r') as conf:
                self._wd_config = base_config.BaseConfig(yaml.load(
                    conf.read()))
Exemplo n.º 5
0
 def setUp(self):
     self.config = base_config.BaseConfig()
     self.dir_path = testing.create_test_pod_dir()
     self.pod = pods.Pod(self.dir_path, storage=storage.FileStorage)
     self.installer = nvm_installer.NvmInstaller(self.pod, self.config)
Exemplo n.º 6
0
 def enable(self, feature, config=None):
     """Enable the feature."""
     self._enabled.add(feature)
     self._disabled.discard(feature)
     if config:
         self._config[feature] = base_config.BaseConfig(config=config)
Exemplo n.º 7
0
 def config(self, feature):
     """Configuration for a feature."""
     return self._config.get(feature, base_config.BaseConfig())
Exemplo n.º 8
0
 def setUp(self):
     self.config = base_config.BaseConfig(config={})
Exemplo n.º 9
0
 def setUp(self):
     self.config = base_config.BaseConfig(config={})
     self.prefixed = self.config.prefixed('base')
Exemplo n.º 10
0
 def test_get_empty(self):
     """Test that get works on the config with default."""
     self.config = base_config.BaseConfig(config=None)
     self.assertEqual(42, self.config.get('foo', 42))
     self.assertEqual(42, self.config.get('foo.bar', 42))