Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#---------------------------------------------------------------------------------------------

# pylint: disable=no-self-use,too-many-arguments,too-many-lines
from __future__ import print_function
import threading
try:
from urllib.parse import urlparse
Expand Down Expand Up @@ -334,10 +335,28 @@ def _get_site_credential(client, resource_group, name):
return (creds.publishing_user_name, creds.publishing_password)

def _stream_trace(streaming_url, user_name, password):
import pycurl
import sys
import certifi
c = pycurl.Curl()
c.setopt(c.URL, streaming_url)
c.setopt(pycurl.CAINFO, certifi.where())
c.setopt(c.USERPWD, '{}:{}'.format(user_name, password))
c.perform()
import urllib3
try:
import urllib3.contrib.pyopenssl
urllib3.contrib.pyopenssl.inject_into_urllib3()
except ImportError:
pass

std_encoding = sys.stdout.encoding
http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where())
headers = urllib3.util.make_headers(basic_auth='{0}:{1}'.format(user_name, password))
r = http.request(
Copy link
Member

Choose a reason for hiding this comment

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

Don't you need to release the request at some point?

Copy link
Author

Choose a reason for hiding this comment

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

stream request will be closed when client reads the end of content or server terminates it.

Copy link
Author

Choose a reason for hiding this comment

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

Actually, I was wrong here. Added releasing connection here.

'GET',
streaming_url,
headers=headers,
preload_content=False
)
for chunk in r.stream():
if chunk:
# Extra encode() and decode for stdout which does not surpport 'utf-8'
print(chunk.decode(encoding='utf-8', errors='replace')
.encode(std_encoding, errors='replace')
.decode(std_encoding, errors='replace'), end='') # each line of log has CRLF.
r.release_conn()
3 changes: 2 additions & 1 deletion src/command_modules/azure-cli-webapp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
'azure==2.0.0rc6',
'azure-cli-core',
'azure-mgmt-web==0.30.0rc6',
'pycurl'
# v1.17 breaks on wildcard cert https://github.com/shazow/urllib3/issues/981
'urllib3[secure]==1.16'
]

with open('README.rst', 'r', encoding='utf-8') as f:
Expand Down