s4/scripting/*: py3 compatible print
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sat, 27 Oct 2018 22:12:48 +0000 (11:12 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Fri, 2 Nov 2018 02:48:52 +0000 (03:48 +0100)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <noel.power@suse.com>
14 files changed:
source4/scripting/bin/enablerecyclebin
source4/scripting/bin/findprovisionusnranges
source4/scripting/bin/fullschema
source4/scripting/bin/get-descriptors
source4/scripting/bin/minschema
source4/scripting/bin/mymachinepw
source4/scripting/bin/rebuildextendeddn
source4/scripting/bin/sambaundoguididx
source4/scripting/bin/smbstatus
source4/scripting/devel/addlotscontacts
source4/scripting/devel/config_base
source4/scripting/devel/crackname
source4/scripting/devel/enumprivs
source4/scripting/devel/getncchanges

index ab36ead1b8f2b8a6e6c3ff22d7bf339aa7f077cc..a179698b7fe8bd409591f90b175830c7d302d667 100755 (executable)
@@ -50,4 +50,4 @@ msg["enableOptionalFeature"] = ldb.MessageElement(
      ldb.FLAG_MOD_ADD, "enableOptionalFeature")
 res = sam_ldb.modify(msg)
 
-print "Recycle Bin feature enabled"
+print("Recycle Bin feature enabled")
index ee9da3d421e13cef998da94910a98383b3e53fb1..540869dbae44a5ce086ccbc7551f72fdc2482acb 100755 (executable)
@@ -18,7 +18,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
-
 import sys
 import optparse
 sys.path.insert(0, "bin/python")
@@ -63,18 +62,17 @@ if res and len(res) == 1 and res[0]["dsServiceName"] != None:
     if res and len(res) == 1 and res[0]["invocationId"]:
         invocation = str(ndr_unpack(misc.GUID, res[0]["invocationId"][0]))   
     else:
-        print "Unable to find invocation ID"
+        print("Unable to find invocation ID")
         sys.exit(1)
 else:
-    print "Unable to find attribute dsServiceName in rootDSE"
+    print("Unable to find attribute dsServiceName in rootDSE")
     sys.exit(1)
 
 minobj = 5
 (hash_id, nb_obj) = findprovisionrange(samdb, basedn)
-print "Here is a list of changes that modified more than %d objects in 1 minute." % minobj
-print "Usually changes made by provision and upgradeprovision are those who affect a couple"\
-        " of hundred of objects or more"
-print "Total number of objects: %d" % nb_obj
-print 
+print("Here is a list of changes that modified more than %d objects in 1 minute." % minobj)
+print("Usually changes made by provision and upgradeprovision are those who affect a couple"
+      " of hundred of objects or more")
+print("Total number of objects: %d\n" % nb_obj)
 
 print_provision_ranges(hash_id, minobj, opts.storedir, str(paths.samdb), invocation)
index ab0e4e320bd07dc130d7e5d4b468494a3438d3e8..596de01b91cde971d01c63e9d96b014c840e0762 100755 (executable)
@@ -132,7 +132,7 @@ def fix_dn(dn):
 
 def write_ldif_one(o, attrs):
     """dump an object as ldif"""
-    print "dn: CN=%s,${SCHEMADN}" % o["cn"]
+    print("dn: CN=%s,${SCHEMADN}" % o["cn"])
     for a in attrs:
         if not o.has_key(a):
             continue
index f1a919c37480c3b70c6b0f15b5541fcc61208fdf..70926cdccbbd9cc9675aa016fb3a79e6b7b94871 100755 (executable)
@@ -90,7 +90,7 @@ class DescrGetter:
         for line in ldif_entry:
             length = 79
             if len(line) <= length + 1:
-                print line
+                print(line)
             else:
                 for i in range(len(line) / length + 1):
                     if i == 0:
index 477c69be54d5376c7ab7793218e23e66a4a77e65..e70d79a3cf3eb06cab1d01b994d745c8ab5e83cf 100755 (executable)
@@ -191,7 +191,7 @@ def fix_dn(dn):
 
 def write_ldif_one(o, attrs):
     """dump an object as ldif"""
-    print "dn: CN=%s,${SCHEMADN}" % o["cn"]
+    print("dn: CN=%s,${SCHEMADN}" % o["cn"])
     for a in attrs:
         if not o.has_key(a):
             continue
index dc85ad1df44f741003ddbbc4978d127e0811bb0d..91dc502a634cf80f761c5eac2a3cd8a8e90d4462 100755 (executable)
@@ -19,7 +19,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
-
 import samba.param as param, ldb, sys, getopt
 
 optlist, args = getopt.getopt(sys.argv[1:], "s:")
@@ -48,9 +47,9 @@ search = ("(&(objectclass=primaryDomain)(samaccountname=" +
 msg = secrets.search(expression=search, attrs=['secret'])
 
 if not msg:
-    print "Error:"
-    print "Password for host[%s] not found in path[%s]." % (netbios, path)
-    print "You may want to pass the smb.conf location via the -s option."
+    print("Error:")
+    print("Password for host[%s] not found in path[%s]." % (netbios, path))
+    print("You may want to pass the smb.conf location via the -s option.")
     exit(1)
 
 password=msg[0]['secret'][0]
index 5a0ab1295a6ef32f04638e97117bfba676d2b3fc..5f5e05da795dca97b835b7c8b4e3007c7b0de90f 100755 (executable)
@@ -21,7 +21,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
-
+from __future__ import print_function
 import optparse
 import os
 import sys
@@ -53,7 +53,7 @@ opts = parser.parse_args()[0]
 def message(text):
     """print a message if quiet is not set."""
     if not opts.quiet:
-        print text
+        print(text)
 
 if len(sys.argv) == 1:
     opts.interactive = True
@@ -77,7 +77,7 @@ def get_paths(targetdir=None,smbconf=None):
             smbconf = param.default_path()
 
     if not os.path.exists(smbconf):
-        print >>sys.stderr, "Unable to find smb.conf .. "+smbconf
+        print("Unable to find smb.conf .. "+smbconf, file=sys.stderr)
         parser.print_usage()
         sys.exit(1)
 
@@ -121,9 +121,11 @@ def rebuild_en_dn(credentials,session_info,paths):
                 sam_ldb.modify(m)
                 res3 = sam_ldb.search(expression="(&(distinguishedName=%s)(%s=*))"%(dn,att),scope=SCOPE_SUBTREE, attrs=[att],controls=["search_options:1:2"])
                 if( len(res3) == 0  or (len(res3[0][att])!= len(saveatt))):
-                    print >>sys.stderr, str(dn) + " has no attr " +att+ " or a wrong value"
+                    print(str(dn) + " has no attr " +att+ " or a wrong value",
+                          file=sys.stderr)
                     for satt in saveatt:
-                        print >>sys.stderr,str(att)+"    =    "+satt
+                        print("%s    =    %s" % (att, satt),
+                              file=sys.stderr)
                     sam_ldb.transaction_cancel()
     sam_ldb.transaction_commit()
 
index 24a95e20d7f4ceade059d10d8961aaa244aba881..a931601cf030305215c27e1d7e82848d7f10d86a 100755 (executable)
@@ -71,7 +71,7 @@ for db in dbs:
 
 samdb.transaction_commit()
 
-print "Re-opening with the full DB stack"
+print("Re-opening with the full DB stack")
 samdb = SamDB(url=url,
                           lp=lp_ctx)
 print "Re-triggering another re-index"
index 473dbaf2ce4bdd4c58c7abba17d94d6ddd61ec7c..c2834ab12abef08dd14886987cf915bacb83aa52 100755 (executable)
@@ -27,12 +27,14 @@ def show_sessions(conn):
     """show open sessions"""
 
     sessions = next(conn.smbsrv_information(irpc.SMBSRV_INFO_SESSIONS))
-    print "User                                  Client      Connected at"
-    print "-" * 79
+    print("User                                  Client      Connected at")
+    print("-" * 79)
     for session in sessions:
         fulluser = "%s/%s" % (session.account_name, session.domain_name)
-        print "%-30s %16s   %s" % (fulluser, session.client_ip, sys.httptime(session.connect_time))
-    print ""
+        print("%-30s %16s   %s" % (fulluser,
+                                   session.client_ip,
+                                   sys.httptime(session.connect_time)))
+    print()
 
 def show_tcons(open_connection):
     """show open tree connects"""
index edf54b0bade27357337f235670eba77d09b363d1..e8b2c1af1aa6c97e2df3767c8cc39b0637b70016 100644 (file)
@@ -75,7 +75,7 @@ if __name__ == '__main__':
 
         ldbs.sam.add(msg)
 
-    print "Creating %d contacts" % num_contacts
+    print("Creating %d contacts" % num_contacts)
     count = 0
     increment = num_contacts / 10
     if increment > 5000:
index 0d495c5091b9d150fbaffae6af2dc111f679e711..e74c87486bfa5aedbbefa2e6e85de308c4e0b81e 100755 (executable)
@@ -37,4 +37,4 @@ for v in vars:
 
 options = options.replace("${PREFIX}", prefix)
 
-print options
+print(options)
index 2e1798511f3b6ac04dde2657cae4f44973a53699..0ae177c133fa1091945f587138c130a56118b8c5 100755 (executable)
@@ -56,7 +56,7 @@ if __name__ == "__main__":
 
     drs = drsuapi.drsuapi(binding_str, lp, creds)
     drs_handle = do_DsBind(drs)
-    print "DRS Handle: %s" % drs_handle
+    print("DRS Handle: %s" % drs_handle)
 
     req = drsuapi.DsNameRequest1()
     names = drsuapi.DsNameString()
index 6a040402ae33a63294042a37192d68da800723d8..33597f9388acb5c36738eb8783bd0b2fb648e60b 100755 (executable)
@@ -55,4 +55,4 @@ if __name__ == "__main__":
     (handle, privs) = lsaconn.EnumPrivs(pol_handle, 0, 100)
     for p in privs.privs:
         disp_name = get_display_name(lsaconn, pol_handle, p.name.string)
-        print "0x%08x %31s \"%s\"" % (p.luid.low, p.name.string, disp_name)
+        print("0x%08x %31s \"%s\"" % (p.luid.low, p.name.string, disp_name))
index 9b6361b3548deaf625c9f58854cee2ab3d362003..9c25e39f756608e19f82a570b106a0199a292ab7 100755 (executable)
@@ -76,7 +76,7 @@ if __name__ == "__main__":
 
     drs = drsuapi.drsuapi(binding_str, lp, creds)
     drs_handle, supported_extensions = drs_DsBind(drs)
-    print "DRS Handle: %s" % drs_handle
+    print("DRS Handle: %s" % drs_handle)
 
     req8 = drsuapi.DsGetNCChangesRequest8()