Skip to content

Commit

Permalink
Return code check instead of using check=True
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneTR committed Jan 4, 2023
1 parent 5ba4dff commit 3392ccb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/hardware_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ def read_process_with_regex(path, regex, params=REGEX_PARAMS):
'''Reads the data from a process and then matches the output. The process must terminate and not require user
input! The matching character for the regex is a 'o'. If the process fails (exit val not 0) an exception
is thrown.'''
result = subprocess.run(path, stdout=subprocess.PIPE, shell=True, check=True)
std_data = result.stdout.decode('utf-8')
result = subprocess.run(path, stdout=subprocess.PIPE, shell=True, encoding='UTF-8', check=False)
if result.returncode != 0:
return 'Unknown'

match = re.search(regex, std_data, params)
match = re.search(regex, result.stdout, params)

return match.group('o') if match is not None else 'Unknown'

Expand Down

0 comments on commit 3392ccb

Please sign in to comment.