Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cb-util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christoph Alt
cb-util
Commits
72fabae4
Commit
72fabae4
authored
2 years ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
added some docstrings
parent
e50d7039
No related branches found
No related tags found
1 merge request
!4
Devel/frequency
Pipeline
#51054
failed
2 years ago
Stage: test
Stage: deploy
Stage: trigger
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cbutil/cpu_frequency.py
+25
-0
25 additions, 0 deletions
cbutil/cpu_frequency.py
with
25 additions
and
0 deletions
cbutil/cpu_frequency.py
+
25
−
0
View file @
72fabae4
...
@@ -44,6 +44,18 @@ def read_frequency_from_file(file_path: str) -> float:
...
@@ -44,6 +44,18 @@ def read_frequency_from_file(file_path: str) -> float:
def
run_command
(
command
:
str
)
->
str
:
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
:
try
:
result
=
subprocess
.
run
(
result
=
subprocess
.
run
(
command
,
command
,
...
@@ -58,6 +70,19 @@ def run_command(command: str) -> str:
...
@@ -58,6 +70,19 @@ def run_command(command: str) -> str:
def
filter_output
(
pattern
:
str
,
output
:
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
)
pattern
=
re
.
compile
(
pattern
)
match
=
pattern
.
search
(
output
)
match
=
pattern
.
search
(
output
)
if
match
:
if
match
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment