summaryrefslogtreecommitdiff
path: root/python/samba
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2018-02-23 14:31:38 +0000
committerDouglas Bagnall <dbagnall@samba.org>2018-02-28 23:01:40 +0100
commit52729d35495db638c84caa8cc6f5ffdf0b670353 (patch)
treef89573cd96e174f4972e59072ddd3ef7ef606fbd /python/samba
parent91a5941f173caf3959df24c7702226b0088eeb86 (diff)
downloadsamba-52729d35495db638c84caa8cc6f5ffdf0b670353.tar.gz
samba-tool: convert 'except X, (tuple)' to 'except X as e'
In addition to converting the except line another line is also added for each except to extract the tuple contents. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python/samba')
-rw-r--r--python/samba/netcmd/domain.py12
-rw-r--r--python/samba/netcmd/drs.py3
-rw-r--r--python/samba/netcmd/fsmo.py24
-rw-r--r--python/samba/netcmd/ldapcmp.py12
-rw-r--r--python/samba/netcmd/user.py24
5 files changed, 50 insertions, 25 deletions
diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py
index 52c70acfacc..7b23fa794de 100644
--- a/python/samba/netcmd/domain.py
+++ b/python/samba/netcmd/domain.py
@@ -841,7 +841,8 @@ class cmd_domain_demote(Command):
try:
drsuapiBind.DsReplicaSync(drsuapi_handle, 1, req1)
- except RuntimeError as (werr, string):
+ except RuntimeError as e1:
+ (werr, string) = e1.args
if werr == werror.WERR_DS_DRA_NO_REPLICA:
pass
else:
@@ -981,7 +982,8 @@ class cmd_domain_demote(Command):
req1.commit = 1
drsuapiBind.DsRemoveDSServer(drsuapi_handle, 1, req1)
- except RuntimeError as (werr, string):
+ except RuntimeError as e3:
+ (werr, string) = e3.args
if not (dsa_options & DS_NTDSDSA_OPT_DISABLE_OUTBOUND_REPL) and not samdb.am_rodc():
self.errf.write(
"Error while demoting, re-enabling inbound replication\n")
@@ -1193,7 +1195,8 @@ class cmd_domain_level(Command):
ldb.FLAG_MOD_REPLACE, "nTMixedDomain")
try:
samdb.modify(m)
- except ldb.LdbError, (enum, emsg):
+ except ldb.LdbError as e:
+ (enum, emsg) = e.args
if enum != ldb.ERR_UNWILLING_TO_PERFORM:
raise
@@ -1213,7 +1216,8 @@ class cmd_domain_level(Command):
"msDS-Behavior-Version")
try:
samdb.modify(m)
- except ldb.LdbError, (enum, emsg):
+ except ldb.LdbError as e2:
+ (enum, emsg) = e2.args
if enum != ldb.ERR_UNWILLING_TO_PERFORM:
raise
diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py
index 5498f098714..ebfabe186eb 100644
--- a/python/samba/netcmd/drs.py
+++ b/python/samba/netcmd/drs.py
@@ -202,7 +202,8 @@ class cmd_drs_showrepl(Command):
scope=ldb.SCOPE_BASE,
attrs=["dnsHostName"])
d['dns name'] = c_server_res[0]["dnsHostName"][0]
- except ldb.LdbError, (errno, _):
+ except ldb.LdbError as e:
+ (errno, _) = e.args
if errno == ldb.ERR_NO_SUCH_OBJECT:
d['is deleted'] = True
except KeyError:
diff --git a/python/samba/netcmd/fsmo.py b/python/samba/netcmd/fsmo.py
index c00e8dda45b..41e45592b46 100644
--- a/python/samba/netcmd/fsmo.py
+++ b/python/samba/netcmd/fsmo.py
@@ -40,7 +40,8 @@ def get_fsmo_roleowner(samdb, roledn, role):
try:
res = samdb.search(roledn,
scope=ldb.SCOPE_BASE, attrs=["fSMORoleOwner"])
- except LdbError, (num, msg):
+ except LdbError as e7:
+ (num, msg) = e7.args
if num == ldb.ERR_NO_SUCH_OBJECT:
raise CommandError("The '%s' role is not present in this domain" % role)
raise
@@ -74,7 +75,8 @@ def transfer_dns_role(outf, sambaopts, credopts, role, samdb):
res[0]['fSMORoleOwner'][0])
.get_extended_component('GUID')))
master_owner = str(ldb.Dn(samdb, res[0]['fSMORoleOwner'][0]))
- except LdbError, (num, msg):
+ except LdbError as e3:
+ (num, msg) = e3.args
raise CommandError("No GUID found in naming master DN %s : %s \n" %
(res[0]['fSMORoleOwner'][0], msg))
else:
@@ -109,7 +111,8 @@ def transfer_dns_role(outf, sambaopts, credopts, role, samdb):
try:
samdb.modify(m)
- except LdbError, (num, msg):
+ except LdbError as e4:
+ (num, msg) = e4.args
raise CommandError("Failed to delete role '%s': %s" %
(role, msg))
@@ -120,7 +123,8 @@ def transfer_dns_role(outf, sambaopts, credopts, role, samdb):
"fSMORoleOwner")
try:
samdb.modify(m)
- except LdbError, (num, msg):
+ except LdbError as e5:
+ (num, msg) = e5.args
raise CommandError("Failed to add role '%s': %s" % (role, msg))
try:
@@ -198,7 +202,8 @@ def transfer_role(outf, role, samdb):
if master_owner != new_owner:
try:
samdb.modify(m)
- except LdbError, (num, msg):
+ except LdbError as e6:
+ (num, msg) = e6.args
raise CommandError("Transfer of '%s' role failed: %s" %
(role, msg))
@@ -303,7 +308,8 @@ You must provide an Admin user and password."""),
# We may need to allocate the initial RID Set
samdb.create_own_rid_set()
- except LdbError, (num, msg):
+ except LdbError as e1:
+ (num, msg) = e1.args
if role == "rid" and num == ldb.ERR_ENTRY_ALREADY_EXISTS:
# Try again without the RID Set allocation
@@ -314,7 +320,8 @@ You must provide an Admin user and password."""),
samdb.transaction_start()
try:
samdb.modify(m)
- except LdbError, (num, msg):
+ except LdbError as e:
+ (num, msg) = e.args
samdb.transaction_cancel()
raise CommandError("Failed to seize '%s' role: %s" %
(role, msg))
@@ -378,7 +385,8 @@ You must provide an Admin user and password."""),
"fSMORoleOwner")
try:
samdb.modify(m)
- except LdbError, (num, msg):
+ except LdbError as e2:
+ (num, msg) = e2.args
raise CommandError("Failed to seize '%s' role: %s" %
(role, msg))
self.outf.write("FSMO seize of '%s' role successful\n" % role)
diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py
index 0c0a76cadba..87d45318553 100644
--- a/python/samba/netcmd/ldapcmp.py
+++ b/python/samba/netcmd/ldapcmp.py
@@ -122,7 +122,8 @@ class LDAPBase(object):
res = None
try:
res = self.ldb.search(base=object_dn, scope=SCOPE_BASE)
- except LdbError, (enum, estr):
+ except LdbError as e2:
+ (enum, estr) = e2.args
if enum == ERR_NO_SUCH_OBJECT:
return False
raise
@@ -784,7 +785,8 @@ class LDAPBundel(object):
summary=self.summary,
filter_list=self.filter_list,
outf=self.outf, errf=self.errf)
- except LdbError, (enum, estr):
+ except LdbError as e:
+ (enum, estr) = e.args
if enum == ERR_NO_SUCH_OBJECT:
self.log( "\n!!! Object not found: %s" % self.dn_list[index] )
skip = True
@@ -795,7 +797,8 @@ class LDAPBundel(object):
summary=other.summary,
filter_list=self.filter_list,
outf=self.outf, errf=self.errf)
- except LdbError, (enum, estr):
+ except LdbError as e1:
+ (enum, estr) = e1.args
if enum == ERR_NO_SUCH_OBJECT:
self.log( "\n!!! Object not found: %s" % other.dn_list[index] )
skip = True
@@ -851,7 +854,8 @@ class LDAPBundel(object):
raise StandardError("Wrong 'scope' given. Choose from: SUB, ONE, BASE")
try:
res = self.con.ldb.search(base=self.search_base, scope=self.search_scope, attrs=["dn"])
- except LdbError, (enum, estr):
+ except LdbError as e3:
+ (enum, estr) = e3.args
self.outf.write("Failed search of base=%s\n" % self.search_base)
raise
for x in res:
diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py
index 7feb0870dce..6eebf927613 100644
--- a/python/samba/netcmd/user.py
+++ b/python/samba/netcmd/user.py
@@ -1037,7 +1037,8 @@ class GetPasswordCommand(Command):
nthash = tmp.get_nt_hash()
if nthash == unicodePwd:
calculated["Primary:CLEARTEXT"] = cv
- except gpgme.GpgmeError as (major, minor, msg):
+ except gpgme.GpgmeError as e1:
+ (major, minor, msg) = e1.args
if major == gpgme.ERR_BAD_SECKEY:
msg = "ERR_BAD_SECKEY: " + msg
else:
@@ -1970,7 +1971,8 @@ samba-tool user syncpasswords --terminate \\
try:
self.lockfd = os.open(self.lockfile, flags, 0o600)
- except IOError as (err, msg):
+ except IOError as e4:
+ (err, msg) = e4.args
if err == errno.ENOENT:
if terminate:
return False
@@ -1982,7 +1984,8 @@ samba-tool user syncpasswords --terminate \\
try:
fcntl.lockf(self.lockfd, fcntl.LOCK_EX | fcntl.LOCK_NB)
got_exclusive = True
- except IOError as (err, msg):
+ except IOError as e5:
+ (err, msg) = e5.args
if err != errno.EACCES and err != errno.EAGAIN:
log_msg("check_current_pid_conflict: failed to get exclusive lock[%s] - %s (%d)" %
(self.lockfile, msg, err))
@@ -2001,7 +2004,8 @@ samba-tool user syncpasswords --terminate \\
if got_exclusive and terminate:
try:
os.ftruncate(self.lockfd, 0)
- except IOError as (err, msg):
+ except IOError as e2:
+ (err, msg) = e2.args
log_msg("check_current_pid_conflict: failed to truncate [%s] - %s (%d)" %
(self.lockfile, msg, err))
raise
@@ -2011,7 +2015,8 @@ samba-tool user syncpasswords --terminate \\
try:
fcntl.lockf(self.lockfd, fcntl.LOCK_SH)
- except IOError as (err, msg):
+ except IOError as e6:
+ (err, msg) = e6.args
log_msg("check_current_pid_conflict: failed to get shared lock[%s] - %s (%d)" %
(self.lockfile, msg, err))
@@ -2026,7 +2031,8 @@ samba-tool user syncpasswords --terminate \\
try:
fcntl.lockf(self.lockfd, fcntl.LOCK_EX | fcntl.LOCK_NB)
got_exclusive = True
- except IOError as (err, msg):
+ except IOError as e:
+ (err, msg) = e.args
if err != errno.EACCES and err != errno.EAGAIN:
log_msg("update_pid(%r): failed to get exclusive lock[%s] - %s (%d)" %
(pid, self.lockfile, msg, err))
@@ -2048,7 +2054,8 @@ samba-tool user syncpasswords --terminate \\
os.ftruncate(self.lockfd, 0)
if buf is not None:
os.write(self.lockfd, buf)
- except IOError as (err, msg):
+ except IOError as e3:
+ (err, msg) = e3.args
log_msg("check_current_pid_conflict: failed to write pid to [%s] - %s (%d)" %
(self.lockfile, msg, err))
raise
@@ -2279,7 +2286,8 @@ samba-tool user syncpasswords --terminate \\
try:
sync_loop(wait)
- except ldb.LdbError as (enum, estr):
+ except ldb.LdbError as e7:
+ (enum, estr) = e7.args
self.samdb = None
log_msg("ldb.LdbError(%d) => (%s)\n" % (enum, estr))