use iterator to loop over first 1000 entries (#2359)

old-commit-hash: 47dfa52456
commatwo_master
Willem Melching 5 years ago committed by GitHub
parent 40274818ea
commit 5c09e8e61b
  1. 2
      selfdrive/debug/live_cpu_and_temp.py
  2. 10
      selfdrive/tombstoned.py

@ -49,7 +49,7 @@ if __name__ == "__main__":
if sm.updated['thermal']:
t = sm['thermal']
last_temp = np.mean([t.cpu0, t.cpu1, t.cpu2, t.cpu3]) / 10.
last_temp = np.mean(t.cpu)
last_mem = t.memUsedPercent
if sm.updated['procLog']:

@ -17,10 +17,12 @@ def get_tombstones():
files = []
for folder in ["/data/tombstones/", "/var/crash/"]:
if os.path.exists(folder):
for fn in os.listdir(folder):
if fn.startswith("tombstone") or fn.endswith(".crash"):
path = os.path.join(folder, fn)
files.append((path, int(os.stat(path).st_ctime)))
with os.scandir(folder) as d:
# Loop over first 1000 directory entries
for _, f in zip(range(1000), d):
if f.name.startswith("tombstone") or f.name.endswith(".crash"):
files.append((f.path, int(f.stat().st_ctime)))
return files

Loading…
Cancel
Save