summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2021-10-26 23:26:28 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2021-10-26 23:26:28 +0200
commit2974941c179c1637b5102b0cebd3d332c2847678 (patch)
treeec7f5c009efaa98bc0f554c462322e603368911f
parentcba37f42044e77588095e0ec815b51581ac4f49d (diff)
downloadpsutil-disk-swaps.tar.gz
try to fix GH failuredisk-swaps
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
-rw-r--r--psutil/_pslinux.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index a796386e..1c6a6519 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -1320,23 +1320,25 @@ def disk_swaps():
with f:
lines = f.readlines()
lines.pop(0) # header
- for line in lines:
- # Format is confusing:
- # Filename Type\tSize Used Priority
- # /dev/nvme0n1p3 partition\t11718652 2724 -2
- line = line.strip()
- name_and_type, _, other_fields = line.partition('\t')
- fstype = name_and_type.split()[-1]
- # "/dev/nvme0n1p3 partition" -> "/dev/nvme0n1p3"
- path = name_and_type.rstrip(fstype).strip()
- # The priority column is useful when multiple swap
- # files are in use. The lower the priority, the
- # more likely the swap file is to be used.
- total, used, priority = map(int, other_fields.split('\t'))
- total *= 1024
- used *= 1024
- nt = sdiskswap(path, total, used, fstype, priority)
- retlist.append(nt)
+ for line in lines:
+ # Format is confusing:
+ # Filename Type\tSize Used Priority
+ # /dev/nvme0n1p3 partition\t11718652 2724 -2
+ line = line.strip()
+ if not line:
+ continue
+ name_and_type, _, other_fields = line.partition('\t')
+ fstype = name_and_type.split()[-1]
+ # "/dev/nvme0n1p3 partition" -> "/dev/nvme0n1p3"
+ path = name_and_type.rstrip(fstype).strip()
+ # The priority column is useful when multiple swap
+ # files are in use. The lower the priority, the
+ # more likely the swap file is to be used.
+ total, used, priority = map(int, other_fields.split('\t'))
+ total *= 1024
+ used *= 1024
+ nt = sdiskswap(path, total, used, fstype, priority)
+ retlist.append(nt)
return retlist