Skip to content

Commit

Permalink
remove requests dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
karolzak committed Sep 7, 2020
1 parent 000d0ce commit 75a3989
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 15 additions & 9 deletions pre_commit_nb/base64_to_image_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import os
import re
import subprocess
import urllib
import uuid
from typing import Optional, Sequence
from urllib.parse import urlparse

import requests


def base64_to_blob_storage(
base64_string: str,
Expand Down Expand Up @@ -52,16 +51,23 @@ def put_blob(
url = storage_url + container_name + '/' + blob_name + '?' + qry_string

# with open(file_name_full_path, 'rb') as fh:
response = requests.put(
url,
data=image_bytes,
req = urllib.request.Request(
url, data=image_bytes, method='PUT',
headers={
'content-type': mimetypes.types_map[file_ext],
'x-ms-blob-type': 'BlockBlob'
},
params={'file': file_name_only}
)
return response.status_code, url
})
response_code = urllib.request.urlopen(req).code
# response_code = requests.put(
# url,
# data=image_bytes,
# headers={
# 'content-type': mimetypes.types_map[file_ext],
# 'x-ms-blob-type': 'BlockBlob'
# },
# params={'file': file_name_only}
# ).status_code
return response_code, url


def base64_to_local_file(base64_string: str, image_path: str):
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.0",
version="0.2.1a",
description="Set of git pre-commit hooks for Jupyter Notebooks compatible with https://pre-commit.com/ framework",
long_description=long_description,
long_description_content_type="text/markdown", # This is important!
Expand Down

0 comments on commit 75a3989

Please sign in to comment.