diff --git a/src/interactive/HISTORY.rst b/src/interactive/HISTORY.rst index e046010c666..d618be866af 100644 --- a/src/interactive/HISTORY.rst +++ b/src/interactive/HISTORY.rst @@ -2,6 +2,11 @@ Release History =============== + +0.4.2 ++++++ +* Update to remain compatible with azure-cli 2.0.62. + 0.4.1 +++++ * Remove command registration, rely on module to be called. diff --git a/src/interactive/azext_interactive/azclishell/__init__.py b/src/interactive/azext_interactive/azclishell/__init__.py index ba503827c6c..0d8b149ec86 100644 --- a/src/interactive/azext_interactive/azclishell/__init__.py +++ b/src/interactive/azext_interactive/azclishell/__init__.py @@ -3,4 +3,4 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -__version__ = '0.3.24' +VERSION = '0.4.2' diff --git a/src/interactive/azext_interactive/azclishell/_dump_commands.py b/src/interactive/azext_interactive/azclishell/_dump_commands.py index 92dc9862823..fe8cf550070 100644 --- a/src/interactive/azext_interactive/azclishell/_dump_commands.py +++ b/src/interactive/azext_interactive/azclishell/_dump_commands.py @@ -7,10 +7,11 @@ import os import yaml # pylint: disable=import-error +from azure.cli.core import MainCommandsLoader + from knack.help import REQUIRED_TAG from knack.help_files import helps from knack.log import get_logger -from azure.cli.core import MainCommandsLoader logger = get_logger(__name__) @@ -133,7 +134,7 @@ def load_help_files(data): """ loads all the extra information from help files """ for command_name, help_yaml in helps.items(): - help_entry = yaml.load(help_yaml) + help_entry = yaml.safe_load(help_yaml) try: help_type = help_entry['type'] except KeyError: diff --git a/src/interactive/azext_interactive/azclishell/app.py b/src/interactive/azext_interactive/azclishell/app.py index 347864afa3c..7ccc2bc7d34 100644 --- a/src/interactive/azext_interactive/azclishell/app.py +++ b/src/interactive/azext_interactive/azclishell/app.py @@ -28,17 +28,16 @@ from prompt_toolkit.shortcuts import create_eventloop # pylint: enable=import-error -from knack.log import get_logger -from knack.util import CLIError - from azure.cli.core.commands.client_factory import ENV_ADDITIONAL_USER_AGENT -from azure.cli.core._config import DEFAULTS_SECTION from azure.cli.core._profile import _SUBSCRIPTION_NAME, Profile from azure.cli.core._session import ACCOUNT, CONFIG, SESSION from azure.cli.core.api import get_config_dir from azure.cli.core.util import handle_exception -from . import __version__ +from knack.log import get_logger +from knack.util import CLIError + +from . import VERSION from .az_completer import AzCompleter from .az_lexer import get_az_lexer, ExampleLexer, ToolbarLexer from .configuration import Configuration, SELECT_SYMBOL @@ -101,7 +100,7 @@ def __init__(self, cli_ctx, style=None, completer=None, self.completer = AzCompleter(self, None) self.lexer = None self.history = history or FileHistory(os.path.join(self.config.get_config_dir(), self.config.get_history())) - os.environ[ENV_ADDITIONAL_USER_AGENT] = 'AZURECLISHELL/' + __version__ + os.environ[ENV_ADDITIONAL_USER_AGENT] = 'AZURECLISHELL/' + VERSION # OH WHAT FUN TO FIGURE OUT WHAT THESE ARE! self._cli = None @@ -324,10 +323,11 @@ def generate_help_text(self): def _update_default_info(self): try: - options = self.cli_ctx.config.config_parser.options(DEFAULTS_SECTION) + defaults_section = self.cli_ctx.config.defaults_section_name + options = self.cli_ctx.config.config_parser.options(defaults_section) self.config_default = "" for opt in options: - self.config_default += opt + ": " + self.cli_ctx.config.get(DEFAULTS_SECTION, opt) + " " + self.config_default += opt + ": " + self.cli_ctx.config.get(defaults_section, opt) + " " except configparser.NoSectionError: self.config_default = "" @@ -477,7 +477,7 @@ def _special_cases(self, cmd, outside): if not cmd_stripped and cmd: # add scope if there are only spaces cmd = self.default_command + " " + cmd - elif cmd_stripped == "quit" or cmd_stripped == "exit": + elif cmd_stripped in ("quit", "exit"): break_flag = True elif cmd_stripped == "clear-history": continue_flag = True diff --git a/src/interactive/azext_interactive/azclishell/argfinder.py b/src/interactive/azext_interactive/azclishell/argfinder.py index d00e7ee3725..b04191f535c 100644 --- a/src/interactive/azext_interactive/azclishell/argfinder.py +++ b/src/interactive/azext_interactive/azclishell/argfinder.py @@ -29,7 +29,7 @@ def get_parsed_args(self, comp_words): try: active_parsers[0].parse_known_args(comp_words, namespace=parsed_args) - except BaseException: + except BaseException: # pylint: disable=broad-except pass self.completing = False diff --git a/src/interactive/azext_interactive/azclishell/key_bindings.py b/src/interactive/azext_interactive/azclishell/key_bindings.py index 76fafeed54d..8280b234813 100644 --- a/src/interactive/azext_interactive/azclishell/key_bindings.py +++ b/src/interactive/azext_interactive/azclishell/key_bindings.py @@ -105,5 +105,4 @@ def format_response(self, response): if conversion[response]: return 'yes' return 'no' - else: - raise ValueError('Invalid response: input should equate to true or false') + raise ValueError('Invalid response: input should equate to true or false') diff --git a/src/interactive/azext_interactive/azclishell/layout.py b/src/interactive/azext_interactive/azclishell/layout.py index 6634ba50774..ac607823e98 100644 --- a/src/interactive/azext_interactive/azclishell/layout.py +++ b/src/interactive/azext_interactive/azclishell/layout.py @@ -311,6 +311,6 @@ def get_descriptions(config, exam_lex, lexer): get_param(lexer), ]) return get_descript(exam_lex) - elif config.BOOLEAN_STATES[config.config.get('Layout', 'param_description')]: + if config.BOOLEAN_STATES[config.config.get('Layout', 'param_description')]: return get_param(lexer) return get_empty() diff --git a/src/interactive/azext_interactive/azclishell/util.py b/src/interactive/azext_interactive/azclishell/util.py index 55dd92b4dc7..b8a65005068 100644 --- a/src/interactive/azext_interactive/azclishell/util.py +++ b/src/interactive/azext_interactive/azclishell/util.py @@ -20,7 +20,7 @@ def get_window_dim(): if version >= (3, 3): return _size_36() - elif platform.system() == 'Windows': + if platform.system() == 'Windows': return _size_windows() return _size_27() diff --git a/src/interactive/azext_interactive/azext_metadata.json b/src/interactive/azext_interactive/azext_metadata.json index 5cbdb87c5ed..f56fcfe605d 100644 --- a/src/interactive/azext_interactive/azext_metadata.json +++ b/src/interactive/azext_interactive/azext_metadata.json @@ -1,5 +1,4 @@ { "azext.isPreview": true, - "azext.minCliCoreVersion": "2.0.50.dev0", - "azext.maxCliCoreVersion": "2.0.61" + "azext.minCliCoreVersion": "2.0.62" } \ No newline at end of file diff --git a/src/interactive/setup.py b/src/interactive/setup.py index 5075bb9fb7f..c13d9dd843d 100644 --- a/src/interactive/setup.py +++ b/src/interactive/setup.py @@ -5,10 +5,17 @@ # -------------------------------------------------------------------------------------------- from codecs import open +import os +import re from setuptools import setup, find_packages -# Version is also defined in azclishell.__init__.py. -VERSION = "0.4.1" +# Version is defined in azclishell.__init__.py. +extension_path = os.path.dirname(os.path.realpath(__file__)) +version_file_path = os.path.join(extension_path, 'azext_interactive', 'azclishell', '__init__.py') +with open(version_file_path, 'r') as version_file: + VERSION = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + version_file.read(), re.MULTILINE).group(1) + # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers CLASSIFIERS = [