Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz Stempniewicz committed May 2, 2018
1 parent d6527df commit 8386275
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -349,7 +349,7 @@
"contacts": [
{
"email": "[email protected]",
"name": "Sisira Panchagnula",
"name": "Sisira Panchagnula, Lukasz Stempniewicz",
"role": "author"
}
],
Expand Down
4 changes: 2 additions & 2 deletions src/webapp/azext_webapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = """
Expand Down
6 changes: 3 additions & 3 deletions src/webapp/azext_webapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
18 changes: 14 additions & 4 deletions src/webapp/azext_webapp/tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time
import traceback
import websocket
import logging as logs

from contextlib import closing
from threading import Thread
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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()

0 comments on commit 8386275

Please sign in to comment.