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 ) )
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, ) )
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"]))
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"]))
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"]))
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"]))
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"]))
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"]))
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"]))
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"]))
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"]))
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':'"]))
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}'"]))
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"]))
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':'"]))
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"], ))
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}'"], ))
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-"], ))
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"], ))
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 '\"'", ], ))
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