s4/scripting: MORE py3 compatible print functions
[kai/samba-autobuild/.git] / source4 / scripting / bin / smbstatus
index d171a433a30988c63421730fe69286d00302451c..fd67b2ca6916da5ccd6dcf76c935934b1f144ea7 100755 (executable)
@@ -8,7 +8,7 @@
 #  Copyright Andrew Tridgell 2005
 #  Released under the GNU GPL version 3 or later
 #
-
+from __future__ import print_function
 import os, sys
 
 # make sure the script dies immediately when hitting control-C,
@@ -40,25 +40,26 @@ def show_tcons(open_connection):
     """show open tree connects"""
     conn = open_connection("smb_server")
     tcons = next(conn.smbsrv_information(irpc.SMBSRV_INFO_TCONS))
-    print "Share                                 Client      Connected at"
-    print "-" * 79
+    print("Share                                 Client      Connected at")
+    print("-" * 79)
     for tcon in tcons:
-        print "%-30s %16s   %s" % (tcon.share_name, tcon.client_ip, sys.httptime(tcon.connect_time))
+        print("%-30s %16s   %s" %
+              (tcon.share_name, tcon.client_ip, sys.httptime(tcon.connect_time)))
 
 
 def show_nbt(open_connection):
     """show nbtd information"""
     conn = open_connection("nbt_server")
     stats = next(conn.nbtd_information(irpc.NBTD_INFO_STATISTICS))
-    print "NBT server statistics:"
+    print("NBT server statistics:")
     fields = [("total_received", "Total received"),
               ("total_sent", "Total sent"),
               ("query_count", "Query count"),
               ("register_count", "Register count"),
               ("release_count", "Release count")]
     for (field, description) in fields:
-        print "\t%s:\t%s" % (description, getattr(stats, field))
-    print
+        print("\t%s:\t%s" % (description, getattr(stats, field)))
+    print()
 
 parser = optparse.OptionParser("%s [options]" % sys.argv[0])
 sambaopts = options.SambaOptions(parser)
@@ -71,7 +72,7 @@ opts, args = parser.parse_args()
 
 lp = sambaopts.get_loadparm()
 
-print "%s" % lp.get("server string")
+print("%s" % lp.get("server string"))
 
 messaging_path = (opts.messaging_path or os.path.join(lp.get("private dir"), "smbd.tmp", "messaging"))
 
@@ -85,7 +86,7 @@ else:
         conn = open_connection("smb_server")
     except RuntimeError, (num, msg):
         if msg == 'NT_STATUS_OBJECT_NAME_NOT_FOUND':
-            print "No active connections"
+            print("No active connections")
     else:
         show_sessions(conn)
         show_tcons(conn)