From 5d5f93708bbf31040a71012fa78388ac52f3ff29 Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Tue, 3 Mar 2020 17:55:07 +0800 Subject: [PATCH] Remove find --- .github/CODEOWNERS | 2 - src/find/azext_find/__init__.py | 43 --------- src/find/azext_find/azext_metadata.json | 3 - src/find/azext_find/custom.py | 121 ------------------------ src/find/azext_find/test/__init__.py | 4 - src/find/azext_find/test/test_custom.py | 21 ---- src/find/setup.cfg | 2 - src/find/setup.py | 43 --------- src/index.json | 54 ----------- 9 files changed, 293 deletions(-) delete mode 100644 src/find/azext_find/__init__.py delete mode 100644 src/find/azext_find/azext_metadata.json delete mode 100644 src/find/azext_find/custom.py delete mode 100644 src/find/azext_find/test/__init__.py delete mode 100644 src/find/azext_find/test/test_custom.py delete mode 100644 src/find/setup.cfg delete mode 100644 src/find/setup.py diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ccef2093c42..787dc88b58a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -36,8 +36,6 @@ /src/mixed-reality/ @xiangyul -/src/find/ @albaloo - /src/resource-graph/ @demyanenko @amirhbk @chiragg4u /src/azure-firewall/ @MyronFanQiu diff --git a/src/find/azext_find/__init__.py b/src/find/azext_find/__init__.py deleted file mode 100644 index 9736aeed729..00000000000 --- a/src/find/azext_find/__init__.py +++ /dev/null @@ -1,43 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -from azure.cli.core import AzCommandsLoader -from knack.help_files import helps - -helps['find'] = """ - type: command - short-summary: I'm an AI robot, my advice is based on our Azure documentation as well as the usage patterns of Azure CLI and Azure ARM users. Using me improves Azure products and documentation. - examples: - - name: Give me any Azure CLI command or group and I’ll show the most popular commands and parameters. - text: | - az find 'az [group]' : az find 'az storage' - az find 'az [group] [command]' : az find 'az monitor activity-log list' - - name: You can also enter a search term, and I'll try to help find the best commands. - text: | - az find '[query]' : az find 'arm template' -""" - - -class FindCommandsLoader(AzCommandsLoader): - - def __init__(self, cli_ctx=None): - from azure.cli.core.commands import CliCommandType - - process_query_custom = CliCommandType( - operations_tmpl='azext_find.custom#{}') - super(FindCommandsLoader, self).__init__( - cli_ctx=cli_ctx, custom_command_type=process_query_custom) - - def load_command_table(self, _): - with self.command_group('') as g: - g.custom_command('find', 'process_query') - return self.command_table - - def load_arguments(self, _): - with self.argument_context('find') as c: - c.positional('cli_term', help='An Azure CLI command or group for which you need an example.') - - -COMMAND_LOADER_CLS = FindCommandsLoader diff --git a/src/find/azext_find/azext_metadata.json b/src/find/azext_find/azext_metadata.json deleted file mode 100644 index a2f37531f6a..00000000000 --- a/src/find/azext_find/azext_metadata.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "azext.isPreview": true -} \ No newline at end of file diff --git a/src/find/azext_find/custom.py b/src/find/azext_find/custom.py deleted file mode 100644 index 442237655b3..00000000000 --- a/src/find/azext_find/custom.py +++ /dev/null @@ -1,121 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -import random -import json -import re -import sys -import platform -import requests -import colorama # pylint: disable=import-error - - -from azure.cli.core import telemetry as telemetry_core -from knack.prompting import prompt -from knack.log import get_logger -logger = get_logger(__name__) - -WAIT_MESSAGE = ['I\'m an AI bot (learn more: aka.ms/aladdin); Let me see how I can help you...'] - -EXTENSION_NAME = 'find' - -FIND_EXTENSION_PREFIX = 'Context.Default.Extension.Find.' - - -def process_query(cli_term): - print(random.choice(WAIT_MESSAGE)) - response = call_aladdin_service(cli_term) - - if response.status_code != 200: - err_msg = '[?] Unexpected Error: [HTTP {0}]: Content: {1}'.format(response.status_code, response.content) - logger.error(err_msg) - else: - if (platform.system() == 'Windows' and should_enable_styling()): - colorama.init(convert=True) - - answer_list = json.loads(response.content) - if (not answer_list or answer_list[0]['source'] == 'bing'): - print("\nSorry I am not able to help with [" + cli_term + "]." - "\nTry typing the beginning of a command e.g. " + style_message('az vm') + ".") - else: - print("\nHere are the most common ways to use [" + cli_term + "]: \n") - num_results_to_show = min(3, len(answer_list)) - for i in range(num_results_to_show): - current_title = answer_list[i]['title'].strip() - current_snippet = answer_list[i]['snippet'].strip() - if current_title.startswith("az "): - current_title, current_snippet = current_snippet, current_title - current_title = current_title.split('\r\n')[0] - elif '```azurecli\r\n' in current_snippet: - start_index = current_snippet.index('```azurecli\r\n') + len('```azurecli\r\n') - current_snippet = current_snippet[start_index:] - current_snippet = current_snippet.replace('```', '').replace(current_title, '').strip() - current_snippet = re.sub(r'\[.*\]', '', current_snippet).strip() - print(style_message(current_title)) - print(current_snippet) - - print("") - feedback = prompt("[Enter to close. Press + or - to give feedback]:") - if feedback in ['+', '-']: - print('Wow, you are a true hero!') - print("""\ - O_ - """ + style_message("""""") + """`-. - """ + style_message("""|""") + """`-‘ - """ + style_message("""I""") + """ - """) - print('My human overlords review each of these reports; I\'m told these reports makes me smarter.') - print('Send us more feedback by email: aladdindoc@microsoft.com') - properties = {} - set_custom_properties(properties, 'Feedback', feedback) - telemetry_core.add_extension_event(EXTENSION_NAME, properties) - - -def style_message(msg): - if should_enable_styling(): - try: - msg = colorama.Style.BRIGHT + msg + colorama.Style.RESET_ALL - except KeyError: - pass - return msg - - -def should_enable_styling(): - try: - # Style if tty stream available - if sys.stdout.isatty(): - return True - except AttributeError: - pass - return False - - -def set_custom_properties(prop, name, value): - if name and value is not None: - # 10 characters limit for strings - prop['{}{}'.format(FIND_EXTENSION_PREFIX, name)] = value[:10] if isinstance(value, str) else value - - -def call_aladdin_service(query): - context = { - 'session_id': telemetry_core._session._get_base_properties()['Reserved.SessionId'], # pylint: disable=protected-access - 'subscription_id': telemetry_core._get_azure_subscription_id(), # pylint: disable=protected-access - 'client_request_id': telemetry_core._session.application.data['headers']['x-ms-client-request-id'], # pylint: disable=protected-access - 'installation_id': telemetry_core._get_installation_id() # pylint: disable=protected-access - } - - service_input = { - 'paragraphText': "
", - 'currentPageUrl': "", - 'query': "ALADDIN-CLI:" + query, - 'context': context - } - - api_url = 'https://aladdinservice-prod.azurewebsites.net/api/aladdin/generateCards' - headers = {'Content-Type': 'application/json'} - - response = requests.post(api_url, headers=headers, json=service_input) - - return response diff --git a/src/find/azext_find/test/__init__.py b/src/find/azext_find/test/__init__.py deleted file mode 100644 index 34913fb394d..00000000000 --- a/src/find/azext_find/test/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- diff --git a/src/find/azext_find/test/test_custom.py b/src/find/azext_find/test/test_custom.py deleted file mode 100644 index b83bb423121..00000000000 --- a/src/find/azext_find/test/test_custom.py +++ /dev/null @@ -1,21 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -import unittest - -from azext_find.custom import ( - call_aladdin_service, -) - - -class FindCustomCommandTest(unittest.TestCase): - - def test_call_aladdin_service(self): - response = call_aladdin_service("what is azure cli?") - self.assertEqual(200, response.status_code) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/find/setup.cfg b/src/find/setup.cfg deleted file mode 100644 index 3c6e79cf31d..00000000000 --- a/src/find/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal=1 diff --git a/src/find/setup.py b/src/find/setup.py deleted file mode 100644 index 8e0fae3d4eb..00000000000 --- a/src/find/setup.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python - -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -from setuptools import setup, find_packages - -VERSION = "0.3.0" - -CLASSIFIERS = [ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Intended Audience :: System Administrators', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'License :: OSI Approved :: MIT License', -] - -DEPENDENCIES = [ - 'colorama~=0.3.7' -] - -setup( - name='find', - version=VERSION, - description='Intelligent querying for CLI information.', - long_description='Find answers any CLI related questions from defining Azure terms to finding the right CLI command for your task.', - license='MIT', - author='Roshanak Zilouchian', - author_email='rozilouc@microsoft.com', - url='https://github.com/Azure/azure-cli-extensions/tree/master/src/find', - classifiers=CLASSIFIERS, - packages=find_packages(), - install_requires=DEPENDENCIES, - package_data={'azext_find': ['azext_metadata.json']} -) diff --git a/src/index.json b/src/index.json index 7119da40af4..8fb8dabffc3 100644 --- a/src/index.json +++ b/src/index.json @@ -1571,60 +1571,6 @@ "sha256Digest": "b83f723baae0ea04557a87f358fa2131baf15d45cd3aba7a9ab42d14ec80df38" } ], - "find": [ - { - "downloadUrl": "https://smartmlprod.blob.core.windows.net/aladdin-public/find-0.3.0-py2.py3-none-any.whl", - "filename": "find-0.3.0-py2.py3-none-any.whl", - "metadata": { - "azext.isPreview": true, - "classifiers": [ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Intended Audience :: System Administrators", - "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "License :: OSI Approved :: MIT License" - ], - "extensions": { - "python.details": { - "contacts": [ - { - "email": "rozilouc@microsoft.com", - "name": "Roshanak Zilouchian", - "role": "author" - } - ], - "document_names": { - "description": "DESCRIPTION.rst" - }, - "project_urls": { - "Home": "https://github.com/Azure/azure-cli-extensions/tree/master/src/find" - } - } - }, - "extras": [], - "generator": "bdist_wheel (0.30.0)", - "license": "MIT", - "metadata_version": "2.0", - "name": "find", - "run_requires": [ - { - "requires": [ - "colorama (~=0.3.7)" - ] - } - ], - "summary": "Intelligent querying for CLI information.", - "version": "0.3.0" - }, - "sha256Digest": "0960ec6711959712d5cbab611e32d248f0cdc597cef9613a5dbac790f4cf3b56" - } - ], "front-door": [ { "downloadUrl": "https://azurecliafd.blob.core.windows.net/azure-cli-extension/front_door-1.0.2-py2.py3-none-any.whl",