1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-25 17:57:42 +03:00

python/samba/emulate: Fix some more missed exception tuple assignments

In python3 we need to change

    except LdbError as e:
-        (status, _) = e
to
    except LdbError as e:
+        (status, _) = e.args

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
Noel Power 2018-05-09 20:17:30 +01:00 committed by Andrew Bartlett
parent d5cd9af7b5
commit 7d43571169
5 changed files with 18 additions and 18 deletions

View File

@ -1568,7 +1568,7 @@ def create_ou(ldb, instance_id):
ldb.add({"dn": ou.split(',', 1)[1],
"objectclass": "organizationalunit"})
except LdbError as e:
(status, _) = e
(status, _) = e.args
# ignore already exists
if status != 68:
raise
@ -1576,7 +1576,7 @@ def create_ou(ldb, instance_id):
ldb.add({"dn": ou,
"objectclass": "organizationalunit"})
except LdbError as e:
(status, _) = e
(status, _) = e.args
# ignore already exists
if status != 68:
raise
@ -1626,7 +1626,7 @@ def generate_traffic_accounts(ldb, instance_id, number, password):
create_machine_account(ldb, instance_id, netbios_name, password)
added += 1
except LdbError as e:
(status, _) = e
(status, _) = e.args
if status == 68:
break
else:
@ -1642,7 +1642,7 @@ def generate_traffic_accounts(ldb, instance_id, number, password):
create_user_account(ldb, instance_id, username, password)
added += 1
except LdbError as e:
(status, _) = e
(status, _) = e.args
if status == 68:
break
else:
@ -1728,7 +1728,7 @@ def generate_users(ldb, instance_id, number, password):
create_user_account(ldb, instance_id, username, password)
users += 1
except LdbError as e:
(status, _) = e
(status, _) = e.args
# Stop if entry exists
if status == 68:
break
@ -1752,7 +1752,7 @@ def generate_groups(ldb, instance_id, number):
create_group(ldb, instance_id, name)
groups += 1
except LdbError as e:
(status, _) = e
(status, _) = e.args
# Stop if entry exists
if status == 68:
break
@ -1767,7 +1767,7 @@ def clean_up_accounts(ldb, instance_id):
try:
ldb.delete(ou, ["tree_delete:1"])
except LdbError as e:
(status, _) = e
(status, _) = e.args
# ignore does not exist
if status != 32:
raise

View File

@ -1715,7 +1715,7 @@ class DomainTrustCommand(Command):
if runtime is None:
return False
err32 = self._uint32(runtime[0])
err32 = self._uint32(runtime.args[0])
if err32 == val:
return True
@ -1723,24 +1723,24 @@ class DomainTrustCommand(Command):
class LocalRuntimeError(CommandError):
def __init__(exception_self, self, runtime, message):
err32 = self._uint32(runtime[0])
errstr = runtime[1]
err32 = self._uint32(runtime.args[0])
errstr = runtime.args[1]
msg = "LOCAL_DC[%s]: %s - ERROR(0x%08X) - %s" % (
self.local_server, message, err32, errstr)
CommandError.__init__(exception_self, msg)
class RemoteRuntimeError(CommandError):
def __init__(exception_self, self, runtime, message):
err32 = self._uint32(runtime[0])
errstr = runtime[1]
err32 = self._uint32(runtime.args[0])
errstr = runtime.args[1]
msg = "REMOTE_DC[%s]: %s - ERROR(0x%08X) - %s" % (
self.remote_server, message, err32, errstr)
CommandError.__init__(exception_self, msg)
class LocalLdbError(CommandError):
def __init__(exception_self, self, ldb_error, message):
errval = ldb_error[0]
errstr = ldb_error[1]
errval = ldb_error.args[0]
errstr = ldb_error.args[1]
msg = "LOCAL_DC[%s]: %s - ERROR(%d) - %s" % (
self.local_server, message, errval, errstr)
CommandError.__init__(exception_self, msg)

View File

@ -57,7 +57,7 @@ class NetJoinTests(samba.tests.TestCaseInTempDir):
self.domain, netbios_name, LIBNET_JOIN_AUTOMATIC,
machinepass=machinepass)
except NTSTATUSError as e:
code = ctypes.c_uint32(e[0]).value
code = ctypes.c_uint32(e.args[0]).value
if code == ntstatus.NT_STATUS_CONNECTION_DISCONNECTED:
self.fail("Connection failure")
raise

View File

@ -57,7 +57,7 @@ class NetlogonServiceTests(TestCase):
except NTSTATUSError as e:
# On non-DC test environments, netlogon should not be running on
# the server, so we expect the test to fail here
enum = ctypes.c_uint32(e[0]).value
enum = ctypes.c_uint32(e.args[0]).value
if enum == ntstatus.NT_STATUS_OBJECT_NAME_NOT_FOUND:
self.fail("netlogon service is not running")
else:

View File

@ -56,7 +56,7 @@ class NtlmDisabledTests(TestCase):
self.assertIsNotNone(conn)
except NTSTATUSError as e:
# NTLM might be blocked on this server
enum = ctypes.c_uint32(e[0]).value
enum = ctypes.c_uint32(e.args[0]).value
if enum == ntstatus.NT_STATUS_NTLM_BLOCKED:
self.fail("NTLM is disabled on this server")
else:
@ -77,7 +77,7 @@ class NtlmDisabledTests(TestCase):
conn.ChangePasswordUser2(server, username, None, None, True, None, None)
except NTSTATUSError as e:
# changing passwords should be rejected when NTLM is disabled
enum = ctypes.c_uint32(e[0]).value
enum = ctypes.c_uint32(e.args[0]).value
if enum == ntstatus.NT_STATUS_NTLM_BLOCKED:
self.fail("NTLM is disabled on this server")
elif enum == ntstatus.NT_STATUS_WRONG_PASSWORD: