fix a bunch of python warnings (#28576)
* fix a bunch of python warnings * fix that old-commit-hash: 111b4eee30d3a8f79d082b78e9158cbe262f1a14
This commit is contained in:
@@ -159,7 +159,7 @@ class TestAthenadMethods(unittest.TestCase):
|
||||
resp = dispatcher["uploadFileToUrl"]("qlog.bz2", f"{host}/qlog.bz2", {})
|
||||
self.assertEqual(resp['enqueued'], 1)
|
||||
self.assertNotIn('failed', resp)
|
||||
self.assertDictContainsSubset({"path": fn, "url": f"{host}/qlog.bz2", "headers": {}}, resp['items'][0])
|
||||
self.assertLessEqual({"path": fn, "url": f"{host}/qlog.bz2", "headers": {}}.items(), resp['items'][0].items())
|
||||
self.assertIsNotNone(resp['items'][0].get('id'))
|
||||
self.assertEqual(athenad.upload_queue.qsize(), 1)
|
||||
|
||||
|
||||
@@ -76,9 +76,10 @@ class TestAlerts(unittest.TestCase):
|
||||
break
|
||||
|
||||
font = fonts[alert.alert_size][i]
|
||||
w, _ = draw.textsize(txt, font)
|
||||
left, _, right, _ = draw.textbbox((0, 0), txt, font)
|
||||
width = right - left
|
||||
msg = f"type: {alert.alert_type} msg: {txt}"
|
||||
self.assertLessEqual(w, max_text_width, msg=msg)
|
||||
self.assertLessEqual(width, max_text_width, msg=msg)
|
||||
|
||||
def test_alert_sanity_check(self):
|
||||
for event_types in EVENTS.values():
|
||||
|
||||
@@ -100,8 +100,9 @@ class ManagerProcess(ABC):
|
||||
|
||||
try:
|
||||
fn = WATCHDOG_FN + str(self.proc.pid)
|
||||
# TODO: why can't pylint find struct.unpack?
|
||||
self.last_watchdog_time = struct.unpack('Q', open(fn, "rb").read())[0] # pylint: disable=no-member
|
||||
with open(fn, "rb") as f:
|
||||
# TODO: why can't pylint find struct.unpack?
|
||||
self.last_watchdog_time = struct.unpack('Q', f.read())[0] # pylint: disable=no-member
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user