The branch, master has been updated
       via  578786c buildtools python: convert 'except X, e' to 'except X as e'
       via  5fbb471 scripts/ python: convert 'except X, e' to 'except X as e'
       via  16e173a selftest and autrobuild: convert 'except X, e' to 'except X 
as e'
       via  bf2086e drs torture python: convert 'except X, e' to 'except X as e'
       via  f43cb7c source4/scripting python: convert 'except X, e' to 'except 
X as e'
       via  20e38fb dsdb python tests: convert 'except X, e' to 'except X as e'
       via  28134d0 samba python tests: convert 'except X, e' to 'except X as e'
       via  4885937 samba python libs: convert 'except X, e' to 'except X as e'
       via  a485ac3 samba-tool: convert 'except X, e' to 'except X as e' for 
all X
       via  278ac39 selftest: Avoid a build started around midnight failing 
(again)
       via  23ec302 smbspool: Initialize empty_str on declaration
       via  b415f92 selftest: GnuTLS is already mandetory to build the AD DC
       via  8e54bc4 selftest: Require jansson support for selftest of the AD DC
       via  a12925b test samba-tool drs showrepl: test --json output
       via  ed15a45 samba-tool drs showrepl: add --json option for JSON output
       via  90d0c63 samba-tool drs showrepl: restructure in preparation for 
--json
       via  2cd7097 test samba-tool drs showrepl: test expected output more 
strictly
       via  48248b7 test samba-tool drs showrepl: fix formatting and unused 
imports
       via  cec3646 tests: move samba-tool drs showrepl into its own suite
       via  92ec01d python.subunit: add assertRegexpMatches for Python 2.6
       via  70a85c1 python: tests: Make tests of dsdb Python module Python 3 
compatible
       via  dce18a0 python: Port dsdb module to Python 3 compatible form.
       via  bc7c6c1 python: Port samdb module to Python 3 compatible form
       via  cb15e32 python: Add `text_type` Python 2/3 compatible function name.
       via  7ee74f6 python: Port dsdb_dns module to Python 3 compatible form.
       via  a45e70b python: Convert base64 encoded password to utf-8
       via  298d812 python: Generate random test usernames
      from  ebd88eb docs: Add a not that 'wbinfo --user-groups' may be 
incomplete

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 578786c38b65e5c3925ab9f605cfd661d0950cc2
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Wed Feb 14 11:19:49 2018 +1300

    buildtools python: convert 'except X, e' to 'except X as e'
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abart...@samba.org>
    Autobuild-Date(master): Thu Feb 15 05:40:55 CET 2018 on sn-devel-144

commit 5fbb47144328b6bd4e52369c904d81633e5fdb02
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Wed Feb 14 10:36:22 2018 +1300

    scripts/ python: convert 'except X, e' to 'except X as e'
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 16e173ad2e52ed1140fd43cabdeec0bc4553f6d2
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Wed Feb 14 10:35:53 2018 +1300

    selftest and autrobuild: convert 'except X, e' to 'except X as e'
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit bf2086e137e00414669828991027d9c450fd0bcc
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Wed Feb 14 10:34:23 2018 +1300

    drs torture python: convert 'except X, e' to 'except X as e'
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit f43cb7c38d1945cdeca259b53a433c68803482d0
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Wed Feb 14 10:33:06 2018 +1300

    source4/scripting python: convert 'except X, e' to 'except X as e'
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 20e38fbd457a35e90662a284bead44b05393f54b
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Wed Feb 14 10:31:33 2018 +1300

    dsdb python tests: convert 'except X, e' to 'except X as e'
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 28134d002b632a7fcd52906604412889fc973ef5
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Wed Feb 14 10:27:52 2018 +1300

    samba python tests: convert 'except X, e' to 'except X as e'
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 4885937bf87e6c37c60cda890dc18d46b5868a91
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Wed Feb 14 10:18:36 2018 +1300

    samba python libs: convert 'except X, e' to 'except X as e'
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit a485ac32438b74315ffd4a7188909f00e175d4fa
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Wed Feb 14 10:07:23 2018 +1300

    samba-tool: convert 'except X, e' to 'except X as e' for all X
    
    This is needed for Python 3 and is compatible with python 2.6
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 278ac393844bcbb5df7a2e2d75b878e20fba323e
Author: Andrew Bartlett <abart...@samba.org>
Date:   Wed Feb 14 11:29:54 2018 +1300

    selftest: Avoid a build started around midnight failing (again)
    
    This case most likely relates to Daylight Saving changes creating
    a 23 hour day.
    
    Signed-off-by: Andrew Bartlett <abart...@samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>

commit 23ec3021224d797ab9d889d8152d8d7774da0226
Author: Andreas Schneider <a...@samba.org>
Date:   Fri Jan 5 10:43:18 2018 +0100

    smbspool: Initialize empty_str on declaration
    
    Signed-off-by: Andreas Schneider <a...@samba.org>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit b415f9202fcb05eb75513494c596bf30082ca63d
Author: Andrew Bartlett <abart...@samba.org>
Date:   Mon Feb 12 11:06:25 2018 +1300

    selftest: GnuTLS is already mandetory to build the AD DC
    
    This change avoids the code behind 'if have_tls_support' becoming untested
    if the configure logic changes.  We already assert that we have GnuTLS
    elsewhere in the AD DC build scripts.
    
    Signed-off-by: Andrew Bartlett <abart...@samba.org>
    Reviewed-by: Gary Lockyer <g...@catalyst.net.nz>

commit 8e54bc463adcfbc322249ba626e2c503ca13a864
Author: Andrew Bartlett <abart...@samba.org>
Date:   Mon Feb 12 11:03:25 2018 +1300

    selftest: Require jansson support for selftest of the AD DC
    
    This avoids this code becoming untested if a package is not installed or
    the configure test is accidentially broken.
    
    Signed-off-by: Andrew Bartlett <abart...@samba.org>
    Reviewed-by: Gary Lockyer <g...@catalyst.net.nz>

commit a12925b6ed66ca2e0383e8e60e4deeb5894dc3ed
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Thu Feb 8 16:01:41 2018 +1300

    test samba-tool drs showrepl: test --json output
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit ed15a452e7db6d76e231e5fbd45fa236c57a87f3
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Thu Feb 8 15:52:01 2018 +1300

    samba-tool drs showrepl: add --json option for JSON output
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 90d0c638ef1817337a58babd0c02be5c9c4611c6
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Fri Feb 2 15:39:47 2018 +1300

    samba-tool drs showrepl: restructure in preparation for --json
    
    Basically we just separate data extraction from printing.
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 2cd70978681259713281bd9e89971cf98584b069
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Thu Feb 8 14:22:39 2018 +1300

    test samba-tool drs showrepl: test expected output more strictly
    
    We try to ensure the output has all the expected information in the
    expected order.
    
    Soon we're going to add a JSON output mode, and we are strengthening
    the tests here to ensure we don't break anything.
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 48248b7ad15458f2f5a5b1410b1aed1c52cf019b
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Thu Feb 8 14:47:55 2018 +1300

    test samba-tool drs showrepl: fix formatting and unused imports
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit cec3646c5d2ac47df129f16f8994c332e2ad06c3
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Fri Feb 2 15:59:38 2018 +1300

    tests: move samba-tool drs showrepl into its own suite
    
    This is a simple copy of the sowrepl test to the new file, making room
    to expand the test and (soon) to test JSON output.
    
    pep-8 intentionally ignored to show this is a copy.
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 92ec01dcf080901eb4c208b208651ae03e77f538
Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
Date:   Sun Feb 11 11:59:40 2018 +1300

    python.subunit: add assertRegexpMatches for Python 2.6
    
    This is used in python/samba/tests/samba_tool/provision_password_check.py
    
    Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 70a85c163ff7397075bf0cef8a483df4f33799b4
Author: Lumir Balhar <lbal...@redhat.com>
Date:   Tue Jan 30 18:55:12 2018 +0100

    python: tests: Make tests of dsdb Python module Python 3 compatible
    
    Signed-off-by: Lumir Balhar <lbal...@redhat.com>
    Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit dce18a079e8c1e259bab4b4da57121d6ab4b7635
Author: Lumir Balhar <lbal...@redhat.com>
Date:   Tue Jan 30 18:53:38 2018 +0100

    python: Port dsdb module to Python 3 compatible form.
    
    Signed-off-by: Lumir Balhar <lbal...@redhat.com>
    Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit bc7c6c15da0ba42cd7f4b3551d2ab33f349bae1b
Author: Lumir Balhar <lbal...@redhat.com>
Date:   Tue Jan 30 18:52:11 2018 +0100

    python: Port samdb module to Python 3 compatible form
    
    Signed-off-by: Lumir Balhar <lbal...@redhat.com>
    Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit cb15e32f85f7a69dff0e461ec3536a84e95407ca
Author: Lumir Balhar <lbal...@redhat.com>
Date:   Fri Feb 9 20:49:36 2018 +0100

    python: Add `text_type` Python 2/3 compatible function name.
    
    This compatible function name represents `str` in Python 3
    and `unicode` in Python 2.
    
    Signed-off-by: Lumir Balhar <lbal...@redhat.com>
    Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 7ee74f66a1715b2c88165f025ebc3b661f15c75d
Author: Lumir Balhar <lbal...@redhat.com>
Date:   Tue Jan 30 18:47:32 2018 +0100

    python: Port dsdb_dns module to Python 3 compatible form.
    
    Signed-off-by: Lumir Balhar <lbal...@redhat.com>
    Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit a45e70bf47cb4b48f69a237298e143f574bf58bb
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Jan 30 18:09:00 2018 +0100

    python: Convert base64 encoded password to utf-8
    
    Pair-Programmed-With: Alexander Bokovoy <a...@samba.org>
    
    Signed-off-by: Andreas Schneider <a...@samba.org>
    Signed-off-by: Alexander Bokovoy <a...@samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 298d812ca053811a56e5092fb52bffa60d007650
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Jan 30 16:39:21 2018 +0100

    python: Generate random test usernames
    
    Signed-off-by: Andreas Schneider <a...@samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 auth/wscript_configure                             |   9 ++
 buildtools/wafsamba/nothreads.py                   |   4 +-
 buildtools/wafsamba/samba_conftests.py             |   2 +-
 buildtools/wafsamba/samba_dist.py                  |   2 +-
 buildtools/wafsamba/wafsamba.py                    |   2 +-
 python/samba/common.py                             |   2 +-
 python/samba/compat.py                             |   2 +
 python/samba/dbchecker.py                          |  10 +-
 python/samba/drs_utils.py                          |   6 +-
 python/samba/kcc/__init__.py                       |   4 +-
 python/samba/kcc/graph_utils.py                    |   2 +-
 python/samba/kcc/kcc_utils.py                      |   6 +-
 python/samba/kcc/ldif_import_export.py             |   2 +-
 python/samba/netcmd/__init__.py                    |   2 +-
 python/samba/netcmd/delegation.py                  |   8 +-
 python/samba/netcmd/dns.py                         |   2 +-
 python/samba/netcmd/domain.py                      |  14 +-
 python/samba/netcmd/drs.py                         | 170 ++++++++++++++-------
 python/samba/netcmd/fsmo.py                        |   6 +-
 python/samba/netcmd/gpo.py                         |  24 +--
 python/samba/netcmd/group.py                       |  14 +-
 python/samba/netcmd/ldapcmp.py                     |   2 +-
 python/samba/netcmd/ntacl.py                       |   8 +-
 python/samba/netcmd/ou.py                          |  24 +--
 python/samba/netcmd/rodc.py                        |   4 +-
 python/samba/netcmd/sites.py                       |  10 +-
 python/samba/netcmd/testparm.py                    |   2 +-
 python/samba/netcmd/user.py                        |  20 +--
 python/samba/provision/backend.py                  |   2 +-
 python/samba/samdb.py                              |  15 +-
 python/samba/tests/__init__.py                     |  11 +-
 python/samba/tests/auth_log_pass_change.py         |   6 +-
 python/samba/tests/dcerpc/array.py                 |   4 +-
 python/samba/tests/dcerpc/testrpc.py               |   8 +-
 python/samba/tests/dns_forwarder.py                |   2 +-
 python/samba/tests/docs.py                         |   4 +-
 python/samba/tests/dsdb.py                         |  29 ++--
 python/samba/tests/netcmd.py                       |   2 +-
 python/samba/tests/pam_winbind_warn_pwd_expire.py  |   5 +-
 python/samba/tests/samba_tool/dnscmd.py            |   8 +-
 python/samba/tests/source.py                       |   2 +-
 python/samba/upgrade.py                            |  30 ++--
 python/samba/web_server/__init__.py                |   2 +-
 script/autobuild.py                                |   2 +-
 script/bisect-test.py                              |   2 +-
 script/generate_param.py                           |   2 +-
 selftest/subunithelper.py                          |   2 +-
 source3/client/smbspool.c                          |  10 +-
 source4/dns_server/pydns.c                         |  19 ++-
 source4/dns_server/wscript_build                   |   8 +-
 source4/dsdb/pydsdb.c                              |  60 +++++---
 source4/dsdb/tests/python/dirsync.py               |  14 +-
 source4/dsdb/tests/python/linked_attributes.py     |   2 +-
 source4/dsdb/tests/python/rodc.py                  |   4 +-
 source4/dsdb/tests/python/rodc_rwdc.py             |  10 +-
 source4/dsdb/tests/python/sites.py                 |   2 +-
 source4/dsdb/tests/python/sort.py                  |   2 +-
 source4/dsdb/tests/python/vlv.py                   |   4 +-
 source4/dsdb/wscript_build                         |  20 ++-
 source4/scripting/bin/autoidl                      |   2 +-
 source4/scripting/bin/minschema                    |   8 +-
 source4/scripting/bin/rpcclient                    |   2 +-
 source4/scripting/bin/samba-tool                   |   4 +-
 source4/scripting/bin/samba_dnsupdate              |   6 +-
 source4/scripting/bin/samba_kcc                    |   2 +-
 source4/scripting/bin/samba_spnupdate              |   4 +-
 source4/scripting/bin/samba_upgradedns             |   2 +-
 source4/scripting/bin/samba_upgradeprovision       |   8 +-
 source4/scripting/bin/w32err_code.py               |   2 +-
 source4/selftest/tests.py                          |  86 +++++------
 .../torture/drs/python/linked_attributes_drs.py    |   4 +-
 source4/torture/drs/python/ridalloc_exop.py        |   2 +-
 source4/torture/drs/python/samba_tool_drs.py       |  20 ---
 .../torture/drs/python/samba_tool_drs_showrepl.py  | 159 +++++++++++++++++++
 74 files changed, 611 insertions(+), 356 deletions(-)
 create mode 100644 source4/torture/drs/python/samba_tool_drs_showrepl.py


Changeset truncated at 500 lines:

diff --git a/auth/wscript_configure b/auth/wscript_configure
index 47943fa..9d930ba 100644
--- a/auth/wscript_configure
+++ b/auth/wscript_configure
@@ -1,7 +1,16 @@
 #!/usr/bin/env python
 
+import Options, Utils
+
 conf.SET_TARGET_TYPE('jansson', 'EMPTY')
 
 if conf.CHECK_CFG(package='jansson', args='--cflags --libs',
                  msg='Checking for jansson'):
     conf.CHECK_FUNCS_IN('json_object', 'jansson')
+
+if not conf.CONFIG_GET('HAVE_JSON_OBJECT') and \
+   conf.CONFIG_GET('ENABLE_SELFTEST') and \
+   (not Options.options.without_ad_dc):
+    raise Utils.WafError('jansson JSON library required for '
+                         '--enable-selftest '
+                         'when building the AD DC')
diff --git a/buildtools/wafsamba/nothreads.py b/buildtools/wafsamba/nothreads.py
index d194eb8..9bd33e8 100644
--- a/buildtools/wafsamba/nothreads.py
+++ b/buildtools/wafsamba/nothreads.py
@@ -43,7 +43,7 @@ def process(tsk):
         if tsk.__class__.stat: ret = tsk.__class__.stat(tsk)
         # actual call to task's run() function
         else: ret = tsk.call_run()
-    except Exception, e:
+    except Exception as e:
         tsk.err_msg = Utils.ex_stack()
         tsk.hasrun = EXCEPTION
 
@@ -177,7 +177,7 @@ class Parallel(object):
 
             try:
                 st = tsk.runnable_status()
-            except Exception, e:
+            except Exception as e:
                 self.processed += 1
                 if self.stop and not Options.options.keep:
                     tsk.hasrun = SKIPPED
diff --git a/buildtools/wafsamba/samba_conftests.py 
b/buildtools/wafsamba/samba_conftests.py
index 511176d..b52727b 100644
--- a/buildtools/wafsamba/samba_conftests.py
+++ b/buildtools/wafsamba/samba_conftests.py
@@ -50,7 +50,7 @@ def check(self, *k, **kw):
     ret = None
     try:
         ret = self.run_c_code(*k, **kw)
-    except Configure.ConfigurationError, e:
+    except Configure.ConfigurationError as e:
         self.check_message_2(kw['errmsg'], 'YELLOW')
         if 'mandatory' in kw and kw['mandatory']:
             if Logs.verbose > 1:
diff --git a/buildtools/wafsamba/samba_dist.py 
b/buildtools/wafsamba/samba_dist.py
index 2e52820..8d51632 100644
--- a/buildtools/wafsamba/samba_dist.py
+++ b/buildtools/wafsamba/samba_dist.py
@@ -167,7 +167,7 @@ def dist(appname='', version=''):
         absdir = os.path.join(srcdir, dir)
         try:
             files = vcs_dir_contents(absdir)
-        except Exception, e:
+        except Exception as e:
             Logs.error('unable to get contents of %s: %s' % (absdir, e))
             sys.exit(1)
         add_files_to_tarball(tar, srcdir, dir, dist_base, destdir, blacklist, 
files)
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index 4bb19d0..1e331e5 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -900,7 +900,7 @@ def INSTALL_DIR(bld, path, chmod=0o755, env=None):
             try:
                 os.makedirs(destpath)
                 os.chmod(destpath, chmod)
-            except OSError, e:
+            except OSError as e:
                 if not os.path.isdir(destpath):
                     raise Utils.WafError("Cannot create the folder '%s' 
(error: %s)" % (path, e))
 Build.BuildContext.INSTALL_DIR = INSTALL_DIR
diff --git a/python/samba/common.py b/python/samba/common.py
index a915934..1c410a4 100644
--- a/python/samba/common.py
+++ b/python/samba/common.py
@@ -18,7 +18,7 @@
 
 
 import ldb
-import dsdb
+from samba import dsdb
 from samba.ndr import ndr_pack
 from samba.dcerpc import misc
 import binascii
diff --git a/python/samba/compat.py b/python/samba/compat.py
index dfdfb7d..667a1a4 100644
--- a/python/samba/compat.py
+++ b/python/samba/compat.py
@@ -23,5 +23,7 @@ PY3 = sys.version_info[0] == 3
 
 if PY3:
     integer_types = int,
+    text_type = str
 else:
     integer_types = (int, long)
+    text_type = unicode
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
index b2b8b0c..5e06d1f 100644
--- a/python/samba/dbchecker.py
+++ b/python/samba/dbchecker.py
@@ -369,7 +369,7 @@ systemFlags: -1946157056%s""" % (dn, guid_suffix),
         try:
             controls = controls + ["local_oid:%s:0" % 
dsdb.DSDB_CONTROL_DBCHECK]
             self.samdb.delete(dn, controls=controls)
-        except Exception, err:
+        except Exception as err:
             if self.in_transaction:
                 raise CommandError("%s : %s" % (msg, err))
             self.report("%s : %s" % (msg, err))
@@ -383,7 +383,7 @@ systemFlags: -1946157056%s""" % (dn, guid_suffix),
         try:
             controls = controls + ["local_oid:%s:0" % 
dsdb.DSDB_CONTROL_DBCHECK]
             self.samdb.modify(m, controls=controls, validate=validate)
-        except Exception, err:
+        except Exception as err:
             if self.in_transaction:
                 raise CommandError("%s : %s" % (msg, err))
             self.report("%s : %s" % (msg, err))
@@ -402,7 +402,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), 
str(to_base)))
             to_dn = to_rdn + to_base
             controls = controls + ["local_oid:%s:0" % 
dsdb.DSDB_CONTROL_DBCHECK]
             self.samdb.rename(from_dn, to_dn, controls=controls)
-        except Exception, err:
+        except Exception as err:
             if self.in_transaction:
                 raise CommandError("%s : %s" % (msg, err))
             self.report("%s : %s" % (msg, err))
@@ -1565,7 +1565,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), 
str(to_base)))
         cls = None
         try:
             cls = obj["objectClass"][-1]
-        except KeyError, e:
+        except KeyError as e:
             pass
 
         if cls is None:
@@ -2191,7 +2191,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), 
str(to_base)))
             # special handling for some specific attribute types
             try:
                 syntax_oid = 
self.samdb_schema.get_syntax_oid_from_lDAPDisplayName(attrname)
-            except Exception, msg:
+            except Exception as msg:
                 self.err_unknown_attribute(obj, attrname)
                 error_count += 1
                 continue
diff --git a/python/samba/drs_utils.py b/python/samba/drs_utils.py
index ded072c..1940d2d 100644
--- a/python/samba/drs_utils.py
+++ b/python/samba/drs_utils.py
@@ -54,7 +54,7 @@ def drsuapi_connect(server, lp, creds):
     try:
         drsuapiBind = drsuapi.drsuapi(binding_string, lp, creds)
         (drsuapiHandle, bindSupportedExtensions) = drs_DsBind(drsuapiBind)
-    except Exception, e:
+    except Exception as e:
         raise drsException("DRS connection to %s failed: %s" % (server, e))
 
     return (drsuapiBind, drsuapiHandle, bindSupportedExtensions)
@@ -83,7 +83,7 @@ def sendDsReplicaSync(drsuapiBind, drsuapi_handle, 
source_dsa_guid,
 
     try:
         drsuapiBind.DsReplicaSync(drsuapi_handle, 1, req1)
-    except Exception, estr:
+    except Exception as estr:
         raise drsException("DsReplicaSync failed %s" % estr)
 
 
@@ -106,7 +106,7 @@ def sendRemoveDsServer(drsuapiBind, drsuapi_handle, 
server_dsa_dn, domain):
         req1.commit = 1
 
         drsuapiBind.DsRemoveDSServer(drsuapi_handle, 1, req1)
-    except Exception, estr:
+    except Exception as estr:
         raise drsException("DsRemoveDSServer failed %s" % estr)
 
 
diff --git a/python/samba/kcc/__init__.py b/python/samba/kcc/__init__.py
index 6f8be1c..b9e491a 100644
--- a/python/samba/kcc/__init__.py
+++ b/python/samba/kcc/__init__.py
@@ -2718,7 +2718,7 @@ class KCC(object):
         try:
             self.samdb = ldif_import_export.ldif_to_samdb(dburl, lp, ldif_file,
                                                           forced_local_dsa)
-        except ldif_import_export.LdifError, e:
+        except ldif_import_export.LdifError as e:
             logger.critical(e)
             return 1
         return 0
@@ -2743,7 +2743,7 @@ class KCC(object):
         try:
             ldif_import_export.samdb_to_ldif_file(self.samdb, dburl, lp, creds,
                                                   ldif_file)
-        except ldif_import_export.LdifError, e:
+        except ldif_import_export.LdifError as e:
             logger.critical(e)
             return 1
         return 0
diff --git a/python/samba/kcc/graph_utils.py b/python/samba/kcc/graph_utils.py
index 5e909f3..a3b5109 100644
--- a/python/samba/kcc/graph_utils.py
+++ b/python/samba/kcc/graph_utils.py
@@ -303,7 +303,7 @@ def verify_graph(title, edges, vertices=None, 
directed=False, properties=(),
         try:
             f(edges, vertices, edge_vertices)
             debug(" %s%18s:%s verified!" % (DARK_GREEN, p, C_NORMAL))
-        except GraphError, e:
+        except GraphError as e:
             errors.append((p, e))
 
     if errors:
diff --git a/python/samba/kcc/kcc_utils.py b/python/samba/kcc/kcc_utils.py
index e4b99f4..df5da6d 100644
--- a/python/samba/kcc/kcc_utils.py
+++ b/python/samba/kcc/kcc_utils.py
@@ -373,7 +373,7 @@ class NCReplica(NamingContext):
         try:
             samdb.modify(m)
 
-        except ldb.LdbError, estr:
+        except ldb.LdbError as estr:
             raise KCCError("Could not set repsFrom for (%s) - (%s)" %
                            (self.nc_dnstr, estr))
 
@@ -524,7 +524,7 @@ class NCReplica(NamingContext):
         try:
             samdb.modify(m)
 
-        except ldb.LdbError, estr:
+        except ldb.LdbError as estr:
             raise KCCError("Could not set repsTo for (%s) - (%s)" %
                            (self.nc_dnstr, estr))
 
@@ -1686,7 +1686,7 @@ class Site(object):
         try:
             samdb.modify(m)
 
-        except ldb.LdbError, estr:
+        except ldb.LdbError as estr:
             raise KCCError(
                 "Could not set interSiteTopologyGenerator for (%s) - (%s)" %
                 (ssdn, estr))
diff --git a/python/samba/kcc/ldif_import_export.py 
b/python/samba/kcc/ldif_import_export.py
index 5e0f337..1cfffa3 100644
--- a/python/samba/kcc/ldif_import_export.py
+++ b/python/samba/kcc/ldif_import_export.py
@@ -77,7 +77,7 @@ dsServiceName: CN=NTDS Settings,%s
 -
 """)
 
-    except Exception, estr:
+    except Exception as estr:
         tmpdb.transaction_cancel()
         raise LdifError("Failed to import %s: %s" % (ldif_file, estr))
 
diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py
index fcad7f6..9037d03 100644
--- a/python/samba/netcmd/__init__.py
+++ b/python/samba/netcmd/__init__.py
@@ -174,7 +174,7 @@ class Command(object):
 
         try:
             return self.run(*args, **kwargs)
-        except Exception, e:
+        except Exception as e:
             self.show_command_error(e)
             return -1
 
diff --git a/python/samba/netcmd/delegation.py 
b/python/samba/netcmd/delegation.py
index 39397bb..49e5957 100644
--- a/python/samba/netcmd/delegation.py
+++ b/python/samba/netcmd/delegation.py
@@ -138,7 +138,7 @@ class cmd_delegation_for_any_service(Command):
             sam.toggle_userAccountFlags(search_filter, flag,
                                         flags_str="Trusted-for-Delegation",
                                         on=on, strict=True)
-        except Exception, err:
+        except Exception as err:
             raise CommandError(err)
 
 
@@ -192,7 +192,7 @@ class cmd_delegation_for_any_protocol(Command):
             sam.toggle_userAccountFlags(search_filter, flag,
                         flags_str="Trusted-to-Authenticate-for-Delegation",
                         on=on, strict=True)
-        except Exception, err:
+        except Exception as err:
             raise CommandError(err)
 
 
@@ -246,7 +246,7 @@ class cmd_delegation_add_service(Command):
                                           "msDS-AllowedToDelegateTo")
         try:
             sam.modify(msg)
-        except Exception, err:
+        except Exception as err:
             raise CommandError(err)
 
 
@@ -300,7 +300,7 @@ class cmd_delegation_del_service(Command):
                                           "msDS-AllowedToDelegateTo")
         try:
             sam.modify(msg)
-        except Exception, err:
+        except Exception as err:
             raise CommandError(err)
 
 
diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py
index 33f81ee..8bd6a9b 100644
--- a/python/samba/netcmd/dns.py
+++ b/python/samba/netcmd/dns.py
@@ -47,7 +47,7 @@ def dns_connect(server, lp, creds):
     binding_str = "ncacn_ip_tcp:%s[sign]" % server
     try:
         dns_conn = dnsserver.dnsserver(binding_str, lp, creds)
-    except RuntimeError, e:
+    except RuntimeError as e:
         raise CommandError('Connecting to DNS RPC server %s failed with %s' % 
(server, e))
 
     return dns_conn
diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py
index 2cb14f1..52c70ac 100644
--- a/python/samba/netcmd/domain.py
+++ b/python/samba/netcmd/domain.py
@@ -499,7 +499,7 @@ class cmd_domain_provision(Command):
                   base_schema=base_schema,
                   plaintext_secrets=plaintext_secrets)
 
-        except ProvisioningError, e:
+        except ProvisioningError as e:
             raise CommandError("Provision failed", e)
 
         result.report_logger(self.logger)
@@ -865,7 +865,7 @@ class cmd_domain_demote(Command):
             dc_dn = res[0].dn
             uac = int(str(res[0]["userAccountControl"]))
 
-        except Exception, e:
+        except Exception as e:
             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")
@@ -897,7 +897,7 @@ class cmd_domain_demote(Command):
                                                         "userAccountControl")
         try:
             remote_samdb.modify(msg)
-        except Exception, e:
+        except Exception as e:
             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")
@@ -952,7 +952,7 @@ class cmd_domain_demote(Command):
         try:
             newdn = ldb.Dn(remote_samdb, "%s,%s" % (newrdn, str(computer_dn)))
             remote_samdb.rename(dc_dn, newdn)
-        except Exception, e:
+        except Exception as e:
             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")
@@ -1012,7 +1012,7 @@ class cmd_domain_demote(Command):
             try:
                 remote_samdb.delete(ldb.Dn(remote_samdb,
                                     "%s,%s" % (s, str(newdn))))
-            except ldb.LdbError, l:
+            except ldb.LdbError as l:
                 pass
 
         self.errf.write("Demote successful\n")
@@ -1328,7 +1328,7 @@ class cmd_domain_passwordsettings(Command):
             else:
                 cur_account_lockout_duration = 
abs(int(res[0]["lockoutDuration"][0])) / (1e7 * 60)
             cur_reset_account_lockout_after = 
abs(int(res[0]["lockOutObservationWindow"][0])) / (1e7 * 60)
-        except Exception, e:
+        except Exception as e:
             raise CommandError("Could not retrieve password properties!", e)
 
         if subcommand == "show":
@@ -3853,7 +3853,7 @@ This command expunges tombstones from the database."""
                                                                
current_time=current_time,
                                                                
tombstone_lifetime=tombstone_lifetime)
 
-        except Exception, err:
+        except Exception as err:
             if started_transaction:
                 samdb.transaction_cancel()
             raise CommandError("Failed to expunge / garbage collect 
tombstones", err)
diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py
index 0ccbf9a..5498f09 100644
--- a/python/samba/netcmd/drs.py
+++ b/python/samba/netcmd/drs.py
@@ -42,7 +42,7 @@ def drsuapi_connect(ctx):
     '''make a DRSUAPI connection to the server'''
     try:
         (ctx.drsuapi, ctx.drsuapi_handle, ctx.bind_supported_extensions) = 
drs_utils.drsuapi_connect(ctx.server, ctx.lp, ctx.creds)
-    except Exception, e:
+    except Exception as e:
         raise CommandError("DRS connection to %s failed" % ctx.server, e)
 
 def samdb_connect(ctx):
@@ -51,7 +51,7 @@ def samdb_connect(ctx):
         ctx.samdb = SamDB(url="ldap://%s"; % ctx.server,
                           session_info=system_session(),
                           credentials=ctx.creds, lp=ctx.lp)
-    except Exception, e:
+    except Exception as e:
         raise CommandError("LDAP connection to %s failed" % ctx.server, e)
 
 def drs_errmsg(werr):
@@ -95,21 +95,44 @@ class cmd_drs_showrepl(Command):
         "credopts": options.CredentialsOptions,
     }
 
+    takes_options = [
+        Option("--json", help="output in JSON format", action='store_true'),
+    ]
+
     takes_args = ["DC?"]
 
-    def print_neighbour(self, n):
-        '''print one set of neighbour information'''
-        self.message("%s" % n.naming_context_dn)
+    def parse_neighbour(self, n):
+        """Convert an ldb neighbour object into a python dictionary"""
+        d = {
+            'NC dn': n.naming_context_dn,
+            "DSA objectGUID": str(n.source_dsa_obj_guid),
+            "last attempt time": nttime2string(n.last_attempt),
+            "last attempt message": drs_errmsg(n.result_last_attempt),
+            "consecutive failures": n.consecutive_sync_failures,
+            "last success": nttime2string(n.last_success),
+            "NTDS DN": str(n.source_dsa_obj_dn)
+        }
+
         try:
             (site, server) = drs_parse_ntds_dn(n.source_dsa_obj_dn)
-            self.message("\t%s\%s via RPC" % (site, server))
+            d["DSA"] = "%s\%s" % (site, server)
         except RuntimeError:
-            self.message("\tNTDS DN: %s" % n.source_dsa_obj_dn)
-        self.message("\t\tDSA object GUID: %s" % n.source_dsa_obj_guid)
-        self.message("\t\tLast attempt @ %s %s" % 
(nttime2string(n.last_attempt),
-                                                   
drs_errmsg(n.result_last_attempt)))
-        self.message("\t\t%u consecutive failure(s)." % 
n.consecutive_sync_failures)
-        self.message("\t\tLast success @ %s" % nttime2string(n.last_success))
+            pass
+        return d
+
+    def print_neighbour(self, d):
+        '''print one set of neighbour information'''
+        self.message("%s" % d['NC dn'])
+        if 'DSA' in d:
+            self.message("\t%s via RPC" % d['DSA'])
+        else:
+            self.message("\tNTDS DN: %s" % d['NTDS DN'])
+        self.message("\t\tDSA object GUID: %s" % d['DSA objectGUID'])
+        self.message("\t\tLast attempt @ %s %s" % (d['last attempt time'],
+                                                   d['last attempt message']))
+        self.message("\t\t%u consecutive failure(s)." %
+                     d['consecutive failures'])
+        self.message("\t\tLast success @ %s" % d['last success'])
         self.message("")
 
     def drsuapi_ReplicaInfo(self, info_type):
@@ -120,12 +143,12 @@ class cmd_drs_showrepl(Command):
         try:
             (info_type, info) = self.drsuapi.DsReplicaGetInfo(
                 self.drsuapi_handle, 1, req1)
-        except Exception, e:
+        except Exception as e:
             raise CommandError("DsReplicaGetInfo of type %u failed" % 
info_type, e)
         return (info_type, info)
 
     def run(self, DC=None, sambaopts=None,
-            credopts=None, versionopts=None, server=None):
+            credopts=None, versionopts=None, server=None, json=False):
 
         self.lp = sambaopts.get_loadparm()
         if DC is None:
@@ -143,24 +166,75 @@ class cmd_drs_showrepl(Command):
         (site, server) = drs_parse_ntds_dn(ntds_dn)
         try:
             ntds = self.samdb.search(base=ntds_dn, scope=ldb.SCOPE_BASE, 
attrs=['options', 'objectGUID', 'invocationId'])
-        except Exception, e:
+        except Exception as e:
             raise CommandError("Failed to search NTDS DN %s" % ntds_dn)
+
+        dsa_details = {


-- 
Samba Shared Repository

Reply via email to