Пример #1
0
  def _Start(self, conf_path, conf_file):
    """Pull and process a config file.

    Args:
      conf_path: The path to the config below root.
      conf_file: A named config file, normally build.yaml.
    """
    self._build_info.ActiveConfigPath(append=conf_path.rstrip('/'))
    try:
      path = download.PathCompile(self._build_info, file_name=conf_file)
      yaml_config = files.Read(path)
    except (files.Error, buildinfo.Error) as e:
      raise ConfigBuilderError(e)
    timer_start = 'start_{}_{}'.format(conf_path.rstrip('/'), conf_file)
    self._task_list.append({
        'path': copy.deepcopy(self._build_info.ActiveConfigPath()),
        'data': {'SetTimer': [timer_start]}
    })
    controls = yaml_config['controls']
    for control in controls:
      if 'pin' not in control or self._MatchPin(control['pin']):
        self._StoreControls(control, yaml_config.get('templates'))
    timer_stop = 'stop_{}_{}'.format(conf_path.rstrip('/'), conf_file)
    self._task_list.append({
        'path': copy.deepcopy(self._build_info.ActiveConfigPath()),
        'data': {'SetTimer': [timer_stop]}
    })
    self._build_info.ActiveConfigPath(pop=True)
Пример #2
0
 def Start(self, task_list):
     self._task_list_path = task_list
     try:
         data = files.Read(self._task_list_path)
     except files.Error as e:
         raise ConfigRunnerError(e)
     self._ProcessTasks(data)
Пример #3
0
 def _VersionInfo(self):
     if not self._version_info:
         info_file = '%s/%s' % (self.ConfigServer().rstrip('/'),
                                'version-info.yaml')
         try:
             self._version_info = files.Read(info_file)
         except files.Error as e:
             raise Error(e)
     return self._version_info
Пример #4
0
 def _ReleaseInfo(self):
     if not self._release_info:
         rel_info_file = '%s/%s' % (self.ReleasePath().rstrip('/'),
                                    'release-info.yaml')
         try:
             self._release_info = files.Read(rel_info_file)
         except files.Error as e:
             raise Error(e)
     return self._release_info
Пример #5
0
 def testRead(self, download):
   self.filesystem.CreateFile('/tmp/downloaded1.yaml', contents='data: set1')
   self.filesystem.CreateFile('/tmp/downloaded2.yaml', contents='data: set2')
   download.return_value = '/tmp/downloaded1.yaml'
   result = files.Read(
       'https://glazier-server.example.com/unstable/dir/test-build.yaml')
   download.assert_called_with(
       mock.ANY,
       'https://glazier-server.example.com/unstable/dir/test-build.yaml')
   self.assertEqual(result['data'], 'set1')
   # download error
   download.side_effect = files.download.DownloadError
   self.assertRaises(
       files.Error, files.Read,
       'https://glazier-server.example.com/unstable/dir/test-build.yaml')
   # local
   result = files.Read('/tmp/downloaded2.yaml')
   self.assertEqual(result['data'], 'set2')
Пример #6
0
  def Release(self) -> Optional[Text]:
    """Determine the current build release.

    Returns:
      The build release as a string.
    """
    rel_id_file = '%s/%s' % (self.ReleasePath().rstrip('/'), 'release-id.yaml')
    try:
      data = files.Read(rel_id_file)
    except files.Error as e:
      raise Error(e)
    if data and 'release_id' in data:
      return data['release_id']
    return None
Пример #7
0
    def _Start(self, conf_path, conf_file):
        """Pull and process a config file.

    Args:
      conf_path: The path to the config below root.
      conf_file: A named config file, normally build.yaml.
    """
        self._build_info.ActiveConfigPath(append=conf_path.rstrip('/'))
        try:
            path = download.PathCompile(self._build_info, file_name=conf_file)
            yaml_config = files.Read(path)
        except (files.Error, buildinfo.BuildInfoError) as e:
            raise ConfigBuilderError(e)
        controls = yaml_config['controls']
        for control in controls:
            if 'pin' not in control or self._MatchPin(control['pin']):
                self._StoreControls(control, yaml_config.get('templates'))
        self._build_info.ActiveConfigPath(pop=True)