summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2018-10-28 11:12:48 +1300
committerDouglas Bagnall <dbagnall@samba.org>2018-11-02 03:48:52 +0100
commit78f5b6e3999a0bf4a118df36a2aabcb696049792 (patch)
treef67648a66458d871d161686dc7d9f224f39a9162 /source4/scripting
parent1cf142c30abaec2e99cebca15ac61685723032ed (diff)
downloadsamba-78f5b6e3999a0bf4a118df36a2aabcb696049792.tar.gz
s4/scripting/*: py3 compatible print
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
Diffstat (limited to 'source4/scripting')
-rwxr-xr-xsource4/scripting/bin/enablerecyclebin2
-rwxr-xr-xsource4/scripting/bin/findprovisionusnranges14
-rwxr-xr-xsource4/scripting/bin/fullschema2
-rwxr-xr-xsource4/scripting/bin/get-descriptors2
-rwxr-xr-xsource4/scripting/bin/minschema2
-rwxr-xr-xsource4/scripting/bin/mymachinepw7
-rwxr-xr-xsource4/scripting/bin/rebuildextendeddn12
-rwxr-xr-xsource4/scripting/bin/sambaundoguididx2
-rwxr-xr-xsource4/scripting/bin/smbstatus10
-rw-r--r--source4/scripting/devel/addlotscontacts2
-rwxr-xr-xsource4/scripting/devel/config_base2
-rwxr-xr-xsource4/scripting/devel/crackname2
-rwxr-xr-xsource4/scripting/devel/enumprivs2
-rwxr-xr-xsource4/scripting/devel/getncchanges2
14 files changed, 32 insertions, 31 deletions
diff --git a/source4/scripting/bin/enablerecyclebin b/source4/scripting/bin/enablerecyclebin
index ab36ead1b8f..a179698b7fe 100755
--- a/source4/scripting/bin/enablerecyclebin
+++ b/source4/scripting/bin/enablerecyclebin
@@ -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")
diff --git a/source4/scripting/bin/findprovisionusnranges b/source4/scripting/bin/findprovisionusnranges
index ee9da3d421e..540869dbae4 100755
--- a/source4/scripting/bin/findprovisionusnranges
+++ b/source4/scripting/bin/findprovisionusnranges
@@ -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)
diff --git a/source4/scripting/bin/fullschema b/source4/scripting/bin/fullschema
index ab0e4e320bd..596de01b91c 100755
--- a/source4/scripting/bin/fullschema
+++ b/source4/scripting/bin/fullschema
@@ -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
diff --git a/source4/scripting/bin/get-descriptors b/source4/scripting/bin/get-descriptors
index f1a919c3748..70926cdccbb 100755
--- a/source4/scripting/bin/get-descriptors
+++ b/source4/scripting/bin/get-descriptors
@@ -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:
diff --git a/source4/scripting/bin/minschema b/source4/scripting/bin/minschema
index 477c69be54d..e70d79a3cf3 100755
--- a/source4/scripting/bin/minschema
+++ b/source4/scripting/bin/minschema
@@ -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
diff --git a/source4/scripting/bin/mymachinepw b/source4/scripting/bin/mymachinepw
index dc85ad1df44..91dc502a634 100755
--- a/source4/scripting/bin/mymachinepw
+++ b/source4/scripting/bin/mymachinepw
@@ -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]
diff --git a/source4/scripting/bin/rebuildextendeddn b/source4/scripting/bin/rebuildextendeddn
index 5a0ab1295a6..5f5e05da795 100755
--- a/source4/scripting/bin/rebuildextendeddn
+++ b/source4/scripting/bin/rebuildextendeddn
@@ -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()
diff --git a/source4/scripting/bin/sambaundoguididx b/source4/scripting/bin/sambaundoguididx
index 24a95e20d7f..a931601cf03 100755
--- a/source4/scripting/bin/sambaundoguididx
+++ b/source4/scripting/bin/sambaundoguididx
@@ -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"
diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus
index 473dbaf2ce4..c2834ab12ab 100755
--- a/source4/scripting/bin/smbstatus
+++ b/source4/scripting/bin/smbstatus
@@ -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"""
diff --git a/source4/scripting/devel/addlotscontacts b/source4/scripting/devel/addlotscontacts
index edf54b0bade..e8b2c1af1aa 100644
--- a/source4/scripting/devel/addlotscontacts
+++ b/source4/scripting/devel/addlotscontacts
@@ -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:
diff --git a/source4/scripting/devel/config_base b/source4/scripting/devel/config_base
index 0d495c5091b..e74c87486bf 100755
--- a/source4/scripting/devel/config_base
+++ b/source4/scripting/devel/config_base
@@ -37,4 +37,4 @@ for v in vars:
options = options.replace("${PREFIX}", prefix)
-print options
+print(options)
diff --git a/source4/scripting/devel/crackname b/source4/scripting/devel/crackname
index 2e1798511f3..0ae177c133f 100755
--- a/source4/scripting/devel/crackname
+++ b/source4/scripting/devel/crackname
@@ -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()
diff --git a/source4/scripting/devel/enumprivs b/source4/scripting/devel/enumprivs
index 6a040402ae3..33597f9388a 100755
--- a/source4/scripting/devel/enumprivs
+++ b/source4/scripting/devel/enumprivs
@@ -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))
diff --git a/source4/scripting/devel/getncchanges b/source4/scripting/devel/getncchanges
index 9b6361b3548..9c25e39f756 100755
--- a/source4/scripting/devel/getncchanges
+++ b/source4/scripting/devel/getncchanges
@@ -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()