better log formatting and limit lines to 80 char
[logparse.git] / logparse / parsers / temperature.py
index afc652b4fe00eba694f5127de062a43845922d8e..f2c366ccbb3f0b3db5b1a70fc3b2957adf57d5b2 100644 (file)
@@ -148,9 +148,11 @@ class Temperature(Parser):
                 logger.debug("Ignoring drive {0} ({1}) due to config".format(drive.path, drive.model))
         logger.debug("Sorted drive info: " + str(drives))
 
-        hddavg = '{0:.1f}{1}{2}'.format(sumtemp/len(drives), DEG, drives[0].units) # use units of first drive
-        logger.debug("Sum of temperatures: {}; Number of drives: {}; => Avg disk temp is {}".format(str(sumtemp), str(len(drives)), hddavg)) 
-        hddtemp_data.subtitle += " (avg {0}{1}{2})".format(str(hddavg), DEG, CEL)
+        if not len(drives) == 0:
+            hddavg = '{0:.1f}{1}{2}'.format(sumtemp/len(drives), DEG, drives[0].units) # use units of first drive
+            logger.debug("Sum of temperatures: {}; Number of drives: {}; => Avg disk temp is {}".format(str(sumtemp), str(len(drives)), hddavg)) 
+            hddtemp_data.subtitle += " (avg {0}{1}{2})".format(str(hddavg), DEG, CEL)
+            section.append_data(hddtemp_data)
 
         logger.debug("Finished processing drive temperatures")
         logger.info("Finished temp section")