Skip to content

Commit

Permalink
Plugging in HaTs survey (Azure#11526)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzhou-msft authored Dec 11, 2019
1 parent 4c19a96 commit 4ee717b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/azure-cli-core/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Release History
===============

* Plug in HaTS survey

2.0.77
++++++
* Add deprecate message for Python 2.7
Expand Down
3 changes: 3 additions & 0 deletions src/azure-cli-core/azure/cli/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def get_cli_version(self):

def show_version(self):
from azure.cli.core.util import get_az_version_string
from azure.cli.core.commands.constants import SURVEY_PROMPT
ver_string, updates_available = get_az_version_string()
print(ver_string)
if updates_available == -1:
Expand All @@ -96,6 +97,8 @@ def show_version(self):
else:
print('Your CLI is up-to-date.')

print('\n' + SURVEY_PROMPT)

def exception_handler(self, ex): # pylint: disable=no-self-use
from azure.cli.core.util import handle_exception
return handle_exception(ex)
Expand Down
2 changes: 2 additions & 0 deletions src/azure-cli-core/azure/cli/core/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse

from azure.cli.core.commands import ExtensionCommandSource
from azure.cli.core.commands.constants import SURVEY_PROMPT

from knack.help import (HelpFile as KnackHelpFile, CommandHelpFile as KnackCommandHelpFile,
GroupHelpFile as KnackGroupHelpFile, ArgumentGroupRegistry as KnackArgumentGroupRegistry,
Expand Down Expand Up @@ -150,6 +151,7 @@ def new_normalize_text(s):
def show_help(self, cli_name, nouns, parser, is_group):
self.update_loaders_with_help_file_contents(nouns)
super(AzCliHelp, self).show_help(cli_name, nouns, parser, is_group)
print(SURVEY_PROMPT)

def _register_help_loaders(self):
import azure.cli.core._help_loaders as help_loaders
Expand Down
2 changes: 2 additions & 0 deletions src/azure-cli-core/azure/cli/core/_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ def find_from_user_account(self, username, password, tenant, resource):
return result

def find_through_authorization_code_flow(self, tenant, resource, authority_url):
from azure.cli.core.commands.constants import SURVEY_PROMPT
# launch browser and get the code
results = _get_authorization_code(resource, authority_url)

Expand All @@ -793,6 +794,7 @@ def find_through_authorization_code_flow(self, tenant, resource, authority_url):
token_entry = context.acquire_token_with_authorization_code(results['code'], results['reply_url'],
resource, _CLIENT_ID, None)
self.user_id = token_entry[_TOKEN_ENTRY_USER_ID]
print(SURVEY_PROMPT + "\n")
logger.warning("You have logged in. Now let us find all the subscriptions to which you have access...")
if tenant is None:
result = self._find_using_common_tenant(token_entry[_ACCESS_TOKEN], resource)
Expand Down
4 changes: 4 additions & 0 deletions src/azure-cli-core/azure/cli/core/commands/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from colorama import Fore, Style
from knack.parser import ARGPARSE_SUPPORTED_KWARGS


Expand All @@ -29,3 +30,6 @@
DEFAULT_QUERY_TIME_RANGE = 3600000

BLACKLISTED_MODS = ['context', 'shell', 'documentdb', 'component']

SURVEY_PROMPT = Fore.YELLOW + Style.BRIGHT + 'Please let us know how we are doing: ' + Fore.BLUE \
+ 'https://aka.ms/clihats' + Style.RESET_ALL
1 change: 1 addition & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Release History
**Core**

* Remove support for Python 3.4
* Plug in HaTS survey in multiple commands

**Install**

Expand Down
4 changes: 3 additions & 1 deletion src/azure-cli/azure/cli/command_modules/feedback/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from azure.cli.core.extension._resolve import resolve_project_url_from_index, NoExtensionCandidatesError
from azure.cli.core.util import get_az_version_string, open_page_in_browser, can_launch_browser, in_cloud_console
from azure.cli.core.azlogging import _UNKNOWN_COMMAND, _CMD_LOG_LINE_PREFIX
from azure.cli.core.commands.constants import SURVEY_PROMPT

_ONE_MIN_IN_SECS = 60

Expand All @@ -50,7 +51,8 @@
'\nWe appreciate your feedback!\n\n' \
'For more information on getting started, visit: {}\n' \
'If you have questions, visit our Stack Overflow page: {}\n'\
.format(_GET_STARTED_URL, _QUESTIONS_URL)
'{}\n'\
.format(_GET_STARTED_URL, _QUESTIONS_URL, SURVEY_PROMPT)

_MSG_CMD_ISSUE = "\nEnter the number of the command you would like to create an issue for. Enter q to quit: "

Expand Down
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/find/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from azure.cli.core import telemetry as telemetry_core
from azure.cli.core import __version__ as core_version
from azure.cli.core.commands.constants import SURVEY_PROMPT
from pkg_resources import parse_version
from knack.log import get_logger
logger = get_logger(__name__)
Expand Down Expand Up @@ -65,6 +66,7 @@ def process_query(cli_term):
if has_pruned_answer:
print(style_message("More commands and examples are available in the latest version of the CLI. "
"Please update for the best experience.\n"))
print(SURVEY_PROMPT)


def style_message(msg):
Expand Down

0 comments on commit 4ee717b

Please sign in to comment.