python/samba/emulate: Fix some more missed exception tuple assignments
authorNoel Power <noel.power@suse.com>
Wed, 9 May 2018 19:17:30 +0000 (20:17 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 Jul 2018 23:12:24 +0000 (01:12 +0200)
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>
python/samba/emulate/traffic.py
python/samba/netcmd/domain.py
python/samba/tests/net_join.py
python/samba/tests/netlogonsvc.py
python/samba/tests/ntlmdisabled.py

index dba2c3f32f9a9768926268dfe63a2f4c11bf82be..c96530b01643c490aa6ecdf3c00c665034b6dac7 100644 (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
index 86249073652cc0a01e002fcafae0b5e2c411333a..d50cf3f526c941b0d360618a6d5d7a7f76552eda 100644 (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)
index daba2d2e3bc3935ce7cf1d53c3482ca2f150b226..41220280e621251a7797e5daa865c921f99ec92e 100644 (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
index 87afa3e233eb200a45a09ccc759928579eb7a376..3dac66c71ccf57855bc2031019914a53c0b792c5 100644 (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:
index 90341a5cee3534b6c7a23c40058bc19694600365..dadebb327f5ed72e591616e6a9a06b72656aafd2 100644 (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: