зеркало из https://github.com/microsoft/azure-cli.git
Better Completer responsiveness in interactive after command table loaded (#5794)
* improved completer responsiveness upon command table load * history and version bump * mock create_interface() * delay create_interface and remove refresh_cli flag * close file descriptor
This commit is contained in:
Родитель
499325194b
Коммит
83fb2aef72
|
@ -12,11 +12,10 @@
|
|||
<OutputPath>.</OutputPath>
|
||||
<ProjectTypeGuids>{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
|
||||
<LaunchProvider>Standard Python launcher</LaunchProvider>
|
||||
<InterpreterId>{0739f18f-8f0c-4ff7-b592-f6a44eacf0ba}</InterpreterId>
|
||||
<InterpreterVersion>3.5</InterpreterVersion>
|
||||
<InterpreterId>{78c1ee79-34bd-41e9-beb0-9ecf0336c9a2}</InterpreterId>
|
||||
<InterpreterVersion>2.7</InterpreterVersion>
|
||||
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
|
||||
<CommandLineArguments>
|
||||
</CommandLineArguments>
|
||||
<CommandLineArguments>interactive</CommandLineArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'" />
|
||||
|
@ -351,30 +350,29 @@
|
|||
<Compile Include="command_modules\azure-cli-find\azure\cli\command_modules\find\_params.py" />
|
||||
<Compile Include="command_modules\azure-cli-find\azure\cli\command_modules\find\__init__.py" />
|
||||
<Compile Include="command_modules\azure-cli-find\setup.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\app.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\argfinder.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\az_completer.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\az_lexer.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\color_styles.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\command_tree.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\configuration.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\frequency_heuristic.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\gather_commands.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\key_bindings.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\layout.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\progress.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\telemetry.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\threads.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\util.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\_dump_commands.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azclishell\__init__.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\app.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\argfinder.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\az_completer.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\az_lexer.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\color_styles.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\command_tree.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\configuration.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\frequency_heuristic.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\gather_commands.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\key_bindings.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\layout.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\progress.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\telemetry.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\threads.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\util.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\_dump_commands.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__init__.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\tests\latest\test_completion.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\tests\latest\test_feedback.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\tests\latest\test_gather.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\tests\latest\test_query_injection.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\tests\latest\test_quote_parse.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\tests\latest\test_shell_progress.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\tests\latest\test_telemetry.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\tests\latest\test_tree.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\__init__.py" />
|
||||
<Compile Include="command_modules\azure-cli-interactive\setup.py" />
|
||||
|
@ -856,11 +854,12 @@
|
|||
<Folder Include="command_modules\azure-cli-find\azure\cli\command_modules\find\tests\" />
|
||||
<Folder Include="command_modules\azure-cli-find\azure\cli\command_modules\find\tests\latest\" />
|
||||
<Folder Include="command_modules\azure-cli-interactive\" />
|
||||
<Folder Include="command_modules\azure-cli-interactive\azclishell\" />
|
||||
<Folder Include="command_modules\azure-cli-interactive\azure\" />
|
||||
<Folder Include="command_modules\azure-cli-interactive\azure\cli\" />
|
||||
<Folder Include="command_modules\azure-cli-interactive\azure\cli\command_modules\" />
|
||||
<Folder Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\" />
|
||||
<Folder Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\" />
|
||||
<Folder Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\" />
|
||||
<Folder Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\tests\" />
|
||||
<Folder Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\tests\latest\" />
|
||||
<Folder Include="command_modules\azure-cli-interactive\docs\" />
|
||||
|
@ -1088,6 +1087,41 @@
|
|||
<Content Include="command_modules\azure-cli-find\MANIFEST.in" />
|
||||
<Content Include="command_modules\azure-cli-find\README.rst" />
|
||||
<Content Include="command_modules\azure-cli-find\setup.cfg" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\app.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\argfinder.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\az_completer.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\az_lexer.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\color_styles.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\command_tree.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\configuration.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\frequency_heuristic.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\gather_commands.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\key_bindings.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\layout.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\progress.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\telemetry.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\threads.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\util.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\_dump_commands.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__init__.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\app.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\argfinder.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\az_completer.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\az_lexer.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\color_styles.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\command_tree.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\configuration.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\frequency_heuristic.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\gather_commands.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\key_bindings.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\layout.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\progress.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\telemetry.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\threads.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\util.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\_dump_commands.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\__init__.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\azclishell\__pycache__\__main__.cpython-36.pyc" />
|
||||
<Content Include="command_modules\azure-cli-interactive\docs\faster-shell-cast.gif" />
|
||||
<Content Include="command_modules\azure-cli-interactive\docs\shell.gif" />
|
||||
<Content Include="command_modules\azure-cli-interactive\docs\shell_tutorial.gif" />
|
||||
|
@ -1165,18 +1199,16 @@
|
|||
<Content Include="command_modules\azure-cli-vm\HISTORY.rst" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterpreterReference Include="{6121b83b-bf4d-4953-9b9d-9360b34efe09}\3.5" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Interpreter Include="..\env\">
|
||||
<Id>{0739f18f-8f0c-4ff7-b592-f6a44eacf0ba}</Id>
|
||||
<BaseInterpreter>{6121b83b-bf4d-4953-9b9d-9360b34efe09}</BaseInterpreter>
|
||||
<Version>3.5</Version>
|
||||
<Description>env (Python 3.6)</Description>
|
||||
<Interpreter Include="..\env36b\">
|
||||
<Id>{78c1ee79-34bd-41e9-beb0-9ecf0336c9a2}</Id>
|
||||
<BaseInterpreter>{d09116de-bd02-4de4-8a41-0d9752df0ac8}</BaseInterpreter>
|
||||
<Version>2.7</Version>
|
||||
<Description>env36b (env36)</Description>
|
||||
<InterpreterPath>Scripts\python.exe</InterpreterPath>
|
||||
<WindowsInterpreterPath>Scripts\pythonw.exe</WindowsInterpreterPath>
|
||||
<WindowsInterpreterPath>Scripts\python.exe</WindowsInterpreterPath>
|
||||
<LibraryPath>Lib\</LibraryPath>
|
||||
<PathEnvironmentVariable>PYTHONPATH</PathEnvironmentVariable>
|
||||
<PathEnvironmentVariable>
|
||||
</PathEnvironmentVariable>
|
||||
<Architecture>Amd64</Architecture>
|
||||
</Interpreter>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
Release History
|
||||
===============
|
||||
|
||||
0.3.18
|
||||
++++++
|
||||
* Completions kick in as soon as command table loading is done.
|
||||
|
||||
0.3.17
|
||||
++++++
|
||||
* Persist history across different sessions
|
||||
|
|
|
@ -76,11 +76,6 @@ def space_toolbar(settings_items, empty_space):
|
|||
return settings, empty_space
|
||||
|
||||
|
||||
def restart_completer(shell_ctx):
|
||||
shell_ctx.completer = AzCompleter(shell_ctx, GatherCommands(shell_ctx.config))
|
||||
shell_ctx.refresh_cli = True
|
||||
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
class AzInteractiveShell(object):
|
||||
|
||||
|
@ -98,21 +93,18 @@ class AzInteractiveShell(object):
|
|||
self.lexer = lexer or get_az_lexer(self.config) if self.styles else None
|
||||
try:
|
||||
self.completer = completer or AzCompleter(self, GatherCommands(self.config))
|
||||
from .az_completer import initialize_command_table_attributes
|
||||
initialize_command_table_attributes(self.completer)
|
||||
self.completer.initialize_command_table_attributes()
|
||||
except IOError: # if there is no cache
|
||||
self.completer = None
|
||||
self.completer = AzCompleter(self, None)
|
||||
self.history = history or FileHistory(os.path.join(self.config.config_dir, self.config.get_history()))
|
||||
os.environ[ENV_ADDITIONAL_USER_AGENT] = 'AZURECLISHELL/' + __version__
|
||||
|
||||
# OH WHAT FUN TO FIGURE OUT WHAT THESE ARE!
|
||||
self._cli = None
|
||||
self.refresh_cli = False
|
||||
self.layout = None
|
||||
self.description_docs = u''
|
||||
self.param_docs = u''
|
||||
self.example_docs = u''
|
||||
self._env = os.environ
|
||||
self.last = None
|
||||
self.last_exit = 0
|
||||
self.user_feedback = user_feedback
|
||||
|
@ -155,9 +147,8 @@ class AzInteractiveShell(object):
|
|||
@property
|
||||
def cli(self):
|
||||
""" Makes the interface or refreshes it """
|
||||
if self._cli is None or self.refresh_cli:
|
||||
if self._cli is None:
|
||||
self._cli = self.create_interface()
|
||||
self.refresh_cli = False
|
||||
return self._cli
|
||||
|
||||
def handle_cd(self, cmd):
|
||||
|
@ -201,6 +192,12 @@ class AzInteractiveShell(object):
|
|||
self._update_toolbar()
|
||||
cli.request_redraw()
|
||||
|
||||
def restart_completer(self):
|
||||
if not self.completer:
|
||||
self.completer.start(self, GatherCommands(self.config))
|
||||
self.completer.initialize_command_table_attributes()
|
||||
self._cli = self.create_interface()
|
||||
|
||||
def _space_examples(self, list_examples, rows, section_value):
|
||||
""" makes the example text """
|
||||
examples_with_index = []
|
||||
|
@ -686,7 +683,7 @@ class AzInteractiveShell(object):
|
|||
self.cli_ctx.get_progress_controller().init_progress(ShellProgressView())
|
||||
self.cli_ctx.get_progress_controller = self.progress_patch
|
||||
|
||||
self.command_table_thread = LoadCommandTableThread(restart_completer, self)
|
||||
self.command_table_thread = LoadCommandTableThread(self.restart_completer, self)
|
||||
self.command_table_thread.start()
|
||||
|
||||
from .configuration import SHELL_HELP
|
||||
|
|
|
@ -15,14 +15,6 @@ from .util import parse_quotes
|
|||
SELECT_SYMBOL = configuration.SELECT_SYMBOL
|
||||
|
||||
|
||||
def initialize_command_table_attributes(completer):
|
||||
from ._dump_commands import FreshTable
|
||||
completer.cmdtab = FreshTable(completer.shell_ctx).command_table
|
||||
if completer.cmdtab:
|
||||
completer.parser.load_command_table(completer.cmdtab)
|
||||
completer.argsfinder = ArgsFinder(completer.parser)
|
||||
|
||||
|
||||
def error_pass(_, message): # pylint: disable=unused-argument
|
||||
return
|
||||
|
||||
|
@ -78,32 +70,33 @@ class AzCompleter(Completer):
|
|||
""" Completes Azure CLI commands """
|
||||
|
||||
def __init__(self, shell_ctx, commands, global_params=True):
|
||||
self.shell_ctx = shell_ctx
|
||||
self.shell_ctx = None
|
||||
|
||||
# dictionary of command to descriptions
|
||||
self.command_description = commands.descrip
|
||||
self.command_description = None
|
||||
# from a command to a list of parameters
|
||||
self.command_parameters = commands.command_param
|
||||
self.command_parameters = None
|
||||
# a list of all the possible parameters
|
||||
self.completable_param = commands.completable_param
|
||||
self.completable_param = None
|
||||
# the command tree
|
||||
self.command_tree = commands.command_tree
|
||||
self.command_tree = None
|
||||
# a dictionary of parameter (which is command + " " + parameter name)
|
||||
# to a description of what it does
|
||||
self.param_description = commands.param_descript
|
||||
self.param_description = None
|
||||
# a dictionary of command to examples of how to use it
|
||||
self.command_examples = commands.command_example
|
||||
self.command_examples = None
|
||||
# a dictionary of commands with parameters with multiple names (e.g. {'vm create':{-n: --name}})
|
||||
self.same_param_doubles = commands.same_param_doubles or {}
|
||||
self.same_param_doubles = {}
|
||||
|
||||
self._is_command = True
|
||||
|
||||
self.branch = self.command_tree
|
||||
self.branch = None
|
||||
self.curr_command = ""
|
||||
|
||||
self.global_param = commands.global_param if global_params else []
|
||||
self.output_choices = commands.output_choices if global_params else []
|
||||
self.output_options = commands.output_options if global_params else []
|
||||
self.global_param_descriptions = commands.global_param_descriptions if global_params else []
|
||||
self.global_param = []
|
||||
self.output_choices = []
|
||||
self.output_options = []
|
||||
self.global_param_descriptions = []
|
||||
|
||||
self.global_parser = AzCliCommandParser(add_help=False)
|
||||
self.global_parser.add_argument_group('global', 'Global Arguments')
|
||||
|
@ -111,6 +104,37 @@ class AzCompleter(Completer):
|
|||
self.argsfinder = ArgsFinder(self.parser)
|
||||
self.cmdtab = {}
|
||||
|
||||
if commands:
|
||||
self.start(shell_ctx, commands, global_params=global_params)
|
||||
|
||||
def __bool__(self):
|
||||
return bool(self.shell_ctx)
|
||||
|
||||
def start(self, shell_ctx, commands, global_params=True):
|
||||
self.shell_ctx = shell_ctx
|
||||
self.command_description = commands.descrip
|
||||
self.command_parameters = commands.command_param
|
||||
self.completable_param = commands.completable_param
|
||||
self.command_tree = commands.command_tree
|
||||
self.param_description = commands.param_descript
|
||||
self.command_examples = commands.command_example
|
||||
self.same_param_doubles = commands.same_param_doubles or self.same_param_doubles
|
||||
|
||||
self.branch = self.command_tree
|
||||
|
||||
if global_params:
|
||||
self.global_param = commands.global_param
|
||||
self.output_choices = commands.output_choices
|
||||
self.output_options = commands.output_options
|
||||
self.global_param_descriptions = commands.global_param_descriptions
|
||||
|
||||
def initialize_command_table_attributes(self):
|
||||
from ._dump_commands import FreshTable
|
||||
self.cmdtab = FreshTable(self.shell_ctx).command_table
|
||||
if self.cmdtab:
|
||||
self.parser.load_command_table(self.cmdtab)
|
||||
self.argsfinder = ArgsFinder(self.parser)
|
||||
|
||||
def validate_completion(self, param, words, text_before_cursor, check_double=True):
|
||||
""" validates that a param should be completed """
|
||||
# validates the position of the parameter
|
||||
|
|
|
@ -16,11 +16,9 @@ class LoadCommandTableThread(threading.Thread):
|
|||
|
||||
def run(self):
|
||||
from ._dump_commands import FreshTable
|
||||
from .az_completer import initialize_command_table_attributes
|
||||
|
||||
try:
|
||||
FreshTable(self.shell).dump_command_table(self.shell)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
self.initialize_function(self.shell)
|
||||
initialize_command_table_attributes(self.shell.completer)
|
||||
self.initialize_function()
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import unittest
|
||||
import six
|
||||
import mock
|
||||
|
||||
from azure.cli.command_modules.interactive.azclishell import command_tree as tree
|
||||
from azure.cli.command_modules.interactive.azclishell.az_completer import AzCompleter
|
||||
|
@ -15,8 +16,9 @@ from prompt_toolkit.completion import Completion
|
|||
def _build_completer(commands, global_params):
|
||||
from azure.cli.testsdk import TestCli
|
||||
from azure.cli.command_modules.interactive.azclishell.app import AzInteractiveShell
|
||||
shell_ctx = AzInteractiveShell(TestCli(), None)
|
||||
return AzCompleter(shell_ctx, commands, global_params)
|
||||
with mock.patch.object(AzInteractiveShell, 'create_interface', lambda _: None):
|
||||
shell_ctx = AzInteractiveShell(TestCli(), None)
|
||||
return AzCompleter(shell_ctx, commands, global_params)
|
||||
|
||||
|
||||
class _Commands():
|
||||
|
|
|
@ -56,7 +56,7 @@ class FeedbackTest(unittest.TestCase):
|
|||
fh.update_frequency = self.norm_update
|
||||
now = fh.day_format(datetime.datetime.now())
|
||||
|
||||
_, freq_path = tempfile.mkstemp()
|
||||
fd, freq_path = tempfile.mkstemp()
|
||||
freq_dir, freq_file = freq_path.rsplit(os.path.sep, 1)
|
||||
|
||||
def _get_freq():
|
||||
|
@ -72,13 +72,14 @@ class FeedbackTest(unittest.TestCase):
|
|||
self.assertEqual(json_freq, {now: 2})
|
||||
|
||||
if os.path.exists(freq_path):
|
||||
os.close(fd)
|
||||
os.remove(freq_path)
|
||||
|
||||
def test_update_freq_no_file(self):
|
||||
# tests updating the files for frequency with no file written
|
||||
fh.update_frequency = self.norm_update
|
||||
|
||||
_, freq_path = tempfile.mkstemp()
|
||||
fd, freq_path = tempfile.mkstemp()
|
||||
freq_dir, freq_file = freq_path.rsplit(os.path.sep, 1)
|
||||
|
||||
def _get_freq():
|
||||
|
@ -88,6 +89,7 @@ class FeedbackTest(unittest.TestCase):
|
|||
self.shell_ctx.config.get_frequency = _get_freq
|
||||
|
||||
if os.path.exists(freq_path):
|
||||
os.close(fd)
|
||||
os.remove(freq_path)
|
||||
|
||||
# without a file already written
|
||||
|
|
|
@ -14,7 +14,7 @@ except ImportError:
|
|||
cmdclass = {}
|
||||
|
||||
# Version is also defined in azclishell.__init__.py.
|
||||
VERSION = "0.3.17"
|
||||
VERSION = "0.3.18"
|
||||
# The full list of classifiers is available at
|
||||
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
CLASSIFIERS = [
|
||||
|
|
Загрузка…
Ссылка в новой задаче