コード例 #1
0
ファイル: check.py プロジェクト: Release-Candidate/Buildnis
    def runScript(self, script_path: pathlib.Path) -> None:
        """Runs the script at the given path and saves it's output.

        Args:
            script_path (pathlib.Path): The path to the script to run.
        """
        if script_path.is_file():
            self._logger.warning(
                'Calling build tool config script "{path}"'.format(path=script_path)
            )
            try:
                script_out = runCommand(
                    exe_args=ExeArgs(script_path.__str__(), [self.arch])
                )
                build_tool_cfg = json.loads(
                    script_out.std_out,
                    object_hook=lambda dict: SimpleNamespace(**dict),
                )
            except Exception as excp:
                self._logger.error(
                    'error "{error}" running build tool script "{path}"'.format(
                        error=excp, path=script_path
                    )
                )
            for item in build_tool_cfg.build_tools:
                if self.isBuildToolCfgOK(item):
                    self.build_tool_cfgs.append(item)
                else:
                    self._logger.error(
                        'build tool config "{cfg}" doesn\'t have all needed attributes!'.format(
                            cfg=script_path
                        )
                    )
コード例 #2
0
    def install(self, dep: object) -> None:
        """Install the dependency.

        Args:
            dep (object): The dependency object to install.
        """
        try:
            self._logger.info(
                'trying to install "{name}" using command "{cmd}" with args "{args}"'.format(
                    name=dep.name, cmd=dep.install_cmd, args=dep.install_arguments
                )
            )
            output = runCommand(
                exe_args=ExeArgs(dep.install_cmd, dep.install_arguments)
            )
            self._logger.debug(output.std_out)
            self._logger.debug(output.err_out)
        except Exception as excp:
            self._logger.error(
                'error "{error}" trying to install "{name}" using command "{cmd}" with args "{args}"'.format(
                    error=excp,
                    name=dep.name,
                    cmd=dep.install_cmd,
                    args=dep.install_arguments,
                )
            )
コード例 #3
0
def getL3CacheOSX() -> CmdOutput:
    """Returns the size of the CPU's level 3 cache.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs("sysctl", ["-n", "hw.l3cachesize"]))
コード例 #4
0
def getNumLogCoresOSX() -> CmdOutput:
    """Returns the number of logical cores, including hyperthreading.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs("sysctl", ["-n", "hw.logicalcpu"]))
コード例 #5
0
def getCPUNameOSX() -> CmdOutput:
    """Returns the CPU name.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs("sysctl", ["-n", "machdep.cpu.brand_string"]))
コード例 #6
0
def getNumCoresOSX() -> CmdOutput:
    """Returns the number of physical cores.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs("sysctl", ["-n", "hw.physicalcpu"]))
コード例 #7
0
def getCPUName() -> CmdOutput:
    """Gets the CPU name using `wmic`

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs("wmic", ["cpu", "get", "Name"]))
コード例 #8
0
def getOSName() -> CmdOutput:
    """Returns the OS version of OS X.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs("sw_vers", ["-productVersion"]))
コード例 #9
0
def getGPUOSX() -> CmdOutput:
    """Return the GPU names.

    Returns:
         CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs("system_profiler", ["SPDisplaysDataType"]))
コード例 #10
0
def getRAMSizeOSX() -> CmdOutput:
    """Returns the RAM size in bytes.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs("sysctl", ["-n", "hw.memsize"]))
コード例 #11
0
def getGPUInfo() -> CmdOutput:
    """Returns the GPU names.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs(
        "wmic", ["path", "win32_VideoController", "get", "name"]))
コード例 #12
0
def getGPUNamesLinux() -> CmdOutput:
    """Returns the names of the GPUs.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(
        exe_args=ExeArgs("bash", ["-c", "lspci|grep VGA|cut -f3 -d':'"]))
コード例 #13
0
def getRAMSizeLinux() -> CmdOutput:
    """Returns the RAM size in bytes.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs(
        "bash", ["-c", "free -b|grep 'Mem:'|awk '{print $2}'"]))
コード例 #14
0
def getMemInfo() -> CmdOutput:
    """Returns the RAM size in bytes.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(
        exe_args=ExeArgs("wmic", ["memorychip", "get", "capacity"]))
コード例 #15
0
def getGPUNamesSbinLinux() -> CmdOutput:
    """Returns the names of the GPUs, using `/sbin/lspci` because some distributions
    don't have `lspci` in `/usr/bin`

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(
        exe_args=ExeArgs("bash", ["-c", "/sbin/lspci|grep VGA|cut -f3 -d':'"]))
コード例 #16
0
def getNumCoresLinux() -> CmdOutput:
    """Returns the number of physical cores.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs(
        "bash",
        ["-c", "grep 'cpu cores' /proc/cpuinfo |uniq|cut -d':' -f2"],
    ))
コード例 #17
0
def getL2CacheLinux() -> CmdOutput:
    """Returns the size of the CPU's level 2 cache.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs(
        "bash",
        ["-c", "getconf -a|grep LEVEL2_CACHE_SIZE|awk '{print $2}'"],
    ))
コード例 #18
0
def getCPUNameLinux() -> CmdOutput:
    """Returns the CPU's name.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs(
        "bash",
        ["-c", "grep 'model name' /proc/cpuinfo |head -1|cut -d':' -f2-"],
    ))
コード例 #19
0
def getNumLogCoresLinux() -> CmdOutput:
    """Returns the number of logical cores, including the hyperthreading.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs(
        "bash",
        ["-c", "grep siblings /proc/cpuinfo |uniq |cut -d':' -f2"],
    ))
コード例 #20
0
def getOSVer() -> CmdOutput:
    """Returns the minor OS version.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    return runCommand(exe_args=ExeArgs(
        "bash",
        [
            "-c",
            "grep VERSION /etc/os-release |head -1|cut -d'=' -f2|tr -d '\"'",
        ],
    ))
コード例 #21
0
def getCPUInfo() -> CmdOutput:
    """Gets CPU info using `wmic`.

    Returns:
        CmdOutput: The output of the command, as a `CmdOutput` instance containing
                    `stdout` and `stderr` as attributes.
    """
    ret_val = runCommand(exe_args=ExeArgs(
        "wmic",
        [
            "cpu",
            "get",
            "L2CacheSize,L3CacheSize,NumberOfLogicalProcessors,NumberOfCores",
        ],
    ), )

    return ret_val