diff --git a/cbutil/cpu_frequency.py b/cbutil/cpu_frequency.py index fa639b3b502e96a830218207fb670438e5f0d0ef..2a628c079c21fa30b5bf4a43a7f71a0ab1c9d775 100644 --- a/cbutil/cpu_frequency.py +++ b/cbutil/cpu_frequency.py @@ -44,6 +44,18 @@ def read_frequency_from_file(file_path: str) -> float: def run_command(command: str) -> str: + """ + Runs a shell command and returns its output. + + Args: + command: The shell command to run. + + Returns: + The output of the command as a string. + + Raises: + ValueError: If there is an error running the shell command. + """ try: result = subprocess.run( command, @@ -58,6 +70,19 @@ def run_command(command: str) -> str: def filter_output(pattern: str, output: str) -> str: + """ + Filters the output of a command using a regex pattern. + + Args: + pattern: The regex pattern to search for. + output: The output of the command as a string. + + Returns: + The first match for the regex pattern in the output. + + Raises: + LookupError: If no match is found for the regex pattern. + """ pattern = re.compile(pattern) match = pattern.search(output) if match: