1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-27 07:42:04 +03:00

samba-tool: Use self.outf in a few more places.

Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Thu Oct 13 05:06:52 CEST 2011 on sn-devel-104
This commit is contained in:
Jelmer Vernooij
2011-10-13 00:36:44 +02:00
parent 0e70e26d92
commit 88d997a63e
13 changed files with 104 additions and 88 deletions

View File

@ -85,11 +85,15 @@ class LDAPBase(object):
# Log some domain controller specific place-holers that are being used
# when compare content of two DCs. Uncomment for DEBUG purposes.
if self.two_domains and not self.quiet:
print "\n* Place-holders for %s:" % self.host
print 4*" " + "${DOMAIN_DN} => %s" % self.base_dn
print 4*" " + "${DOMAIN_NETBIOS} => %s" % self.domain_netbios
print 4*" " + "${SERVER_NAME} => %s" % self.server_names
print 4*" " + "${DOMAIN_NAME} => %s" % self.domain_name
self.outf.write("\n* Place-holders for %s:\n" % self.host)
self.outf.write(4*" " + "${DOMAIN_DN} => %s\n" %
self.base_dn)
self.outf.write(4*" " + "${DOMAIN_NETBIOS} => %s\n" %
self.domain_netbios)
self.outf.write(4*" " + "${SERVER_NAME} => %s\n" %
self.server_names)
self.outf.write(4*" " + "${DOMAIN_NAME} => %s\n" %
self.domain_name)
def find_domain_sid(self):
res = self.ldb.search(base=self.base_dn, expression="(objectClass=*)", scope=SCOPE_BASE)
@ -493,7 +497,7 @@ class LDAPObject(object):
Log on the screen if there is no --quiet oprion set
"""
if not self.quiet:
print msg
self.outf.write(msg+"\n")
def fix_dn(self, s):
res = "%s" % s
@ -665,6 +669,7 @@ class LDAPObject(object):
class LDAPBundel(object):
def __init__(self, connection, context, dn_list=None, filter_list=None):
self.con = connection
self.two_domains = self.con.two_domains
@ -705,7 +710,7 @@ class LDAPBundel(object):
Log on the screen if there is no --quiet oprion set
"""
if not self.quiet:
print msg
self.outf.write(msg+"\n")
def update_size(self):
self.size = len(self.dn_list)
@ -820,7 +825,7 @@ class LDAPBundel(object):
try:
res = self.con.ldb.search(base=self.search_base, scope=self.search_scope, attrs=["dn"])
except LdbError, (enum, estr):
print("Failed search of base=%s" % self.search_base)
self.outf.write("Failed search of base=%s\n" % self.search_base)
raise
for x in res:
dn_list.append(x["dn"].get_linearized())
@ -842,6 +847,7 @@ class LDAPBundel(object):
self.log( "".join([str("\n" + 4*" " + x) for x in self.summary["df_value_attrs"]]) )
self.summary["df_value_attrs"] = []
class cmd_ldapcmp(Command):
"""compare two ldap databases"""
synopsis = "%prog ldapcmp <URL1> <URL2> (domain|configuration|schema) [options]"
@ -942,22 +948,23 @@ class cmd_ldapcmp(Command):
status = 0
for context in contexts:
if not quiet:
print "\n* Comparing [%s] context..." % context
self.outf.write("\n* Comparing [%s] context...\n" % context)
b1 = LDAPBundel(con1, context=context, filter_list=filter_list)
b2 = LDAPBundel(con2, context=context, filter_list=filter_list)
if b1 == b2:
if not quiet:
print "\n* Result for [%s]: SUCCESS" % context
self.outf.write("\n* Result for [%s]: SUCCESS\n" %
context)
else:
if not quiet:
print "\n* Result for [%s]: FAILURE" % context
self.outf.write("\n* Result for [%s]: FAILURE\n" % context)
if not descriptor:
assert len(b1.summary["df_value_attrs"]) == len(b2.summary["df_value_attrs"])
b2.summary["df_value_attrs"] = []
print "\nSUMMARY"
print "---------"
self.outf.write("\nSUMMARY\n")
self.outf.write("---------\n")
b1.print_summary()
b2.print_summary()
# mark exit status as FAILURE if a least one comparison failed