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

pull/2360/head
Willem Melching 2020-10-19 13:44:36 +02:00 committed by GitHub
parent c5e2d0cd61
commit 47dfa52456
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -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']:

View File

@ -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