Silently ignore permission errors
Those usually occur on special filesystems which we don't care about anyway.
This commit is contained in:
parent
6c67de3bc9
commit
2f4096c5af
4
df2db
4
df2db
|
@ -12,6 +12,7 @@ csr = db.cursor()
|
||||||
with open("/proc/mounts") as mounts:
|
with open("/proc/mounts") as mounts:
|
||||||
for mount in mounts:
|
for mount in mounts:
|
||||||
(dev, mountpoint, fstype, rest) = mount.split(' ', 3)
|
(dev, mountpoint, fstype, rest) = mount.split(' ', 3)
|
||||||
|
try:
|
||||||
s = os.statvfs(mountpoint)
|
s = os.statvfs(mountpoint)
|
||||||
if s.f_blocks == 0:
|
if s.f_blocks == 0:
|
||||||
continue # not a real file system
|
continue # not a real file system
|
||||||
|
@ -40,6 +41,9 @@ with open("/proc/mounts") as mounts:
|
||||||
(hostname, mountpoint,
|
(hostname, mountpoint,
|
||||||
s_total, s_usable, s_used,
|
s_total, s_usable, s_used,
|
||||||
f_total, f_usable, f_used))
|
f_total, f_usable, f_used))
|
||||||
|
except PermissionError:
|
||||||
|
# silently ignore some errors
|
||||||
|
pass
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue