Example #1
0
def set_from_config(kwargs):
    if kwargs["config"] is None:
        config_path = config.path()
    else:
        config_path = kwargs["config"]

    kwargs["config_path"] = config_path

    kwargs["config"] = config.read(kwargs["config_path"])

    keys = {
        "paths": [("prefs", "prefs_root", True),
                  ("run_info", "run_info", True)],
        "web-platform-tests": [("remote_url", "remote_url", False),
                               ("branch", "branch", False),
                               ("sync_path", "sync_path", True)],
        "SSL": [("openssl_binary", "openssl_binary", True),
                ("certutil_binary", "certutil_binary", True),
                ("ca_cert_path", "ca_cert_path", True),
                ("host_cert_path", "host_cert_path", True),
                ("host_key_path", "host_key_path", True)]
    }

    for section, values in keys.iteritems():
        for config_value, kw_value, is_path in values:
            if kw_value in kwargs and kwargs[kw_value] is None:
                if not is_path:
                    new_value = kwargs["config"].get(section,
                                                     config.ConfigDict(
                                                         {})).get(config_value)
                else:
                    new_value = kwargs["config"].get(
                        section, config.ConfigDict({})).get_path(config_value)
                kwargs[kw_value] = new_value

    kwargs["test_paths"] = get_test_paths(kwargs["config"])

    if kwargs["tests_root"]:
        if "/" not in kwargs["test_paths"]:
            kwargs["test_paths"]["/"] = {}
        kwargs["test_paths"]["/"]["tests_path"] = kwargs["tests_root"]

    if kwargs["metadata_root"]:
        if "/" not in kwargs["test_paths"]:
            kwargs["test_paths"]["/"] = {}
        kwargs["test_paths"]["/"]["metadata_path"] = kwargs["metadata_root"]

    if kwargs.get("manifest_path"):
        if "/" not in kwargs["test_paths"]:
            kwargs["test_paths"]["/"] = {}
        kwargs["test_paths"]["/"]["manifest_path"] = kwargs["manifest_path"]

    kwargs["suite_name"] = kwargs["config"].get("web-platform-tests", {}).get(
        "name", "web-platform-tests")

    check_paths(kwargs)
Example #2
0
 def _control_ini_section(self, section):
     if self._control_ini is None:
         self._control_ini = {}  # empty set of caches
     cache = self._control_ini.get(section, None)
     if cache is None:  # empty cache from set
         fullpath = os.path.join(self.job.resultdir, 'control.ini')
         # Control-file & behavior cannot be assumed, file may not exist.
         try:
             cache_section = config.ConfigDict(section)
             cache_section.read(open(fullpath, 'rb'))
             # The class instance isn't needed, only store the data
             cache = dict(cache_section.items())
         except (IOError, OSError, Error):
             self.logwarning(
                 "Failed to load reference '%s' and/or "
                 "its '[%s]' section.", fullpath, section)
             # Flag to signal no file or section
             cache = {}
         # Update cache set
         self._control_ini[section] = cache
     # Must always return None or a dictionary
     if not cache:
         self.logdebug("No reference control.ini found, returning None")
         return None
     return dict(cache.items())  # return a copy
Example #3
0
 def control_config(self):
     """
     Represent operational control.ini's [Control] section as a dict or None
     """
     if self._control_ini is None:
         fullpath = os.path.join(self.job.resultdir, 'control.ini')
         # Control-file & behavior cannot be assumed, file may not exist.
         try:
             self._control_ini = config.ConfigDict('Control')
             self._control_ini.read(open(fullpath, 'rb'))
         except (IOError, OSError, Error):
             self.logwarning("Failed to load reference '%s' and/or"
                             "it's '[Control]' section.", fullpath)
             self._control_ini = {}
     if self._control_ini == {}:
         self.logdebug("No reference control.ini found, returning None")
         return None
     else:
         return dict(self._control_ini.items())  # return a copy