Added exception handling to check_output
I tweaked the optimized return of check_output. Worth mentioning that `check_output()` will raise an exception `subprocess.CalledProcessError: Command 'lscpu | grep AMD' returned non-zero exit status 1.`.
This commit is contained in:
parent
5fe752cf72
commit
8d7ccde162
|
|
@ -63,13 +63,19 @@ def has_wifi() -> bool:
|
||||||
|
|
||||||
|
|
||||||
def has_amd_cpu() -> bool:
|
def has_amd_cpu() -> bool:
|
||||||
if subprocess.check_output("lscpu | grep AMD", shell=True).strip().decode():
|
try:
|
||||||
return True
|
return subprocess.check_output("lscpu | grep AMD", shell=True).strip().decode()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def has_intel_cpu() -> bool:
|
def has_intel_cpu() -> bool:
|
||||||
|
try:
|
||||||
return subprocess.check_output("lscpu | grep Intel", shell=True).strip().decode()
|
return subprocess.check_output("lscpu | grep Intel", shell=True).strip().decode()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
def has_uefi() -> bool:
|
def has_uefi() -> bool:
|
||||||
return os.path.isdir('/sys/firmware/efi')
|
return os.path.isdir('/sys/firmware/efi')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue