Skip to content

Commit

Permalink
Improved error message when hdparm is absent
Browse files Browse the repository at this point in the history
  • Loading branch information
louwrentius committed Nov 30, 2023
1 parent e0ea9f6 commit 3ff5bb4
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions showtools/showlib/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@ def get_hdparm_data(device):
p = subprocess.Popen([command], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True)
rawdata = p.communicate()
except OSError:
print("Is hdparm installed or are you root / using sudo?")
sys.exit(1)

returncode = p.returncode
returncode = p.returncode

if returncode == 13:
raise IOError
if returncode == 127:
raise OSError
if returncode > 0:
pass
if returncode == 13:
raise IOError
if returncode == 127:
raise OSError
if returncode > 0:
pass

except OSError:
print("Is hdparm installed or are you root / using sudo?")
sys.exit(1)
except IOError:
print(f"Possible I/O error on device {device}")
sys.exit(1)
return rawdata


Expand Down

0 comments on commit 3ff5bb4

Please sign in to comment.