fix a bunch of python warnings (#28576)

* fix a bunch of python warnings

* fix that
This commit is contained in:
Adeeb Shihadeh
2023-06-16 13:22:30 -07:00
committed by GitHub
parent 056bc05489
commit 111b4eee30
4 changed files with 13 additions and 8 deletions
+6 -3
View File
@@ -106,8 +106,10 @@ class Tici(HardwareBase):
return model
def get_sound_card_online(self):
return (os.path.isfile('/proc/asound/card0/state') and
open('/proc/asound/card0/state').read().strip() == 'ONLINE')
if os.path.isfile('/proc/asound/card0/state'):
with open('/proc/asound/card0/state') as f:
return f.read().strip() == 'ONLINE'
return False
def reboot(self, reason=None):
subprocess.check_output(["sudo", "reboot"])
@@ -452,7 +454,8 @@ class Tici(HardwareBase):
def get_gpu_usage_percent(self):
try:
used, total = open('/sys/class/kgsl/kgsl-3d0/gpubusy').read().strip().split()
with open('/sys/class/kgsl/kgsl-3d0/gpubusy') as f:
used, total = f.read().strip().split()
return 100.0 * int(used) / int(total)
except Exception:
return 0