Skip to content

Commit

Permalink
upd urllib usage
Browse files Browse the repository at this point in the history
  • Loading branch information
karolzak committed Sep 7, 2020
1 parent 6513de4 commit 1d8ed4e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pre_commit_nb/base64_to_external_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def base64_to_blob_storage(
base64_string: str,
az_blob_container_sas_url: str,
image_path: str) -> (int, str):
print("Uploading image to blob storage...")
image_bytes = base64_string_to_bytes(base64_string)

o = urlparse(az_blob_container_sas_url)
Expand Down Expand Up @@ -42,14 +41,15 @@ def http_put(
file_ext = os.path.splitext(file_name_only)[1]

url = storage_url + container_name + '/' + blob_name + '?' + qry_string

req = urllib.request.Request(
url, data=image_bytes, method='PUT',
headers={
'content-type': mimetypes.types_map[file_ext],
'x-ms-blob-type': 'BlockBlob'
})
response_code = urllib.request.urlopen(req).code
with urllib.request.urlopen(req) as response:
response_code = response.code
# response_code = urllib.request.urlopen(req).code
# response_code = requests.put(
# url,
# data=image_bytes,
Expand Down
1 change: 1 addition & 0 deletions pre_commit_nb/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def process_nb(
from pre_commit_nb.base64_to_external_storage import (
base64_to_blob_storage)

print("Uploading image to blob storage...")
response_status, url_path = base64_to_blob_storage(
base64_string, az_blob_container_url, full_path
)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="pre_commit_nb",
version="0.2.2a3",
version="0.2.2a4",
description="Set of git pre-commit hooks for Jupyter Notebooks compatible with https://pre-commit.com/ framework", # NOQA E501
long_description=long_description,
long_description_content_type="text/markdown", # This is important!
Expand Down

0 comments on commit 1d8ed4e

Please sign in to comment.