Skip to content

Commit

Permalink
csmock: add shortcut to retrieve coverity version
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyw committed Sep 20, 2023
1 parent bea85b7 commit e9c9865
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions py/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with csmock. If not, see <http://www.gnu.org/licenses/>.

import re
import subprocess


def shell_quote(str_in):
Expand Down Expand Up @@ -121,3 +122,19 @@ def dirs_to_scan_by_args(parser, args, props, tool):
props.need_rpm_bi = True

return dirs_to_scan


def get_coverity_version(install_dir="/opt/coverity/"):
"""
Retrieve the version information from the coverity executable.
Returns:
string of the version information or None otherwise.
"""
executable_path = f"{install_dir}bin/coverity"
try:
version_info = subprocess.check_output([executable_path, "--version"])
version_text = version_info.decode("utf-8")
return version_text.strip().split()[0]
except (subprocess.CalledProcessError, FileNotFoundError):
return None

0 comments on commit e9c9865

Please sign in to comment.