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 fixes for webapp extension #175

Merged
merged 4 commits into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion src/webapp/azext_webapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def load_arguments(self, _):
help="shows summary of the create and deploy operation instead of executing it",
default=False, action='store_true')
with self.argument_context('webapp remote-connection create') as c:
c.argument('port', options_list=['--port', '-p'], help='Port for the remote connection. Default: Random available port', type=int)
c.argument('port', options_list=['--port', '-p'],
help='Port for the remote connection. Default: Random available port', type=int)
c.argument('name', options_list=['--name', '-n'], help='Name of the webapp to connect to')
with self.argument_context('webapp config snapshot list') as c:
c.argument('resource_group', options_list=['--resource-group', '-g'], help='Name of resource group.')
Expand Down
1 change: 1 addition & 0 deletions src/webapp/azext_webapp/create_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def check_app_exists(cmd, rg_name, app_name):
return False


# pylint:disable=unexpected-keyword-arg
def get_lang_from_content(src_path):
import glob
# NODE: package.json should exist in the application root dir
Expand Down
26 changes: 10 additions & 16 deletions src/webapp/azext_webapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
# --------------------------------------------------------------------------------------------

from __future__ import print_function
import json
from knack.log import get_logger
from knack.util import CLIError

from azure.mgmt.web.models import (AppServicePlan, SkuDescription, SnapshotRecoveryRequest, SnapshotRecoveryTarget)

from azure.cli.core.commands.client_factory import get_subscription_id

from azure.cli.command_modules.appservice.custom import (
create_webapp,
update_app_settings,
Expand All @@ -19,9 +17,7 @@
get_sku_name,
list_publish_profiles,
get_site_configs)

from azure.cli.command_modules.appservice._appservice_utils import _generic_site_operation

from .create_util import (
zip_contents_from_dir,
get_runtime_version_details,
Expand All @@ -33,14 +29,10 @@
get_lang_from_content,
web_client_factory
)

from ._constants import (NODE_RUNTIME_NAME, OS_DEFAULT, JAVA_RUNTIME_NAME, STATIC_RUNTIME_NAME)
import json
import time

logger = get_logger(__name__)

# pylint:disable=no-member,too-many-lines,too-many-locals,too-many-statements
# pylint:disable=no-member,too-many-lines,too-many-locals,too-many-statements,too-many-branches


def create_deploy_webapp(cmd, name, location=None, dryrun=False):
Expand Down Expand Up @@ -245,6 +237,7 @@ def _check_for_ready_tunnel(remote_debugging, tunnel_server):


def create_tunnel(cmd, resource_group_name, name, port=None, slot=None):
import time
profiles = list_publish_profiles(cmd, resource_group_name, name, slot)
user_name = next(p['userName'] for p in profiles)
user_password = next(p['userPWD'] for p in profiles)
Expand All @@ -268,6 +261,7 @@ def create_tunnel(cmd, resource_group_name, name, port=None, slot=None):


def _start_tunnel(tunnel_server, remote_debugging_enabled):
import time
if not _check_for_ready_tunnel(remote_debugging_enabled, tunnel_server):
logger.warning('Tunnel is not ready yet, please wait (may take up to 1 minute)')
while True:
Expand Down Expand Up @@ -299,7 +293,7 @@ def _zip_deploy(cmd, rg_name, name, zip_path):
# keep checking for status of the deployment
deployment_url = scm_url + '/api/deployments/latest'
response = requests.get(deployment_url, headers=authorization)
if(response.json()['status'] != 4):
if response.json()['status'] != 4:
logger.warning(response.json()['progress'])
_check_deployment_status(deployment_url, authorization)

Expand All @@ -312,15 +306,15 @@ def _check_deployment_status(deployment_url, authorization):
res_dict = response.json()
num_trials = num_trials + 1
if res_dict['status'] == 5:
return logger.warning("Zip deployment failed status {}".format(
logger.warning("Zip deployment failed status {}".format(
res_dict['status_text']
))
break
elif res_dict['status'] == 4:
return
break
logger.warning(res_dict['progress'])
# if the deployment is taking longer than expected
r = requests.get(deployment_url, headers=authorization)
# if the deployment is taking longer than expected
r = requests.get(deployment_url, headers=authorization)
if r.json()['status'] != 4:
logger.warning("""Deployment is taking longer than expected. Please verify status at '{}'
beforing launching the app""".format(deployment_url))
return
16 changes: 11 additions & 5 deletions src/webapp/azext_webapp/tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def recv(self):
return data


# pylint: disable=no-member, too-many-instance-attributes,bare-except,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please space correctly and remove last ','

class TunnelServer(object):
def __init__(self, local_addr, local_port, remote_addr, remote_user_name, remote_password):
self.local_addr = local_addr
Expand All @@ -43,6 +44,8 @@ def __init__(self, local_addr, local_port, remote_addr, remote_user_name, remote
self.remote_addr = remote_addr
self.remote_user_name = remote_user_name
self.remote_password = remote_password
self.client = None
self.ws = None
logger.info('Creating a socket on port: %s', self.local_port)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
logger.info('Setting socket options')
Expand All @@ -62,8 +65,9 @@ def create_basic_auth(self):

def is_port_open(self):
is_port_open = False
# pylint: disable=no-member
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for another disable no-member here if it is already disabled for the class (line 37)

with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
if sock.connect_ex(('', self.local_port)) == 0:
if sock.connect_ex('', self.local_port) == 0:
logger.info('Port %s is NOT open', self.local_port)
else:
logger.warning('Port %s is open', self.local_port)
Expand Down Expand Up @@ -125,8 +129,8 @@ def listen(self):
logger.info('Websocket, connected status: %s', self.ws.connected)
index = index + 1
logger.info('Got debugger connection... index: %s', index)
debugger_thread = Thread(target=self.listen_to_client, args=(self.client, self.ws, index))
web_socket_thread = Thread(target=self.listen_to_web_socket, args=(self.client, self.ws, index))
debugger_thread = Thread(target=self._listen_to_client, args=(self.client, self.ws, index))
web_socket_thread = Thread(target=self._listen_to_web_socket, args=(self.client, self.ws, index))
debugger_thread.start()
web_socket_thread.start()
logger.info('Both debugger and websocket threads started...')
Expand All @@ -136,7 +140,8 @@ def listen(self):
logger.info('Both debugger and websocket threads stopped...')
logger.warning('Stopped local server..')

def listen_to_web_socket(self, client, ws_socket, index):
# pylint: disable=no-self-use

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please align this with the corresponding method

def _listen_to_web_socket(self, client, ws_socket, index):
while True:
try:
logger.info('Waiting for websocket data, connection status: %s, index: %s', ws_socket.connected, index)
Expand All @@ -159,7 +164,8 @@ def listen_to_web_socket(self, client, ws_socket, index):
ws_socket.close()
return False

def listen_to_client(self, client, ws_socket, index):
# pylint: disable=no-self-use
Copy link

@LukaszStem LukaszStem May 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please align this with the corresponding method

def _listen_to_client(self, client, ws_socket, index):
while True:
try:
logger.info('Waiting for debugger data, index: %s', index)
Expand Down