From 80b9b01e972e6d5141c5724d4d619b406b4eddba Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Sun, 14 Jul 2013 22:59:24 -0400 Subject: [PATCH] now won't throw exception if we don't have permission to stat a mtab entry on linux (weird chromebook issue) Signed-off-by: Brian Coca --- library/system/setup | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/library/system/setup b/library/system/setup index 0ddc7f209fb..4fae1485f08 100644 --- a/library/system/setup +++ b/library/system/setup @@ -626,16 +626,28 @@ class LinuxHardware(Hardware): if line.startswith('/'): fields = line.rstrip('\n').split() if(fields[2] != 'none'): - statvfs_result = os.statvfs(fields[1]) - self.facts['mounts'].append( - {'mount': fields[1], - 'device':fields[0], - 'fstype': fields[2], - 'options': fields[3], - # statvfs data - 'size_total': statvfs_result.f_bsize * statvfs_result.f_blocks, - 'size_available': statvfs_result.f_bsize * (statvfs_result.f_bavail), - }) + try: + statvfs_result = os.statvfs(fields[1]) + self.facts['mounts'].append( + {'mount': fields[1], + 'device':fields[0], + 'fstype': fields[2], + 'options': fields[3], + # statvfs data + 'size_total': statvfs_result.f_bsize * statvfs_result.f_blocks, + 'size_available': statvfs_result.f_bsize * (statvfs_result.f_bavail), + }) + except OSError, e: + # don't have access to stat so we'll set to None + self.facts['mounts'].append( + {'mount': fields[1], + 'device':fields[0], + 'fstype': fields[2], + 'options': fields[3], + # statvfs data + 'size_total': None, + 'size_available': None, + }) def get_device_facts(self): self.facts['devices'] = {}