Ejemplo n.º 1
0
def _remove_windows_protected_entry(function, path,
                                    exc_info):  # pragma: no cover
    path = Path(path)
    path.chmod(stat.S_IWRITE)
    try:
        function(path)
    except Exception as e:
        log.warning("Cannot remove {0}:{1}".format(path, e))
Ejemplo n.º 2
0
 def _set_file_property(self, outfilename: pathlib.Path,
                        properties: Dict[str, Any]) -> None:
     # creation time
     creationtime = ArchiveTimestamp(
         properties['lastwritetime']).totimestamp()
     if creationtime is not None:
         os.utime(str(outfilename), times=(creationtime, creationtime))
     if os.name == 'posix':
         st_mode = properties['posix_mode']
         if st_mode is not None:
             outfilename.chmod(st_mode)
             return
     # fallback: only set readonly if specified
     if properties['readonly'] and not properties['is_directory']:
         ro_mask = 0o777 ^ (stat.S_IWRITE | stat.S_IWGRP | stat.S_IWOTH)
         outfilename.chmod(outfilename.stat().st_mode & ro_mask)
Ejemplo n.º 3
0
def _write_desktop_ini(dirpath, icon=None):  # pragma: no cover -- TODO
    icon = icon or IconResource(r'C:\WINDOWS\System32\SHELL32.dll', 1)
    dirpath = Path(dirpath)
    if dirpath.exists():
        if platform.system() == 'Windows':
            dirpath.chmod(stat.S_IWRITE)
        subprocess.call(['attrib', '-s', str(dirpath)])
    desktop_ini = (dirpath / 'desktop.ini')
    if desktop_ini.exists():
        if platform.system() == 'Windows':
            dirpath.chmod(stat.S_IWRITE)
        subprocess.call(['attrib', '-s', str(desktop_ini)])
    desktop_ini.write_text(
        DESKTOP_INI.format(icon_index=icon.index, dll_name=icon.dll_name))
    subprocess.call(['attrib', '+s', str(dirpath)])
    subprocess.call(['attrib', '+s', str(desktop_ini)])
Ejemplo n.º 4
0
def get_coverage_build(dirpath, args):
    """Gets a coverage build from a specified server.

    Args:
        dirpath (Path): Directory in which build is to be downloaded in.
        args (class): Command line arguments.

    Returns:
        Path: Path to the js coverage build
    """
    RUN_COV_LOG.info("Downloading coverage build zip file into %s from %s",
                     str(dirpath), args.url)
    with requests.get(args.url, stream=True) as f:
        build_request_data = io.BytesIO(f.content)

    RUN_COV_LOG.info("Extracting coverage build zip file...")
    build_zip = zipfile.ZipFile(build_request_data)
    extract_folder = dirpath / "cov-build"
    extract_folder.mkdir(parents=True,
                         exist_ok=True)  # Ensure this dir has been created
    # In 3.5 <= Python < 3.6, .extractall does not automatically create intermediate folders that do not exist
    build_zip.extractall(str(extract_folder.resolve()))
    RUN_COV_LOG.info("Coverage build zip file extracted to this folder: %s",
                     extract_folder.resolve())

    js_cov_bin_name = "js" + (".exe" if platform.system() == "Windows" else "")
    js_cov_bin = extract_folder / "dist" / "bin" / js_cov_bin_name

    Path.chmod(js_cov_bin,
               Path.stat(js_cov_bin).st_mode
               | 0o111)  # Ensure the js binary is executable
    assert js_cov_bin.is_file()

    # Check that the binary is non-debug.
    assert not queryBuildConfiguration(js_cov_bin, "debug")
    assert queryBuildConfiguration(js_cov_bin, "coverage")

    js_cov_fmconf = extract_folder / "dist" / "bin" / (js_cov_bin_name +
                                                       ".fuzzmanagerconf")
    assert js_cov_fmconf.is_file()

    # Check that a coverage build with *.gcno files are present
    js_cov_unified_gcno = extract_folder / "js" / "src" / "Unified_cpp_js_src0.gcno"
    assert js_cov_unified_gcno.is_file()

    return js_cov_bin