[PATCH 5/5] samba.netcmd.domain: Fix python formatting; no unnecessary parentheses, break long line.

Jelmer Vernooij jelmer at samba.org
Fri Aug 29 17:57:30 MDT 2014


Change-Id: Id79d96df551e0b7b5371a0486da5ffde2c514eac
---
 python/samba/netcmd/domain.py | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py
index 9e9b30d..4817e7e 100644
--- a/python/samba/netcmd/domain.py
+++ b/python/samba/netcmd/domain.py
@@ -656,10 +656,10 @@ class cmd_domain_demote(Command):
         samdb = SamDB(session_info=system_session(), credentials=creds, lp=lp)
         if not server:
             res = samdb.search(expression='(&(objectClass=computer)(serverReferenceBL=*))', attrs=["dnsHostName", "name"])
-            if (len(res) == 0):
+            if len(res) == 0:
                 raise CommandError("Unable to search for servers")
 
-            if (len(res) == 1):
+            if len(res) == 1:
                 raise CommandError("You are the latest server in the domain")
 
             server = None
@@ -705,13 +705,15 @@ class cmd_domain_demote(Command):
                             samdb.get_config_basedn(),
                             samdb.get_root_basedn()):
                 try:
-                    sendDsReplicaSync(drsuapiBind, drsuapi_handle, ntds_guid, str(part), drsuapi.DRSUAPI_DRS_WRIT_REP)
+                    sendDsReplicaSync(drsuapiBind, drsuapi_handle, ntds_guid,
+                            str(part), drsuapi.DRSUAPI_DRS_WRIT_REP)
                 except drsException, e:
                     self.errf.write(
                         "Error while demoting, "
                         "re-enabling inbound replication\n")
                     dsa_options ^= DS_NTDSDSA_OPT_DISABLE_INBOUND_REPL
-                    nmsg["options"] = ldb.MessageElement(str(dsa_options), ldb.FLAG_MOD_REPLACE, "options")
+                    nmsg["options"] = ldb.MessageElement(str(dsa_options),
+                            ldb.FLAG_MOD_REPLACE, "options")
                     samdb.modify(nmsg)
                     raise CommandError("Error while sending a DsReplicaSync for partion %s" % str(part), e)
         try:
@@ -735,11 +737,12 @@ class cmd_domain_demote(Command):
             samdb.modify(nmsg)
             raise CommandError("Error while changing account control", e)
 
-        if (len(res) != 1):
+        if len(res) != 1:
             self.errf.write(
                 "Error while demoting, re-enabling inbound replication")
             dsa_options ^= DS_NTDSDSA_OPT_DISABLE_INBOUND_REPL
-            nmsg["options"] = ldb.MessageElement(str(dsa_options), ldb.FLAG_MOD_REPLACE, "options")
+            nmsg["options"] = ldb.MessageElement(str(dsa_options),
+                ldb.FLAG_MOD_REPLACE, "options")
             samdb.modify(nmsg)
             raise CommandError("Unable to find object with samaccountName = %s$"
                                " in the remote dc" % netbios_name.upper())
@@ -776,7 +779,7 @@ class cmd_domain_demote(Command):
         computer_dn = ldb.Dn(remote_samdb, "CN=Computers,%s" % str(remote_samdb.get_root_basedn()))
         res = remote_samdb.search(base=computer_dn, expression=rdn, scope=ldb.SCOPE_ONELEVEL)
 
-        if (len(res) != 0):
+        if len(res) != 0:
             res = remote_samdb.search(base=computer_dn, expression="%s-%d" % (rdn, i),
                                         scope=ldb.SCOPE_ONELEVEL)
             while(len(res) != 0 and i < 100):
-- 
2.1.0



More information about the samba-technical mailing list