Skip to content

Commit d720424

Browse files
committed
Fixed Storage Blob stream
1 parent 8cbc238 commit d720424

8 files changed

Lines changed: 40 additions & 17 deletions

File tree

.github/workflows/deploy_to_test.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
with:
2121
python-version: '3.10'
2222

23-
- name: Install Requirements
24-
run: pip install -r requirements.txt
23+
- name: Installing git
24+
run: pip install gitpython
2525

2626
- name: Generating version file
2727
run: python freeze_version.py
@@ -32,9 +32,9 @@ jobs:
3232
- name: Building Package
3333
run: python setup.py bdist_wheel
3434

35-
# - name: Publish package
36-
# uses: pypa/gh-action-pypi-publish@release/v1
37-
# with:
38-
# skip_existing: true
39-
# password: ${{ secrets.PYPI_API_TOKEN }}
40-
# repository_url: https://test.pypi.org/legacy/
35+
- name: Publish package
36+
uses: pypa/gh-action-pypi-publish@release/v1
37+
with:
38+
skip_existing: true
39+
password: ${{ secrets.PYPI_API_TOKEN }}
40+
repository_url: https://test.pypi.org/legacy/

.github/workflows/publish_to_pypi.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ jobs:
4141
- name: Compare local and remote version with dpkg
4242
run: dpkg --compare-versions ${{env.localVersion}} "gt" ${{env.remoteVersion}}
4343

44-
- name: Install Requirements
45-
run: pip install -r requirements.txt
4644

4745
- name: Setup python wheel
4846
run: pip install wheel

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Change log
22

3+
### 0.0.5
4+
- Fixed Storage Blob stream
5+
36
### 0.0.4
47
- Fixed threading
58

freeze_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
build_date = date.today().strftime('%Y-%m-%d')
1313

14-
version = '0.0.4'
14+
version = '0.0.5'
1515

1616
with open(version_file_path, 'w+') as version_file:
1717
version_file.write("version = '{}'\n".format(version))

requirements.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@ azure-common==1.1.28
22
azure-core==1.26.1
33
azure-servicebus==7.0.0
44
azure-storage-blob==12.14.1
5+
certifi==2022.12.7
6+
cffi==1.15.1
7+
charset-normalizer==2.1.1
8+
cryptography==39.0.0
9+
idna==3.4
10+
isodate==0.6.1
11+
msrest==0.7.1
12+
oauthlib==3.2.2
13+
pycparser==2.21
514
python-dotenv==0.21.0
615
requests==2.28.1
7-
GitPython==3.1.29
16+
requests-oauthlib==1.3.1
17+
six==1.16.0
18+
typing_extensions==4.4.0
19+
uamqp==1.6.3
20+
urllib3==1.26.14

src/python_ms_core/core/storage/abstract/storage_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ def get_container(self, name: str): pass
99
def get_file(self, container_name: str, file_name: str): pass
1010

1111
@abstractmethod
12-
def get_file_from_url(self, full_url: str): pass
12+
def get_file_from_url(self, container_name: str, full_url: str): pass
1313

src/python_ms_core/core/storage/providers/azure/azure_file_entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def __init__(self, name, mimetype, blob_client):
1010
self.blob_client = blob_client
1111

1212
def get_stream(self):
13-
return self.blob_client.download_blob(encoding='latin1').readall()
13+
return self.blob_client.download_blob().readall()
1414

1515
def get_body_text(self):
1616
return self.blob_client.download_blob().content_as_text()

src/python_ms_core/core/storage/providers/azure/azure_storage_client.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import urllib.parse
23
from azure.storage.blob import BlobServiceClient
34
from ...abstract import storage_client
45
from . import azure_storage_config, azure_file_entity, azure_storage_container
@@ -25,7 +26,15 @@ def get_file(self, container_name, file_name):
2526
client_container = self._blob_service_client.get_container_client(container_name)
2627
blob_client = client_container.get_blob_client(file_name)
2728
properties = blob_client.get_blob_properties()
28-
return azure_file_entity.AzureFileEntity(file_name, properties.blob_type, blobClient=blob_client)
29+
return azure_file_entity.AzureFileEntity(file_name, properties.blob_type, blob_client)
2930

30-
def get_file_from_url(self, full_url):
31-
return super().getFileFromUrl(full_url)
31+
def get_file_from_url(self, container_name, full_url):
32+
path = '/'.join(urllib.parse.unquote(full_url).split('/')[4:])
33+
file = azure_file_entity.AzureFileEntity
34+
client_container = self._blob_service_client.get_container_client(container_name)
35+
blob_client = azure_storage_container.AzureStorageContainer(container_name, client_container)
36+
files = blob_client.list_files()
37+
for file_info in files:
38+
if file_info.file_path == path:
39+
file = file_info
40+
return file

0 commit comments

Comments
 (0)