Show hostname in log
authorSun Lihong <lihongx.sun@intel.com>
Thu, 27 Feb 2014 02:17:24 +0000 (10:17 +0800)
committerSun Lihong <lihongx.sun@intel.com>
Thu, 27 Feb 2014 06:16:29 +0000 (14:16 +0800)
Show hostname before distro info in log.

Fixes: #1644

Change-Id: Ibb9bdfa8bd1920084fbcdcec7a233102aeda0762

mic/utils/misc.py
tools/mic

index 9db2eaf..d90041d 100644 (file)
@@ -114,15 +114,21 @@ def get_distro():
 
     return (dist, ver, id)
 
-def get_distro_str():
+def get_hostname():
+    """Get hostname
+    """
+    return platform.node()
+
+def get_hostname_distro_str():
     """Get composited string for current linux distribution
     """
     (dist, ver, id) = get_distro()
+    hostname = get_hostname()
 
     if not dist:
-        return 'Unknown Linux Distro'
+        return "%s(Unknown Linux Distribution)" % hostname
     else:
-        distro_str = ' '.join(map(str.strip, (dist, ver, id)))
+        distro_str = ' '.join(map(str.strip, (hostname, dist, ver, id)))
         return distro_str.strip()
 
 _LOOP_RULE_PTH = None
index 6a0afa1..a81a905 100755 (executable)
--- a/tools/mic
+++ b/tools/mic
@@ -48,7 +48,7 @@ class MicCmd(cmdln.Cmdln):
     def print_version(self):
         msger.raw("%s %s (%s)" % (self.name,
                                   self.version,
-                                  misc.get_distro_str()))
+                                  misc.get_hostname_distro_str()))
 
     def get_optparser(self):
         optparser = cmdln.CmdlnOptionParser(self, version=self.version)