Merge pull request #99 from Kenthliu/openbmc

Fix the sensor scandirectory recovery bug when poll or readattribute fail
diff --git a/bin/hwmon.py b/bin/hwmon.py
index 66159ee..9f4b1d9 100755
--- a/bin/hwmon.py
+++ b/bin/hwmon.py
@@ -47,10 +47,13 @@
 		self.cache = {}
 
 	def readAttribute(self,filename):
-		val = ""
+		val = "-1"
+		try:
 		with open(filename, 'r') as f:
 			for line in f:
 				val = line.rstrip('\n')
+		except (OSError, IOError):
+		print "Cannot read attributes:", filename
 		return val
 
 	def writeAttribute(self,filename,value):
@@ -78,6 +81,7 @@
 					self.writeAttribute(attribute,rtn[1])
 		except:
 			print "HWMON: Attibute no longer exists: "+attribute
+			self.sensors.pop(objpath,None)
 			if attribute in self.cache:
 				del self.cache[attribute]
 			return False