abandon_stale.py: Adapt to removal of digest authentication

HTTP Digest authentication was removed in Gerrit 2.14 and now only basic
authentication is supported.

Change the default authentication to basic, but still support digest
for backwards compatibility with previous Gerrit versions.

Change-Id: I7ccf9d2c506ed79f1209f995856c42c4936b4872
This commit is contained in:
David Pursehouse 2017-04-19 12:50:24 +02:00
parent 463234ca2d
commit bd19a23a1a
1 changed files with 8 additions and 4 deletions

View File

@ -59,7 +59,11 @@ def _main():
help='gerrit server URL')
parser.add_option('-b', '--basic-auth', dest='basic_auth',
action='store_true',
help='use HTTP basic authentication instead of digest')
help='(deprecated) use HTTP basic authentication instead'
' of digest')
parser.add_option('-d', '--digest-auth', dest='digest_auth',
action='store_true',
help='use HTTP digest authentication instead of basic')
parser.add_option('-n', '--dry-run', dest='dry_run',
action='store_true',
help='enable dry-run mode: show stale changes but do '
@ -115,10 +119,10 @@ def _main():
message = "Abandoning after %s %s or more of inactivity." % \
(match.group(1), match.group(2))
if options.basic_auth:
auth_type = HTTPBasicAuthFromNetrc
else:
if options.digest_auth:
auth_type = HTTPDigestAuthFromNetrc
else:
auth_type = HTTPBasicAuthFromNetrc
try:
auth = auth_type(url=options.gerrit_url)