rename parsers, better journald integration
[logparse.git] / logparse / parsers / sysinfo.py
index 7b44358a953605289e3ab041c7923c137fd128ab..c8c43e213576b248424a32fd9e82b236f3ec899e 100644 (file)
@@ -1,8 +1,6 @@
-#
-#   sysinfo.py
-#
-#   Get standard system information from basic Unix commands
-#
+"""
+Get standard system information from basic Unix commands
+"""
 
 import platform
 import subprocess
@@ -28,10 +26,12 @@ class Sysinfo(Parser):
         section = Section("system")
         table = Table()
 
-        table.add_row(Row([Column("Hostname"), Column(util.hostname(prefs.get("logparse", "hostname-path")))]))
+        table.add_row(Row([Column("Hostname"), 
+            Column(util.hostname(prefs.get("logparse", "hostname-path")))]))
         table.add_row(Row([Column("OS"), Column(platform.platform())]))
         table.add_row(Row([Column("OS version"), Column(platform.version())]))
-        table.add_row(Row([Column("Platform"), Column(platform.system() + " " + platform.machine())]))
+        table.add_row(Row([Column("Platform"),
+            Column(platform.system() + " " + platform.machine())]))
 
         processors = []
         raw_proc = util.readlog(prefs.get("logs", "cpuinfo"))
@@ -40,14 +40,17 @@ class Sysinfo(Parser):
         for line in raw_proc.splitlines():
             if "model name" in line:
                 processor = line_regex.sub("", line, 1)
-                processor = " ".join(proc_regex.sub("", processor).split()) # remove extraneous text and whitespace
+                # Remove extraneous text and whitespace:
+                processor = " ".join(proc_regex.sub("", processor).split())
                 if not processor in processors:
                     processors.append(processor)
                 else:
-                    logger.debug("Found duplicate entry (perhaps multiple cores?) for {0}".format(processor))
+                    logger.debug("Found duplicate entry (perhaps multiple "
+                            "cores?) for {0}".format(processor))
         table.align_column(0, "right")
         if len(processors) == 1:
-            table.add_row(Row([Column("Processor"), Column("; ".join(processors))]))
+            table.add_row(Row([Column("Processor"),
+                Column("; ".join(processors))]))
             section.append_table(table)
         elif len(processors) > 1:
             section.append_table(table)
@@ -61,12 +64,20 @@ class Sysinfo(Parser):
         logger.debug("Found uptime data " + str(raw_uptime))
 
         uptime_total = float(raw_uptime.split()[0])
-        table.add_row(Row([Column("Uptime"), Column("%d d %d h %d m" % (uptime_total // 86400, uptime_total % 86400 // 3600, uptime_total % 3600 // 60))]))
+        table.add_row(Row([Column("Uptime"),
+            Column("%d d %d h %d m" % (
+                uptime_total // 86400,
+                uptime_total % 86400 // 3600,
+                uptime_total % 3600 // 60))]))
 
         idle_time = float(raw_uptime.split()[1]) / cpu_count()
         m, s = divmod(idle_time, 60)
         h, m = divmod(m, 60)
-        table.add_row(Row([Column("Idle time"), Column("%d d %d h %d m per core (avg)" % (idle_time // 86400, idle_time % 86400 // 3600, idle_time % 3600 // 60))]))
+        table.add_row(Row([Column("Idle time"), 
+            Column("%d d %d h %d m per core (avg)" % (
+                idle_time // 86400, 
+                idle_time % 86400 // 3600, 
+                idle_time % 3600 // 60))]))
 
         logger.info("Finished sysinfo section")
         return section