Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pylint enabled for all extensions, errors cleaned up for all extensions #177

Merged
merged 5 commits into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/ci/test_static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PYLINT_EXCLUDES=$(echo "$AZURE_SDK_AUTOGEN_FILES" | sed -e s=\./src/=src/=g -e '

# Run pylint/flake8 on extensions
echo "Running pylint on extensions..."
pylint ./src/rdbms/azext_rdbms/ --ignore=$PYLINT_EXCLUDES,vendored_sdks --ignore-patterns=test_* --rcfile=./pylintrc -j $proc_number
pylint ./src/*/azext_*/ --ignore=$PYLINT_EXCLUDES,vendored_sdks --ignore-patterns=test_* --rcfile=./pylintrc -j $proc_number


echo "Pylint OK."
Expand Down
2 changes: 1 addition & 1 deletion src/botservice/azext_bot/_exception_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def bot_exception_handler(ex):
from azext_bot.botservice.models import ErrorException
from msrestazure.azure_exceptions import CloudError
from msrest.exceptions import ClientRequestError
from msrest.exceptions import ClientRequestError # pylint: disable=import-error
if isinstance(ex, ErrorException):
message = 'an error occurred with code:{0} and message:{1}'.format(
ex.error.error.code,
Expand Down
3 changes: 1 addition & 2 deletions src/botservice/azext_bot/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
from knack.arguments import CLIArgumentType

from azure.cli.core.commands.parameters import (
tags_type,
resource_group_name_type,
get_resource_name_completion_list,
get_enum_type,
get_three_state_flag)

name_arg_type = CLIArgumentType(metavar='NAME', configured_default='botname')


# pylint: disable=line-too-long,too-many-statements
def load_arguments(self, _):
with self.argument_context('bot') as c:
c.argument('resource_group_name', arg_type=resource_group_name_type)
Expand Down
3 changes: 2 additions & 1 deletion src/botservice/azext_bot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def load_command_table(self, _):
g.custom_command('delete', 'delete_bot')
g.generic_update_command('update', setter_name='update', setter_type=updateBotService_commandType)

for channel in ['facebook', 'email', 'msteams', 'skype', 'kik', 'webchat', 'directline', 'telegram', 'sms', 'slack']:
for channel in ['facebook', 'email', 'msteams', 'skype', 'kik', 'webchat', 'directline', 'telegram', 'sms',
'slack']:
with self.command_group('bot {}'.format(channel), channelOperations_commandType) as g:
g.custom_command('create', '{}_create'.format(channel))
g.command('show', '{}_get'.format(channel))
Expand Down
78 changes: 45 additions & 33 deletions src/botservice/azext_bot/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from knack.prompting import prompt_y_n
import json
import os
import shutil
import adal # pylint: disable=import-error
from knack.prompting import prompt_y_n # pylint: disable=unused-import
from knack.util import CLIError
from knack.log import get_logger
from azext_bot.botservice import AzureBotService
from azext_bot.botservice.models import Bot, BotProperties, sku, BotChannel
from azure.cli.command_modules.appservice.custom import enable_zip_deploy, config_source_control, get_app_settings, _get_site_credential, _get_scm_url
from azure.cli.command_modules.appservice.custom import (enable_zip_deploy, config_source_control, get_app_settings,
_get_site_credential, _get_scm_url)
from azure.cli.command_modules.resource.custom import deploy_arm_template
from azure.cli.core._profile import Profile
import json
import adal
import os
import shutil

logger = get_logger(__name__)

Expand Down Expand Up @@ -62,7 +62,11 @@ def provisionConvergedApp(bot_name):

def create(cmd, client, resource_group_name, resource_name, kind, description=None, display_name=None,
endpoint=None, msa_app_id=None, password=None, tags=None, storageAccountName=None,
location='Central US', sku_name='F0', appInsightsLocation='South Central US', bot_json=None, language='Csharp'):
location='Central US', sku_name='F0', appInsightsLocation='South Central US', bot_json=None,
language='Csharp'):
if tags:
raise CLIError('Tags not supported yet')

display_name = display_name or resource_name
kind = kind.lower()

Expand All @@ -82,8 +86,7 @@ def create(cmd, client, resource_group_name, resource_name, kind, description=No
display_name=display_name,
description=description,
endpoint=endpoint,
msa_app_id=msa_app_id,
password=password
msa_app_id=msa_app_id
)
)
return client.bots.create(
Expand All @@ -92,12 +95,13 @@ def create(cmd, client, resource_group_name, resource_name, kind, description=No
parameters=parameters
)
elif kind == 'webapp' or kind == 'function':
return create_app(cmd, client, resource_group_name, resource_name, description, kind, msa_app_id, password, storageAccountName, location, sku_name, appInsightsLocation, bot_json, language)
return create_app(cmd, client, resource_group_name, resource_name, description, kind, msa_app_id, password,
storageAccountName, location, sku_name, appInsightsLocation, bot_json, language)
else:
raise CLIError('Invalid Bot Parameter : Kind')


def update(client, parameters, resource_group_name, **kwargs):
def update(client, parameters, resource_group_name):
try:
return client.bots.update(
resource_group_name=resource_group_name,
Expand Down Expand Up @@ -163,39 +167,42 @@ def get_bot(cmd, client, resource_group_name, resource_name, bot_json=None):
return raw_bot_properties


def create_app(cmd, client, resource_group_name, resource_name, description, kind, appid, password, storageAccountName, location, sku, appInsightsLocation, bot_json, language):
def create_app(cmd, client, resource_group_name, resource_name, description, kind, appid, password, storageAccountName, # pylint: disable=inconsistent-return-statements
location, sku_name, appInsightsLocation, bot_json, language):
if kind == 'function':
template_name = 'functionapp.template.json'
if language == 'Csharp':
zip_url = 'https://connectorprod.blob.core.windows.net/bot-packages/csharp-abs-functions_emptybot.zip'
else:
zip_url = 'https://connectorprod.blob.core.windows.net/bot-packages/node.js-abs-functions_emptybot_funcpack.zip'
zip_url = 'https://connectorprod.blob.core.windows.net/bot-packages/node.js-abs-functions_emptybot_funcpack.zip' # pylint: disable=line-too-long

else:
kind = 'sdk'
template_name = 'webapp.template.json'
if language == 'Csharp':
zip_url = 'https://connectorprod.blob.core.windows.net/bot-packages/csharp-abs-webapp_simpleechobot_precompiled.zip'
zip_url = 'https://connectorprod.blob.core.windows.net/bot-packages/csharp-abs-webapp_simpleechobot_precompiled.zip' # pylint: disable=line-too-long
else:
zip_url = 'https://connectorprod.blob.core.windows.net/bot-packages/node.js-abs-webapp_hello-chatconnector.zip'
zip_url = 'https://connectorprod.blob.core.windows.net/bot-packages/node.js-abs-webapp_hello-chatconnector.zip' # pylint: disable=line-too-long

create_new_storage = False
if not storageAccountName:
import re
import string
import random
create_new_storage = True
storageAccountName = re.sub(r'[^a-z0-9]', '', resource_name[:10] + ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(4)))
storageAccountName = re.sub(r'[^a-z0-9]', '', resource_name[:10] +
''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(4)))

paramsdict = {
"location": location,
"kind": kind,
"sku": sku,
"sku": sku_name,
"siteName": resource_name,
"appId": appid,
"appSecret": password,
"storageAccountResourceId": "",
"serverFarmId": "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Web/serverfarms/{2}".format(client.config.subscription_id, resource_group_name, resource_name),
"serverFarmId": "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Web/serverfarms/{2}".format(
client.config.subscription_id, resource_group_name, resource_name),
"zipUrl": zip_url,
"createNewStorage": create_new_storage,
"storageAccountName": storageAccountName,
Expand Down Expand Up @@ -226,7 +233,8 @@ def create_app(cmd, client, resource_group_name, resource_name, description, kin
return create_bot_json(cmd, client, resource_group_name, resource_name, app_password=password)


def publish_app(cmd, client, resource_group_name, resource_name, git_url=None, git_token=None, git_branch='master', code_dir=None):
def publish_app(cmd, _, resource_group_name, resource_name, git_url=None, git_token=None, git_branch='master', # pylint: disable=inconsistent-return-statements
code_dir=None):
# if given msbot json, use that to update environment settings like luis settings
if git_url:
return config_source_control(
Expand Down Expand Up @@ -260,7 +268,7 @@ def download_app(cmd, client, resource_group_name, resource_name, file_save_path
resource_group_name=resource_group_name,
resource_name=resource_name
)
if(raw_bot_properties.kind == 'bot'):
if raw_bot_properties.kind == 'bot':
raise CLIError('Source download is not supported for registration only bots')
file_save_path = file_save_path or os.getcwd()
if not os.path.isdir(file_save_path):
Expand All @@ -279,8 +287,8 @@ def download_app(cmd, client, resource_group_name, resource_name, file_save_path
headers['content-type'] = 'application/json'

payload = {
'command': 'PostDeployScripts\prepareSrc.cmd {0}'.format(password),
'dir': 'site\wwwroot'
'command': 'PostDeployScripts\\prepareSrc.cmd {0}'.format(password),
'dir': r'site\wwwroot'
}

import requests
Expand Down Expand Up @@ -316,14 +324,13 @@ def create_channel(client, channel, channel_name, resource_group_name, resource_
)


def facebook_create(client, resource_group_name, resource_name, page_id, app_id, app_secret, access_token, is_disabled=None):
def facebook_create(client, resource_group_name, resource_name, page_id, app_id, app_secret, access_token, is_disabled=None): # pylint: disable=line-too-long
from azext_bot.botservice.models import FacebookChannel, FacebookChannelProperties, FacebookPage
channel = FacebookChannel(
properties=FacebookChannelProperties(
pages=[FacebookPage(id=page_id, access_token=access_token)],
app_id=app_id,
app_secret=app_secret,
access_token=access_token,
is_enabled=not is_disabled
)
)
Expand All @@ -342,7 +349,8 @@ def email_create(client, resource_group_name, resource_name, email_address, pass
return create_channel(client, channel, 'EmailChannel', resource_group_name, resource_name)


def msteams_create(client, resource_group_name, resource_name, is_disabled=None, enable_messaging=None, enable_media_cards=None, enable_video=None, enable_calling=None):
def msteams_create(client, resource_group_name, resource_name, is_disabled=None, enable_messaging=None,
enable_media_cards=None, enable_video=None, enable_calling=None):
from azext_bot.botservice.models import MsTeamsChannel, MsTeamsChannelProperties
channel = MsTeamsChannel(
properties=MsTeamsChannelProperties(
Expand All @@ -356,7 +364,9 @@ def msteams_create(client, resource_group_name, resource_name, is_disabled=None,
return create_channel(client, channel, 'MsTeamsChannel', resource_group_name, resource_name)


def skype_create(client, resource_group_name, resource_name, is_disabled=None, enable_messaging=None, enable_media_cards=None, enable_video=None, enable_calling=None, enable_screen_sharing=None, enable_groups=None, calling_web_hook=None):
def skype_create(client, resource_group_name, resource_name, is_disabled=None, enable_messaging=None,
enable_media_cards=None, enable_video=None, enable_calling=None,
enable_screen_sharing=None, enable_groups=None, calling_web_hook=None):
from azext_bot.botservice.models import SkypeChannel, SkypeChannelProperties
channel = SkypeChannel(
properties=SkypeChannelProperties(
Expand Down Expand Up @@ -386,7 +396,7 @@ def kik_create(client, resource_group_name, resource_name, user_name, api_key, i
return create_channel(client, channel, 'KikChannel', resource_group_name, resource_name)


def webchat_create(client, resource_group_name, resource_name, is_disabled=None, enable_preview=None, site_name='default'):
def webchat_create(client, resource_group_name, resource_name, is_disabled=None, enable_preview=None, site_name='default'): # pylint: disable=line-too-long
if not enable_preview:
enable_preview = False
from azext_bot.botservice.models import WebChatChannel, WebChatChannelProperties, WebChatSite
Expand All @@ -402,7 +412,8 @@ def webchat_create(client, resource_group_name, resource_name, is_disabled=None,
return create_channel(client, channel, 'WebChatChannel', resource_group_name, resource_name)


def directline_create(client, resource_group_name, resource_name, is_disabled=None, is_v1_disabled=None, is_v3_disabled=None, site_name='default'):
def directline_create(client, resource_group_name, resource_name, is_disabled=None,
is_v1_disabled=None, is_v3_disabled=None, site_name='default'):
from azext_bot.botservice.models import DirectLineChannel, DirectLineChannelProperties, DirectLineSite
channel = DirectLineChannel(
properties=DirectLineChannelProperties(
Expand All @@ -429,7 +440,7 @@ def telegram_create(client, resource_group_name, resource_name, access_token, is
return create_channel(client, channel, 'TelegramChannel', resource_group_name, resource_name)


def sms_create(client, resource_group_name, resource_name, phone, account_sid, auth_token, is_disabled=None, is_validated=None):
def sms_create(client, resource_group_name, resource_name, phone, account_sid, auth_token, is_disabled=None, is_validated=None): # pylint: disable=line-too-long
from azext_bot.botservice.models import SmsChannel, SmsChannelProperties
channel = SmsChannel(
properties=SmsChannelProperties(
Expand All @@ -443,7 +454,8 @@ def sms_create(client, resource_group_name, resource_name, phone, account_sid, a
return create_channel(client, channel, 'SmsChannel', resource_group_name, resource_name)


def slack_create(client, resource_group_name, resource_name, client_id, client_secret, verification_token, is_disabled=None, landing_page_url=None):
def slack_create(client, resource_group_name, resource_name, client_id, client_secret, verification_token,
is_disabled=None, landing_page_url=None):
from azext_bot.botservice.models import SlackChannel, SlackChannelProperties
channel = SlackChannel(
properties=SlackChannelProperties(
Expand All @@ -457,9 +469,9 @@ def slack_create(client, resource_group_name, resource_name, client_id, client_s
return create_channel(client, channel, 'SlackChannel', resource_group_name, resource_name)


class ChannelOperations:
class ChannelOperations(object): # pylint: disable=too-few-public-methods
def __init__(self):
for channel in ['facebook', 'email', 'msTeams', 'skype', 'kik', 'webChat', 'directLine', 'telegram', 'sms', 'slack']:
for channel in ['facebook', 'email', 'msTeams', 'skype', 'kik', 'webChat', 'directLine', 'telegram', 'sms', 'slack']: # pylint: disable=line-too-long
channelName = '{}Channel'.format(channel)
channelName = channelName[:1].upper() + channelName[1:]

Expand Down
5 changes: 3 additions & 2 deletions src/eventgrid/azext_eventgrid/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from six.moves.urllib.parse import quote # pylint: disable=import-error
import re
from six.moves.urllib.parse import quote # pylint: disable=import-error,relative-import
from knack.log import get_logger
from knack.util import CLIError
from msrestazure.tools import parse_resource_id
Expand Down Expand Up @@ -223,7 +223,8 @@ def cli_event_subscription_list( # pylint: disable=too-many-return-statements
if resource_id:
# Resource ID is specified, we need to list only for the particular resource.
if resource_group_name is not None or topic_name is not None:
raise CLIError('Since --resource-id is specified, --topic-name and --resource-group-name should not be specified.')
raise CLIError('Since --resource-id is specified, --topic-name and --resource-group-name should not '
'be specified.')

id_parts = parse_resource_id(resource_id)
rg_name = id_parts['resource_group']
Expand Down
5 changes: 2 additions & 3 deletions src/signalr/azext_signalr/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@


from azure.cli.core.commands.validators import get_default_location_from_resource_group

from knack.log import get_logger

from azure.cli.core.commands.parameters import (
resource_group_name_type,
get_location_type,
get_resource_name_completion_list,
tags_type
)

from knack.log import get_logger

from ._constants import (
SIGNALR_SKU,
SIGNALR_RESOURCE_TYPE,
Expand Down
2 changes: 1 addition & 1 deletion src/signalr/azext_signalr/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@


from azure.cli.core.commands import CliCommandType
from azure.cli.core.util import empty_on_404

from ._client_factory import cf_signalr
from azure.cli.core.util import empty_on_404


def load_command_table(self, _):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import threading


class TokenUpdater:
class TokenUpdater(object):
"""
This class updates a given token_credential periodically using the provided callback function.
It shows one way of making sure the credential does not become expired.
Expand Down
Loading