From 838627595e4edc2f037cf084b68f23c368b6de20 Mon Sep 17 00:00:00 2001 From: Lukasz Stempniewicz Date: Wed, 2 May 2018 14:34:05 -0700 Subject: [PATCH] Address comments --- src/index.json | 4 ++-- src/webapp/azext_webapp/_help.py | 4 ++-- src/webapp/azext_webapp/custom.py | 6 +++--- src/webapp/azext_webapp/tunnel.py | 18 ++++++++++++++---- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/index.json b/src/index.json index fb2f12a0758..375f5fbe522 100644 --- a/src/index.json +++ b/src/index.json @@ -234,7 +234,7 @@ }, { "filename": "image_copy_extension-0.0.6-py2.py3-none-any.whl", - "sha256Digest": "986ab7ab186974bb2c365bf4092ed5dd554b00017ddf4c70ea07a53bcaa6bcc7", + "sha256Digest": "ad128ee3fb0bb992dc8487d0d5538c231891b2fd98fa0ea20d71c873db016b46", "downloadUrl": "https://files.pythonhosted.org/packages/ed/60/306879ce292e087d329ed15c7c63f42e880371ec8cc624c17bb28a1f937b/image_copy_extension-0.0.6-py2.py3-none-any.whl", "metadata": { "azext.minCliCoreVersion": "2.0.24", @@ -349,7 +349,7 @@ "contacts": [ { "email": "sisirap@microsoft.com", - "name": "Sisira Panchagnula", + "name": "Sisira Panchagnula, Lukasz Stempniewicz", "role": "author" } ], diff --git a/src/webapp/azext_webapp/_help.py b/src/webapp/azext_webapp/_help.py index eca37b0e1d5..dbb591168b0 100644 --- a/src/webapp/azext_webapp/_help.py +++ b/src/webapp/azext_webapp/_help.py @@ -18,12 +18,12 @@ """ helps['webapp remote-connection'] = """ type: group - short-summary: Create a remote connection using a tcp tunnel to your app + short-summary: Create a remote connection using a tcp tunnel to your web app """ helps['webapp remote-connection create'] = """ type: command - short-summary: Create a remote connection using a tcp tunnel to your app + short-summary: Creates a remote connection using a tcp tunnel to your web app """ helps['webapp config snapshot list'] = """ diff --git a/src/webapp/azext_webapp/custom.py b/src/webapp/azext_webapp/custom.py index 027785857a8..aab915c3089 100644 --- a/src/webapp/azext_webapp/custom.py +++ b/src/webapp/azext_webapp/custom.py @@ -239,11 +239,11 @@ def create_tunnel(cmd, resource_group_name, name, port, slot=None): t.daemon = True t.start() if not _check_for_ready_tunnel(cmd, resource_group_name, name, config.remote_debugging_enabled, tunnel_server, slot): - print('Tunnel is not ready yet, please wait (may take up to 1 minute)') + logger.warning('Tunnel is not ready yet, please wait (may take up to 1 minute)') while True: time.sleep(1) - print('.') + logger.warning('.') if _check_for_ready_tunnel(cmd, resource_group_name, name, config.remote_debugging_enabled, slot): break - print('Tunnel is ready! Creating on port {}'.format(port)) + logger.warning('Tunnel is ready! Creating on port %s', port) tunnel_server.start_server() diff --git a/src/webapp/azext_webapp/tunnel.py b/src/webapp/azext_webapp/tunnel.py index 2ba6e8946fb..966d6e37839 100644 --- a/src/webapp/azext_webapp/tunnel.py +++ b/src/webapp/azext_webapp/tunnel.py @@ -9,6 +9,7 @@ import time import traceback import websocket +import logging as logs from contextlib import closing from threading import Thread @@ -90,6 +91,8 @@ def is_port_set_to_default(self): raise CLIError("Failed to connect to '{}' with status code '{}' and reason '{}'".format(url, r.status, r.reason)) msg = r.read().decode('utf-8') logger.info('Status response message: %s', msg) + if 'FAIL' in msg.upper(): + logger.warning('WARNING - Remote debugging may not be setup properly. Reponse content: %s', msg) if '2222' in msg: return True return False @@ -103,7 +106,14 @@ def listen(self): self.client.settimeout(60) host = 'wss://{}{}'.format(self.remote_addr, '.scm.azurewebsites.net/AppServiceTunnel/Tunnel.ashx') basic_auth_header = 'Authorization: Basic {}'.format(basic_auth_string) - websocket.enableTrace(True) + cli_logger = get_logger() # get CLI logger which has the level set through command lines + is_verbose = any(handler.level <= logs.INFO for handler in cli_logger.handlers) + if is_verbose: + logger.info('Websocket tracing enabled') + websocket.enableTrace(True) + else: + logger.warning('Websocket tracing disabled, use --verbose flag to enable') + websocket.enableTrace(False) self.ws = create_connection(host, sockopt=((socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),), class_=TunnelWebSocket, @@ -119,11 +129,11 @@ def listen(self): debugger_thread.start() web_socket_thread.start() logger.info('Both debugger and websocket threads started...') - print('Successfully started local server..') + logger.warning('Successfully started local server..') debugger_thread.join() web_socket_thread.join() logger.info('Both debugger and websocket threads stopped...') - print('Stopped local server..') + logger.warning('Stopped local server..') def listen_to_web_socket(self, client, ws_socket, index): while True: @@ -172,5 +182,5 @@ def listen_to_client(self, client, ws_socket, index): return False def start_server(self): - print('Starting local server..') + logger.warning('Starting local server..') self.listen()