mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 05:59:28 -02:30
support the new CLI in py2 *and* py3
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import logging
|
||||
import os
|
||||
import pkg_resources
|
||||
import sys
|
||||
|
||||
from requests.exceptions import RequestException
|
||||
import six
|
||||
|
||||
from .custom import handle_custom_actions
|
||||
from .format import (add_authentication_arguments,
|
||||
@@ -160,10 +163,18 @@ class CLI(object):
|
||||
changed=self.original_action in ('modify', 'create')
|
||||
)
|
||||
if formatted:
|
||||
print(formatted, file=self.stdout)
|
||||
print(utils.to_str(formatted), file=self.stdout)
|
||||
else:
|
||||
self.parser.print_help()
|
||||
|
||||
if six.PY2 and not self.help:
|
||||
# Unfortunately, argparse behavior between py2 and py3
|
||||
# changed in a notable way when required subparsers
|
||||
# have invalid (or missing) arguments specified
|
||||
# see: https://github.com/python/cpython/commit/f97c59aaba2d93e48cbc6d25f7ff9f9c87f8d0b2
|
||||
print('\nargument resource: invalid choice')
|
||||
raise SystemExit(2)
|
||||
|
||||
def parse_action(self, page, from_sphinx=False):
|
||||
"""Perform an HTTP OPTIONS request
|
||||
|
||||
|
||||
Reference in New Issue
Block a user