From 02ec7387b3e3030bac03cb4e1c06162f4cd3dc17 Mon Sep 17 00:00:00 2001 From: Sun Lihong Date: Thu, 27 Feb 2014 10:17:24 +0800 Subject: [PATCH] Show hostname in log Show hostname before distro info in log. Fixes: #1644 Change-Id: Ibb9bdfa8bd1920084fbcdcec7a233102aeda0762 --- mic/utils/misc.py | 12 +++++++++--- tools/mic | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mic/utils/misc.py b/mic/utils/misc.py index 9db2eaf..d90041d 100644 --- a/mic/utils/misc.py +++ b/mic/utils/misc.py @@ -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 diff --git a/tools/mic b/tools/mic index 6a0afa1..a81a905 100755 --- 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) -- 2.7.4