1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

s4-python: Various formatting fixes.

* Trailing whitespace
* use of "==" where "is" should be used
* double spaces
This commit is contained in:
Jelmer Vernooij 2012-09-27 09:30:47 -07:00
parent 6986f7bdda
commit 2a797f29aa
50 changed files with 311 additions and 309 deletions

View File

@ -132,8 +132,10 @@ class Parallel(object):
self.frozen = []
elif not self.count:
(jobs, tmp) = self.manager.get_next_set()
if jobs != None: self.maxjobs = jobs
if tmp: self.outstanding += tmp
if jobs is not None:
self.maxjobs = jobs
if tmp:
self.outstanding += tmp
break
def get_out(self):

View File

@ -62,9 +62,9 @@ def COMPOUND_END(conf, result):
conf.check_message_1 = conf.saved_check_message_1
conf.check_message_2 = conf.saved_check_message_2
p = conf.check_message_2
if result == True:
if result:
p('ok ')
elif result == False:
elif not result:
p('not found', 'YELLOW')
else:
p(result)
@ -241,7 +241,7 @@ def CHECK_FUNC(conf, f, link=True, lib=None, headers=None):
conf.COMPOUND_START('Checking for %s' % f)
if link is None or link == True:
if link is None or link:
ret = CHECK_CODE(conf,
# this is based on the autoconf strategy
'''
@ -284,7 +284,7 @@ def CHECK_FUNC(conf, f, link=True, lib=None, headers=None):
headers=headers,
msg='Checking for macro %s' % f)
if not ret and (link is None or link == False):
if not ret and (link is None or not link):
ret = CHECK_VARIABLE(conf, f,
define=define,
headers=headers,
@ -470,7 +470,7 @@ def CONFIG_SET(conf, option):
if option not in conf.env:
return False
v = conf.env[option]
if v == None:
if v is None:
return False
if v == []:
return False

View File

@ -136,7 +136,7 @@ def build_includes(self):
includes = []
# maybe add local includes
if getattr(self, 'local_include', True) == True and getattr(self, 'local_include_first', True):
if getattr(self, 'local_include', True) and getattr(self, 'local_include_first', True):
includes.append('.')
includes.extend(self.samba_includes_extended)
@ -153,7 +153,7 @@ def build_includes(self):
t = bld.name_to_obj(d, bld.env)
bld.ASSERT(t is not None, "Unable to find dependency %s for %s" % (d, self.sname))
inclist = getattr(t, 'samba_includes_extended', [])[:]
if getattr(t, 'local_include', True) == True:
if getattr(t, 'local_include', True):
inclist.append('.')
if inclist == []:
continue
@ -169,7 +169,7 @@ def build_includes(self):
relpath = os_path_relpath(inc, mypath)
includes.append(relpath)
if getattr(self, 'local_include', True) == True and not getattr(self, 'local_include_first', True):
if getattr(self, 'local_include', True) and not getattr(self, 'local_include_first', True):
includes.append('.')
# now transform the includes list to be relative to the top directory
@ -306,7 +306,7 @@ def check_orphaned_targets(bld, tgt_list):
debug('deps: checking for orphaned targets')
for t in tgt_list:
if getattr(t, 'samba_used', False) == True:
if getattr(t, 'samba_used', False):
continue
type = target_dict[t.sname]
if not type in ['BINARY', 'LIBRARY', 'MODULE', 'ET', 'PYTHON']:

View File

@ -101,7 +101,7 @@ def vcs_dir_contents(path):
def dist(appname='', version=''):
def add_files_to_tarball(tar, srcdir, srcsubdir, dstdir, dstsubdir, blacklist, files):
if blacklist == None:
if blacklist is None:
blacklist = []
for f in files:
abspath = os.path.join(srcdir, f)

View File

@ -121,7 +121,6 @@ def public_headers_simple(bld, public_headers, header_path=None, public_headers_
bld.INSTALL_FILES('${INCLUDEDIR}', h_name, destname=inst_name)
def PUBLIC_HEADERS(bld, public_headers, header_path=None, public_headers_install=True):
'''install some headers

View File

@ -256,7 +256,7 @@ def ENFORCE_GROUP_ORDERING(bld):
@feature('*')
@before('exec_rule', 'apply_core', 'collect')
def force_previous_groups(self):
if getattr(self.bld, 'enforced_group_ordering', False) == True:
if getattr(self.bld, 'enforced_group_ordering', False):
return
self.bld.enforced_group_ordering = True
@ -274,7 +274,7 @@ def ENFORCE_GROUP_ORDERING(bld):
debug('group: Forcing up to group %s for target %s',
group_name(g), self.name or self.target)
break
if stop != None:
if stop is not None:
break
if stop is None:
return

View File

@ -670,7 +670,7 @@ def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
bld.SET_BUILD_GROUP('build_source')
for s in TO_LIST(source):
iname = s
if installname != None:
if installname is not None:
iname = installname
target = os.path.join(installdir, iname)
tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))

View File

@ -150,11 +150,16 @@ class dnsobj(object):
raise Exception("Received unexpected DNS reply of type %s" % self.type)
def __str__(self):
if d.type == "A": return "%s %s %s" % (self.type, self.name, self.ip)
if d.type == "AAAA": return "%s %s %s" % (self.type, self.name, self.ip)
if d.type == "SRV": return "%s %s %s %s" % (self.type, self.name, self.dest, self.port)
if d.type == "CNAME": return "%s %s %s" % (self.type, self.name, self.dest)
if d.type == "NS": return "%s %s %s" % (self.type, self.name, self.dest)
if d.type == "A":
return "%s %s %s" % (self.type, self.name, self.ip)
if d.type == "AAAA":
return "%s %s %s" % (self.type, self.name, self.ip)
if d.type == "SRV":
return "%s %s %s %s" % (self.type, self.name, self.dest, self.port)
if d.type == "CNAME":
return "%s %s %s" % (self.type, self.name, self.dest)
if d.type == "NS":
return "%s %s %s" % (self.type, self.name, self.dest)
def parse_dns_line(line, sub_vars):

View File

@ -301,10 +301,10 @@ class KCC(object):
#
# Bit NTDSCONN_OPT_RODC_TOPOLOGY is clear in cn!options
if same_site:
if cn_conn.is_generated() == False:
if not cn_conn.is_generated():
continue
if self.my_site.is_cleanup_ntdsconn_disabled() == True:
if self.my_site.is_cleanup_ntdsconn_disabled():
continue
# Loop thru connections looking for a duplicate that
@ -328,10 +328,10 @@ class KCC(object):
(cn_conn.whenCreated == cn2_conn.whenCreated and
cmp(cn_conn.guid, cn2_conn.guid) < 0))
if lesser == True:
if lesser:
break
if lesser and cn_conn.is_rodc_topology() == False:
if lesser and not cn_conn.is_rodc_topology():
cn_conn.to_be_deleted = True
# Given an nTDSConnection object cn, if the DC with the nTDSDSA
@ -359,29 +359,29 @@ class KCC(object):
#
else: # different site
if mydsa.is_istg() == False:
if not mydsa.is_istg():
continue
if cn_conn.is_generated() == False:
if not cn_conn.is_generated():
continue
if self.keep_connection(cn_conn) == True:
if self.keep_connection(cn_conn):
continue
# XXX - To be implemented
if all_connected == False:
if not all_connected:
continue
if cn_conn.is_rodc_topology() == False:
if not cn_conn.is_rodc_topology():
cn_conn.to_be_deleted = True
if opts.readonly:
for dnstr, connect in mydsa.connect_table.items():
if connect.to_be_deleted == True:
if connect.to_be_deleted:
logger.info("TO BE DELETED:\n%s" % connect)
if connect.to_be_added == True:
if connect.to_be_added:
logger.info("TO BE ADDED:\n%s" % connect)
# Peform deletion from our tables but perform
@ -480,7 +480,7 @@ class KCC(object):
drsuapi.DRSUAPI_DRS_NEVER_NOTIFY) == 0x0:
t_repsFrom.replica_flags |= drsuapi.DRSUAPI_DRS_NEVER_NOTIFY
elif same_site == False:
elif not same_site:
if (t_repsFrom.replica_flags &
drsuapi.DRSUAPI_DRS_NEVER_NOTIFY) == 0x0:
@ -491,7 +491,7 @@ class KCC(object):
# not in the same site and the
# NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION bit is
# clear in cn!options
if (same_site == False and
if (not same_site and
(cn_conn.options &
dsdb.NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION) == 0x0):
@ -509,7 +509,7 @@ class KCC(object):
# Bits DRS_DISABLE_AUTO_SYNC and DRS_DISABLE_PERIODIC_SYNC are
# set in t.replicaFlags if and only if cn!enabledConnection = false.
if cn_conn.is_enabled() == False:
if not cn_conn.is_enabled():
if (t_repsFrom.replica_flags &
drsuapi.DRSUAPI_DRS_DISABLE_AUTO_SYNC) == 0x0:
@ -586,10 +586,10 @@ class KCC(object):
# We're not currently supporting SMTP replication
# so is_smtp_replication_available() is currently
# always returning False
if (same_site == True or
cn_conn.transport_dnstr == None or
if (same_site or
cn_conn.transport_dnstr is None or
cn_conn.transport_dnstr.find("CN=IP") == 0 or
is_smtp_replication_available() == False):
not is_smtp_replication_available()):
if (t_repsFrom.replica_flags &
drsuapi.DRSUAPI_DRS_MAIL_REP) != 0x0:
@ -614,14 +614,14 @@ class KCC(object):
t_repsFrom.dns_name2 = nastr
else:
if (t_repsFrom.replica_flags & \
if (t_repsFrom.replica_flags &
drsuapi.DRSUAPI_DRS_MAIL_REP) == 0x0:
t_repsFrom.replica_flags |= drsuapi.DRSUAPI_DRS_MAIL_REP
# We have a transport type but its not an
# object in the database
if cn_conn.transport_dnstr not in self.transport_table.keys():
raise Exception("Missing inter-site transport - (%s)" % \
raise Exception("Missing inter-site transport - (%s)" %
cn_conn.transport_dnstr)
x_transport = self.transport_table[cn_conn.transport_dnstr]
@ -656,7 +656,7 @@ class KCC(object):
attrs=attrs)
except ldb.ldbError, (enum, estr):
raise Exception \
("Unable to find attr (%s) for (%s) - (%s)" % \
("Unable to find attr (%s) for (%s) - (%s)" %
(x_transport.address_attr, pdnstr, estr))
msg = res[0]
@ -696,15 +696,14 @@ class KCC(object):
# cn!fromServer references an nTDSDSA object.
s_dsa = None
if cn_conn.is_enabled() == True and \
cn_conn.is_rodc_topology() == False:
if cn_conn.is_enabled() and not cn_conn.is_rodc_topology():
s_dnstr = cn_conn.get_from_dnstr()
if s_dnstr is not None:
s_dsa = self.get_dsa(s_dnstr)
# No DSA matching this source DN string?
if s_dsa == None:
if s_dsa is None:
return False, None
# To imply a repsFrom tuple is needed, each of these
@ -718,7 +717,7 @@ class KCC(object):
# the local DC
s_rep = s_dsa.get_current_replica(n_rep.nc_dnstr)
if s_rep is None or s_rep.is_present() == False:
if s_rep is None or not s_rep.is_present():
return False, None
# To imply a repsFrom tuple is needed, each of these
@ -733,10 +732,10 @@ class KCC(object):
# replica, cn!transportType has no value, or
# cn!transportType has an RDN of CN=IP.
#
implied = (s_rep.is_ro() == False or n_rep.is_partial() == True) and \
(n_rep.is_domain() == False or
n_rep.is_partial() == True or
cn_conn.transport_dnstr == None or
implied = (not s_rep.is_ro() or n_rep.is_partial()) and \
(not n_rep.is_domain() or
n_rep.is_partial() or
cn_conn.transport_dnstr is None or
cn_conn.transport_dnstr.find("CN=IP") == 0)
if implied:
@ -815,7 +814,7 @@ class KCC(object):
# is a child of the local DC's nTDSDSA object and
# (cn!fromServer = s) and (cn!options) does not contain
# NTDSCONN_OPT_RODC_TOPOLOGY or NULL if no such (cn) exists.
if cn_conn and cn_conn.is_rodc_topology() == True:
if cn_conn and cn_conn.is_rodc_topology():
cn_conn = None
# KCC removes this repsFrom tuple if any of the following
@ -831,8 +830,8 @@ class KCC(object):
s_rep = s_dsa.get_current_replica(n_rep.nc_dnstr)
if cn_conn is None or \
s_rep is None or s_rep.is_present() == False or \
(n_rep.is_ro() == False and s_rep.is_partial() == True):
s_rep is None or not s_rep.is_present() or \
(not n_rep.is_ro() and s_rep.is_partial()):
t_repsFrom.to_be_deleted = True
continue
@ -846,7 +845,7 @@ class KCC(object):
for cn_dnstr, cn_conn in self.my_dsa.connect_table.items():
implied, s_dsa = self.is_repsFrom_implied(n_rep, cn_conn)
if implied == False:
if not implied:
continue
# Loop thru the existing repsFrom tupples (if any) and
@ -860,7 +859,7 @@ class KCC(object):
s_dsa = None
break
if s_dsa == None:
if s_dsa is None:
continue
# Create a new RepsFromTo and proceed to modify
@ -995,7 +994,7 @@ class KCC(object):
# Skip dc
if self.my_site.same_site(dsa):
needed, ro, partial = part.should_be_present(dsa)
if needed == False or (partial == True and partial_ok == False):
if not needed or (partial and not partial_ok):
continue
# ELSE
@ -1005,7 +1004,7 @@ class KCC(object):
# Skip dc
else:
rep = dsa.get_current_replica(part.nc_dnstr)
if rep is None or (rep.is_partial() and partial_ok == False):
if rep is None or (rep.is_partial() and not partial_ok):
continue
# IF AmIRODC() and cr!nCName corresponds to default NC then
@ -1013,7 +1012,7 @@ class KCC(object):
# IF dsaobj.msDS-Behavior-Version < DS_BEHAVIOR_WIN2008
# Skip dc
if self.my_dsa.is_ro() and part.is_default():
if dsa.is_minimum_behavior(DS_BEHAVIOR_WIN2008) == False:
if not dsa.is_minimum_behavior(DS_BEHAVIOR_WIN2008):
continue
# IF t!name != "IP" and the parent object of dc has no value for
@ -1036,7 +1035,7 @@ class KCC(object):
# IF BridgeheadDCFailed(dc!objectGUID, detectFailedDCs) = TRUE
# Skip dc
if self.is_bridgehead_failed(dsa, detect_failed) == True:
if self.is_bridgehead_failed(dsa, detect_failed):
continue
logger.debug("get_all_bridgeheads: dsadn=%s" % dsa.dsa_dnstr)
@ -1048,7 +1047,7 @@ class KCC(object):
# servers, and otherwise by ascending objectGUID
# ELSE
# SORT bhs in a random order
if site.is_random_bridgehead_disabled() == True:
if site.is_random_bridgehead_disabled():
bhs.sort(sort_dsa_by_gc_and_guid)
else:
random.shuffle(bhs)
@ -1132,8 +1131,8 @@ class KCC(object):
# IF bits NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT and
# NTDSCONN_OPT_USE_NOTIFY are set in cn
if cn.is_override_notify_default() == True and \
cn.is_use_notify() == True:
if cn.is_override_notify_default() and \
cn.is_use_notify():
# IF bit NTDSSITELINK_OPT_USE_NOTIFY is clear in
# ri.Options
@ -1142,7 +1141,7 @@ class KCC(object):
# NTDSCONN_OPT_USE_NOTIFY in cn!options
if (link_opt & dsdb.NTDSSITELINK_OPT_USE_NOTIFY) == 0:
cn.options &= \
~(dsdb.NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT | \
~(dsdb.NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT |
dsdb.NTDSCONN_OPT_USE_NOTIFY)
cn.set_modified(True)
@ -1156,13 +1155,13 @@ class KCC(object):
# NTDSCONN_OPT_USE_NOTIFY in cn!options
if (link_opt & dsdb.NTDSSITELINK_OPT_USE_NOTIFY) != 0:
cn.options |= \
(dsdb.NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT | \
(dsdb.NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT |
dsdb.NTDSCONN_OPT_USE_NOTIFY)
cn.set_modified(True)
# IF bit NTDSCONN_OPT_TWOWAY_SYNC is set in cn!options
if cn.is_twoway_sync() == True:
if cn.is_twoway_sync():
# IF bit NTDSSITELINK_OPT_TWOWAY_SYNC is clear in
# ri.Options
@ -1186,14 +1185,14 @@ class KCC(object):
# IF bit NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION is set
# in cn!options
if cn.is_intersite_compression_disabled() == True:
if cn.is_intersite_compression_disabled():
# IF bit NTDSSITELINK_OPT_DISABLE_COMPRESSION is clear
# in ri.Options
# Perform an originating update to clear bit
# NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION in
# cn!options
if (link_opt & \
if (link_opt &
dsdb.NTDSSITELINK_OPT_DISABLE_COMPRESSION) == 0:
cn.options &= \
~dsdb.NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION
@ -1206,7 +1205,7 @@ class KCC(object):
# Perform an originating update to set bit
# NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION in
# cn!options
if (link_opt & \
if (link_opt &
dsdb.NTDSSITELINK_OPT_DISABLE_COMPRESSION) != 0:
cn.options |= \
dsdb.NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION
@ -1214,7 +1213,7 @@ class KCC(object):
# Display any modified connection
if opts.readonly:
if cn.to_be_modified == True:
if cn.to_be_modified:
logger.info("TO BE MODIFIED:\n%s" % cn)
ldsa.commit_connections(self.samdb, ro=True)
@ -1295,7 +1294,7 @@ class KCC(object):
# Display any added connection
if opts.readonly:
if cn.to_be_added == True:
if cn.to_be_added:
logger.info("TO BE ADDED:\n%s" % cn)
lbh.commit_connections(self.samdb, ro=True)
@ -1658,7 +1657,7 @@ class KCC(object):
# If we haven't been told to turn off stale connection
# detection and this dsa has a stale connection then
# continue
if detect_stale and self.is_stale_link_connection(dc_s) == True:
if detect_stale and self.is_stale_link_connection(dc_s):
continue
# Replica meets criteria. Add it to table indexed
@ -1669,7 +1668,7 @@ class KCC(object):
# on the local DC, append to R each partial replica (p of x)
# such that p "is present" on a DC satisfying the same
# criteria defined above for full replica DCs.
if partial == True:
if partial:
# Now we loop thru all the DSAs looking for
# partial NC replicas that match the naming
@ -1731,7 +1730,7 @@ class KCC(object):
# If we haven't been told to turn off stale connection
# detection and this dsa has a stale connection then
# continue
if detect_stale and self.is_stale_link_connection(dc_s) == True:
if detect_stale and self.is_stale_link_connection(dc_s):
continue
# Replica meets criteria. Add it to table indexed
@ -1808,11 +1807,11 @@ class KCC(object):
findex = rindex = random.randint(0, r_len-1)
# while this node doesn't have sufficient edges
while tnode.has_sufficient_edges() == False:
while not tnode.has_sufficient_edges():
# If this edge can be successfully added (i.e. not
# the same node and edge doesn't already exist) then
# select a new random index for the next round
if tnode.add_edge_from(graph_list[rindex].dsa_dnstr) == True:
if tnode.add_edge_from(graph_list[rindex].dsa_dnstr):
findex = rindex = random.randint(0, r_len-1)
else:
# Otherwise continue looking against each node
@ -1850,7 +1849,7 @@ class KCC(object):
if mysite.is_intrasite_topology_disabled():
return
detect_stale = (mysite.is_detect_stale_disabled() == False)
detect_stale = (not mysite.is_detect_stale_disabled())
# Loop thru all the partitions.
for partdn, part in self.part_table.items():
@ -1890,11 +1889,11 @@ class KCC(object):
if opts.readonly:
# Display any to be added or modified repsFrom
for dnstr, connect in mydsa.connect_table.items():
if connect.to_be_deleted == True:
if connect.to_be_deleted:
logger.info("TO BE DELETED:\n%s" % connect)
if connect.to_be_modified == True:
if connect.to_be_modified:
logger.info("TO BE MODIFIED:\n%s" % connect)
if connect.to_be_added == True:
if connect.to_be_added:
logger.info("TO BE ADDED:\n%s" % connect)
mydsa.commit_connections(self.samdb, ro=True)
@ -2330,9 +2329,9 @@ def sort_replica_by_dsa_guid(rep1, rep2):
return cmp(rep1.rep_dsa_guid, rep2.rep_dsa_guid)
def sort_dsa_by_gc_and_guid(dsa1, dsa2):
if dsa1.is_gc() == True and dsa2.is_gc() == False:
if dsa1.is_gc() and not dsa2.is_gc():
return -1
if dsa1.is_gc() == False and dsa2.is_gc() == True:
if not dsa1.is_gc() and dsa2.is_gc():
return +1
return cmp(dsa1.dsa_guid, dsa2.dsa_guid)

View File

@ -961,8 +961,8 @@ def checkKeepAttributeWithMetadata(delta, att, message, reference, current,
message(CHANGESD, "%ssd are not identical:\n%s" % (txt, diff))
txt = ""
if attrUSN == -1:
message(CHANGESD, "But the SD has been changed by someonelse "\
"so it's impossible to know if the difference"\
message(CHANGESD, "But the SD has been changed by someonelse "
"so it's impossible to know if the difference"
" cames from the modification or from a previous bug")
dnNotToRecalculate.append(str(dn))
else:
@ -1342,7 +1342,7 @@ def rebuild_sd(samdb, names):
listKeys.sort(dn_sort)
if len(dnToRecalculate) != 0:
message(CHANGESD, "%d DNs have been marked as needed to be recalculated"\
message(CHANGESD, "%d DNs have been marked as needed to be recalculated"
", recalculating %d due to inheritance"
% (len(dnToRecalculate), len(listKeys)))
@ -1372,7 +1372,7 @@ def hasATProvision(samdb):
scope=SCOPE_BASE,
attrs=["dn"])
if entry != None and len(entry) == 1:
if entry is not None and len(entry) == 1:
return True
else:
return False
@ -1695,10 +1695,10 @@ if __name__ == '__main__':
v = v + 1
message(CHANGE,
"Find last provision USN, %d invocation(s) for a total of %d ranges" % \
"Find last provision USN, %d invocation(s) for a total of %d ranges" %
(len(lastProvisionUSNs.keys()), v /2 ))
if lastProvisionUSNs.get("default") != None:
if lastProvisionUSNs.get("default") is not None:
message(CHANGE, "Old style for usn ranges used")
lastProvisionUSNs[str(names.invocation)] = lastProvisionUSNs["default"]
del lastProvisionUSNs["default"]
@ -1709,7 +1709,7 @@ if __name__ == '__main__':
minobj = 5
(hash_id, nb_obj) = findprovisionrange(ldbs.sam, ldb.Dn(ldbs.sam, str(names.rootdn)))
message(SIMPLE, "Here is a list of changes that modified more than %d objects in 1 minute." % minobj)
message(SIMPLE, "Usually changes made by provision and upgradeprovision are those who affect a couple"\
message(SIMPLE, "Usually changes made by provision and upgradeprovision are those who affect a couple"
" of hundred of objects or more")
message(SIMPLE, "Total number of objects: %d" % nb_obj)
message(SIMPLE, "")

View File

@ -105,7 +105,7 @@ class Ldb(_Ldb):
# Allow admins to force non-sync ldb for all databases
if lp is not None:
nosync_p = lp.get("nosync", "ldb")
if nosync_p is not None and nosync_p == True:
if nosync_p is not None and nosync_p:
flags |= ldb.FLG_NOSYNC
self.set_create_perms(0600)

View File

@ -473,7 +473,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
if is_deleted and not target_is_deleted and reverse_link_name is not None:
revealed_dn = self.find_revealed_link(obj.dn, attrname, guid)
rmd_flags = revealed_dn.dn.get_extended_component("RMD_FLAGS")
if rmd_flags != None and (int(rmd_flags) & 1) == 0:
if rmd_flags is not None and (int(rmd_flags) & 1) == 0:
# the RMD_FLAGS for this link should be 1, as the target is deleted
self.err_incorrect_rmd_flags(obj, attrname, revealed_dn)
continue

View File

@ -246,7 +246,7 @@ class drs_Replicate(object):
while True:
(level, ctr) = self.drs.DsGetNCChanges(self.drs_handle, req_level, req)
if ctr.first_object == None and ctr.object_count != 0:
if ctr.first_object is None and ctr.object_count != 0:
raise RuntimeError("DsGetNCChanges: NULL first_object with object_count=%u" % (ctr.object_count))
self.net.replicate_chunk(self.replication_state, level, ctr,
schema=schema, req_level=req_level, req=req)

View File

@ -73,7 +73,7 @@ class NamingContext(object):
scope=ldb.SCOPE_BASE, attrs=attrs)
except ldb.LdbError, (enum, estr):
raise Exception("Unable to find naming context (%s)" % \
raise Exception("Unable to find naming context (%s)" %
(self.nc_dnstr, estr))
msg = res[0]
if "objectGUID" in msg:
@ -213,7 +213,7 @@ class NCReplica(NamingContext):
def set_instantiated_flags(self, flags=None):
'''Set or clear NC replica instantiated flags'''
if (flags == None):
if flags is None:
self.rep_instantiated_flags = 0
else:
self.rep_instantiated_flags = flags
@ -337,7 +337,7 @@ class NCReplica(NamingContext):
# replacement list. Build a list
# of to be deleted reps which we will
# remove from rep_repsFrom list below
if repsFrom.to_be_deleted == True:
if repsFrom.to_be_deleted:
delreps.append(repsFrom)
modify = True
continue
@ -361,7 +361,7 @@ class NCReplica(NamingContext):
# need to be deleted or input option has informed
# us to be "readonly" (ro). Leave database
# record "as is"
if modify == False or ro == True:
if not modify or ro:
return
m = ldb.Message()
@ -380,7 +380,7 @@ class NCReplica(NamingContext):
def dumpstr_to_be_deleted(self):
text=""
for repsFrom in self.rep_repsFrom:
if repsFrom.to_be_deleted == True:
if repsFrom.to_be_deleted:
if text:
text = text + "\n%s" % repsFrom
else:
@ -390,7 +390,7 @@ class NCReplica(NamingContext):
def dumpstr_to_be_modified(self):
text=""
for repsFrom in self.rep_repsFrom:
if repsFrom.is_modified() == True:
if repsFrom.is_modified():
if text:
text = text + "\n%s" % repsFrom
else:
@ -948,13 +948,13 @@ class NTDSConnection(object):
self.to_be_deleted = False
# No database modification requested
if ro == True:
if ro:
return
try:
samdb.delete(self.dnstr)
except ldb.LdbError, (enum, estr):
raise Exception("Could not delete nTDSConnection for (%s) - (%s)" % \
raise Exception("Could not delete nTDSConnection for (%s) - (%s)" %
(self.dnstr, estr))
def commit_added(self, samdb, ro=False):
@ -966,7 +966,7 @@ class NTDSConnection(object):
self.to_be_added = False
# No database modification requested
if ro == True:
if ro:
return
# First verify we don't have this entry to ensure nothing
@ -979,10 +979,10 @@ class NTDSConnection(object):
except ldb.LdbError, (enum, estr):
if enum != ldb.ERR_NO_SUCH_OBJECT:
raise Exception("Unable to search for (%s) - (%s)" % \
raise Exception("Unable to search for (%s) - (%s)" %
(self.dnstr, estr))
if found:
raise Exception("nTDSConnection for (%s) already exists!" % \
raise Exception("nTDSConnection for (%s) already exists!" %
self.dnstr)
if self.enabled:
@ -995,10 +995,10 @@ class NTDSConnection(object):
m.dn = ldb.Dn(samdb, self.dnstr)
m["objectClass"] = \
ldb.MessageElement("nTDSConnection", ldb.FLAG_MOD_ADD, \
ldb.MessageElement("nTDSConnection", ldb.FLAG_MOD_ADD,
"objectClass")
m["showInAdvancedViewOnly"] = \
ldb.MessageElement("TRUE", ldb.FLAG_MOD_ADD, \
ldb.MessageElement("TRUE", ldb.FLAG_MOD_ADD,
"showInAdvancedViewOnly")
m["enabledConnection"] = \
ldb.MessageElement(enablestr, ldb.FLAG_MOD_ADD, "enabledConnection")
@ -1007,12 +1007,12 @@ class NTDSConnection(object):
m["options"] = \
ldb.MessageElement(str(self.options), ldb.FLAG_MOD_ADD, "options")
m["systemFlags"] = \
ldb.MessageElement(str(self.system_flags), ldb.FLAG_MOD_ADD, \
ldb.MessageElement(str(self.system_flags), ldb.FLAG_MOD_ADD,
"systemFlags")
if self.transport_dnstr is not None:
m["transportType"] = \
ldb.MessageElement(str(self.transport_dnstr), ldb.FLAG_MOD_ADD, \
ldb.MessageElement(str(self.transport_dnstr), ldb.FLAG_MOD_ADD,
"transportType")
if self.schedule is not None:
@ -1022,7 +1022,7 @@ class NTDSConnection(object):
try:
samdb.add(m)
except ldb.LdbError, (enum, estr):
raise Exception("Could not add nTDSConnection for (%s) - (%s)" % \
raise Exception("Could not add nTDSConnection for (%s) - (%s)" %
(self.dnstr, estr))
def commit_modified(self, samdb, ro=False):
@ -1034,7 +1034,7 @@ class NTDSConnection(object):
self.to_be_modified = False
# No database modification requested
if ro == True:
if ro:
return
# First verify we have this entry to ensure nothing
@ -1047,9 +1047,9 @@ class NTDSConnection(object):
if enum == ldb.ERR_NO_SUCH_OBJECT:
found = False
else:
raise Exception("Unable to search for (%s) - (%s)" % \
raise Exception("Unable to search for (%s) - (%s)" %
(self.dnstr, estr))
if found == False:
if not found:
raise Exception("nTDSConnection for (%s) doesn't exist!" %
self.dnstr)
@ -1143,7 +1143,7 @@ class NTDSConnection(object):
sched.headerArray[i].offset:
return False
for a, b in zip(self.schedule.dataArray[i].slots, \
for a, b in zip(self.schedule.dataArray[i].slots,
sched.dataArray[i].slots):
if a != b:
return False
@ -1617,7 +1617,7 @@ class Site(object):
# If readonly database then do not perform a
# persistent update
if ro == True:
if ro:
return True
# Perform update to the samdb
@ -1767,7 +1767,7 @@ class GraphNode(object):
# the DC on which ri "is present".
#
# c.options does not contain NTDSCONN_OPT_RODC_TOPOLOGY
if connect and connect.is_rodc_topology() == False:
if connect and not connect.is_rodc_topology():
exists = True
else:
exists = False
@ -2157,7 +2157,7 @@ class Vertex(object):
# We have a full replica which is the largest
# value so exit
if rep.is_partial() == False:
if not rep.is_partial():
self.color = VertexColor.red
break
else:

View File

@ -158,7 +158,7 @@ class Command(object):
undetermined_max_args = True
else:
max_args += 1
if (len(args) < min_args) or (undetermined_max_args == False and len(args) > max_args):
if (len(args) < min_args) or (not undetermined_max_args and len(args) > max_args):
parser.print_usage()
return -1

View File

@ -173,9 +173,9 @@ class cmd_domain_provision(Command):
help="choose machine password (otherwise random)"),
Option("--dns-backend", type="choice", metavar="NAMESERVER-BACKEND",
choices=["SAMBA_INTERNAL", "BIND9_FLATFILE", "BIND9_DLZ", "NONE"],
help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " \
"BIND9_FLATFILE uses bind9 text database to store zone information, " \
"BIND9_DLZ uses samba4 AD to store zone information, " \
help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), "
"BIND9_FLATFILE uses bind9 text database to store zone information, "
"BIND9_DLZ uses samba4 AD to store zone information, "
"NONE skips the DNS setup entirely (not recommended)",
default="SAMBA_INTERNAL"),
Option("--dnspass", type="string", metavar="PASSWORD",
@ -452,8 +452,8 @@ class cmd_domain_dcpromo(Command):
action="store_true"),
Option("--dns-backend", type="choice", metavar="NAMESERVER-BACKEND",
choices=["SAMBA_INTERNAL", "BIND9_DLZ", "NONE"],
help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " \
"BIND9_DLZ uses samba4 AD to store zone information, " \
help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), "
"BIND9_DLZ uses samba4 AD to store zone information, "
"NONE skips the DNS setup entirely (this DC will not be a DNS server)",
default="SAMBA_INTERNAL")
]
@ -518,8 +518,8 @@ class cmd_domain_join(Command):
action="store_true"),
Option("--dns-backend", type="choice", metavar="NAMESERVER-BACKEND",
choices=["SAMBA_INTERNAL", "BIND9_DLZ", "NONE"],
help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " \
"BIND9_DLZ uses samba4 AD to store zone information, " \
help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), "
"BIND9_DLZ uses samba4 AD to store zone information, "
"NONE skips the DNS setup entirely (this DC will not be a DNS server)",
default="SAMBA_INTERNAL")
]
@ -1223,9 +1223,9 @@ class cmd_domain_classicupgrade(Command):
action="store_true"),
Option("--dns-backend", type="choice", metavar="NAMESERVER-BACKEND",
choices=["SAMBA_INTERNAL", "BIND9_FLATFILE", "BIND9_DLZ", "NONE"],
help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " \
"BIND9_FLATFILE uses bind9 text database to store zone information, " \
"BIND9_DLZ uses samba4 AD to store zone information, " \
help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), "
"BIND9_FLATFILE uses bind9 text database to store zone information, "
"BIND9_DLZ uses samba4 AD to store zone information, "
"NONE skips the DNS setup entirely (this DC will not be a DNS server)",
default="SAMBA_INTERNAL")
]

View File

@ -28,14 +28,13 @@ import sys
import samba
import samba.getopt as options
from samba import Ldb
from samba.ndr import ndr_pack, ndr_unpack
from samba.ndr import ndr_unpack
from samba.dcerpc import security
from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, ERR_NO_SUCH_OBJECT, LdbError
from samba.netcmd import (
Command,
CommandError,
Option,
SuperCommand,
)
global summary
@ -103,7 +102,7 @@ class LDAPBase(object):
def find_servers(self):
"""
"""
res = self.ldb.search(base="OU=Domain Controllers,%s" % self.base_dn, \
res = self.ldb.search(base="OU=Domain Controllers,%s" % self.base_dn,
scope=SCOPE_SUBTREE, expression="(objectClass=computer)", attrs=["cn"])
assert len(res) > 0
srv = []
@ -112,7 +111,7 @@ class LDAPBase(object):
return srv
def find_netbios(self):
res = self.ldb.search(base="CN=Partitions,%s" % self.config_dn, \
res = self.ldb.search(base="CN=Partitions,%s" % self.config_dn,
scope=SCOPE_SUBTREE, attrs=["nETBIOSName"])
assert len(res) > 0
for x in res:

View File

@ -223,8 +223,7 @@ class cmd_ntacl_sysvolcheck(Command):
"versionopts": options.VersionOptions,
}
def run(self,
credopts=None, sambaopts=None, versionopts=None):
def run(self, credopts=None, sambaopts=None, versionopts=None):
lp = sambaopts.get_loadparm()
path = lp.private_path("secrets.ldb")
creds = credopts.get_credentials(lp)
@ -234,8 +233,7 @@ class cmd_ntacl_sysvolcheck(Command):
netlogon = lp.get("path", "netlogon")
sysvol = lp.get("path", "sysvol")
try:
samdb = SamDB(session_info=system_session(),
lp=lp)
samdb = SamDB(session_info=system_session(), lp=lp)
except Exception, e:
raise CommandError("Unable to open samdb:", e)

View File

@ -60,7 +60,7 @@ class cmd_spn_list(Command):
spns = res[0].get("servicePrincipalName")
found = False
flag = ldb.FLAG_MOD_ADD
if spns != None:
if spns is not None:
self.outf.write(
"User %s has the following servicePrincipalName: \n" %
res[0].dn)
@ -84,7 +84,7 @@ class cmd_spn_add(Command):
"versionopts": options.VersionOptions,
}
takes_options = [
Option("--force", help="Force the addition of the spn"\
Option("--force", help="Force the addition of the spn"
" even it exists already", action="store_true"),
]
takes_args = ["name", "user"]
@ -114,7 +114,7 @@ class cmd_spn_add(Command):
tab = []
found = False
flag = ldb.FLAG_MOD_ADD
if spns != None:
if spns is not None:
for e in spns:
if str(e) == name:
found = True
@ -172,8 +172,8 @@ class cmd_spn_delete(Command):
listUser = ""
for r in res:
listUser = "%s\n%s" % (listUser, str(r.dn))
raise CommandError("More than one user has the spn %s "\
"and no specific user was specified, list of users"\
raise CommandError("More than one user has the spn %s "
"and no specific user was specified, list of users"
" with this spn:%s" % (name, listUser))
else:
result=res[0]
@ -182,7 +182,7 @@ class cmd_spn_delete(Command):
msg = ldb.Message()
spns = result.get("servicePrincipalName")
tab = []
if spns != None:
if spns is not None:
for e in spns:
if str(e) != name:
tab.append(str(e))

View File

@ -144,14 +144,14 @@ def ldapmask2filemask(ldm):
filemask = ldm & STANDARD_RIGHTS_ALL
if (ldm & RIGHT_DS_READ_PROPERTY) and (ldm & RIGHT_DS_LIST_CONTENTS):
filemask = filemask | (SYNCHRONIZE | FILE_LIST_DIRECTORY |\
FILE_READ_ATTRIBUTES | FILE_READ_EA |\
filemask = filemask | (SYNCHRONIZE | FILE_LIST_DIRECTORY |
FILE_READ_ATTRIBUTES | FILE_READ_EA |
FILE_READ_DATA | FILE_EXECUTE)
if ldm & RIGHT_DS_WRITE_PROPERTY:
filemask = filemask | (SYNCHRONIZE | FILE_WRITE_DATA |\
FILE_APPEND_DATA | FILE_WRITE_EA |\
FILE_WRITE_ATTRIBUTES | FILE_ADD_FILE |\
filemask = filemask | (SYNCHRONIZE | FILE_WRITE_DATA |
FILE_APPEND_DATA | FILE_WRITE_EA |
FILE_WRITE_ATTRIBUTES | FILE_ADD_FILE |
FILE_ADD_SUBDIRECTORY)
if ldm & RIGHT_DS_CREATE_CHILD:

View File

@ -358,7 +358,7 @@ def get_last_provision_usn(sam):
if (len(myids) > 0 and id not in myids):
continue
tab2 = p.split(tab1[0])
if range.get(id) == None:
if range.get(id) is None:
range[id] = []
range[id].append(tab2[0])
range[id].append(tab2[1])

View File

@ -47,13 +47,13 @@ class DNSTest(TestCase):
def assert_dns_rcode_equals(self, packet, rcode):
"Helper function to check return code"
p_errcode = packet.operation & 0x000F
self.assertEquals(p_errcode, rcode, "Expected RCODE %s, got %s" % \
self.assertEquals(p_errcode, rcode, "Expected RCODE %s, got %s" %
(self.errstr(rcode), self.errstr(p_errcode)))
def assert_dns_opcode_equals(self, packet, opcode):
"Helper function to check opcode"
p_opcode = packet.operation & 0x7800
self.assertEquals(p_opcode, opcode, "Expected OPCODE %s, got %s" % \
self.assertEquals(p_opcode, opcode, "Expected OPCODE %s, got %s" %
(opcode, p_opcode))
def make_name_packet(self, opcode, qid=None):

View File

@ -69,7 +69,7 @@ class GensecTests(samba.tests.TestCase):
server_to_client = ""
"""Run the actual call loop"""
while client_finished == False and server_finished == False:
while not client_finished and not server_finished:
if not client_finished:
print "running client gensec_update"
(client_finished, client_to_server) = self.gensec_client.update(server_to_client)
@ -118,7 +118,7 @@ class GensecTests(samba.tests.TestCase):
"""Run the actual call loop"""
i = 0
while client_finished == False or server_finished == False:
while not client_finished or not server_finished:
i += 1
if not client_finished:
print "running client gensec_update: %d: %r" % (len(server_to_client), server_to_client)

View File

@ -883,9 +883,9 @@ Please fix this account before attempting to upgrade again
s4_passdb.add_sam_account(userdata[username])
if username in uids:
add_ad_posix_idmap_entry(result.samdb, userdata[username].user_sid, uids[username], "ID_TYPE_UID", logger)
if (username in homes) and (homes[username] != None) and \
(username in shells) and (shells[username] != None) and \
(username in pgids) and (pgids[username] != None):
if (username in homes) and (homes[username] is not None) and \
(username in shells) and (shells[username] is not None) and \
(username in pgids) and (pgids[username] is not None):
add_posix_attrs(samdb=result.samdb, sid=userdata[username].user_sid, name=username, nisdomain=domainname.lower(), xid_type="ID_TYPE_UID", home=homes[username], shell=shells[username], pgid=pgids[username], logger=logger)
logger.info("Adding users to groups")

View File

@ -864,7 +864,7 @@ def findprovisionrange(samdb, basedn):
minutestamp =_glue.nttime2unix(o.originating_change_time)/60
hash_ts = hash_id.get(str(o.originating_invocation_id))
if hash_ts == None:
if hash_ts is None:
ob = {}
ob["min"] = o.originating_usn
ob["max"] = o.originating_usn
@ -873,7 +873,7 @@ def findprovisionrange(samdb, basedn):
hash_ts = {}
else:
ob = hash_ts.get(minutestamp)
if ob == None:
if ob is None:
ob = {}
ob["min"] = o.originating_usn
ob["max"] = o.originating_usn
@ -935,12 +935,12 @@ def print_provision_ranges(dic, limit_print, dest, samdb_path, invocationid):
for k in kept_record:
obj = hash_ts[k]
if obj.get("skipped") == None:
if obj.get("skipped") is None:
ldif = "%slastProvisionUSN: %d-%d;%s\n" % (ldif, obj["min"],
obj["max"], id)
if ldif != "":
if dest == None:
if dest is None:
dest = "/tmp"
file = tempfile.mktemp(dir=dest, prefix="usnprov", suffix=".ldif")