[bind10-dev] b10-showtech and distributing portable sysinfo

Jeremy C. Reed jreed at isc.org
Tue Jul 10 22:04:26 UTC 2012


I think we should share our portable sysinfo python module as a 
standalone product. (So no specific BIND 10 code in it.)

Also I tested the b10-showtech from master on NetBSD. I know it was for 
Linux only and I see other branches are for OpenBSD and FreeBSD.  But I 
was surprised to get unknown or wrong results for some standard things.  
Anyways here is my patch that uses some functions already in Python:

diff --git a/src/bin/showtech/showtech.py.in b/src/bin/showtech/showtech.py.in
index 5b67847..542e2ea 100755
--- a/src/bin/showtech/showtech.py.in
+++ b/src/bin/showtech/showtech.py.in
@@ -62,12 +62,12 @@ def main():
 
     f.write('\nCPU\n');
     f.write(' + Number of processors: %d\n' % (s.get_num_processors()))
-    f.write(' + Endianness: %s\n' % (s.get_endianness()))
+    f.write(' + Endianness: %s\n' % (sys.byteorder))
 
     f.write('\nPlatform\n');
-    f.write(' + Operating system: %s\n' % (s.get_platform_name()))
-    f.write(' + Distribution: %s\n' % (s.get_platform_distro()))
-    f.write(' + Kernel version: %s\n' % (s.get_platform_version()))
+    f.write(' + Operating system: %s\n' % (os.uname()[0]))	# or sys.platform
+    f.write(' + Distribution: %s\n' % (s.get_platform_distro()))	# TODO: use platform.dist ?
+    f.write(' + Kernel version: %s\n' % (os.uname()[2]))
 
     f.write(' + SMP kernel: ')
     if s.get_platform_is_smp():
@@ -76,11 +76,11 @@ def main():
         f.write('no')
     f.write('\n')
 
-    f.write(' + Machine name: %s\n' % (s.get_platform_machine()))
-    f.write(' + Hostname: %s\n' % (s.get_platform_hostname()))
+    f.write(' + Machine name: %s\n' % (os.uname()[4]))
+    f.write(' + Hostname: %s\n' % (os.uname()[1]))
     f.write(' + Uptime: %d seconds\n' % (s.get_uptime()))
 
-    l = s.get_loadavg()
+    l = os.getloadavg()
     f.write(' + Loadavg: %f %f %f\n' % (l[0], l[1], l[2]))
 
     f.write('\nMemory\n');



More information about the bind10-dev mailing list